Commit c1adae83 authored by Caitlin Ross's avatar Caitlin Ross

memset new messages to be 0

parent 30bb3be1
......@@ -30,7 +30,7 @@ AM_CFLAGS =
AM_CXXFLAGS = $(AM_CFLAGS)
LDADD = $(lib_LTLIBRARIES) $(ROSS_LIBS)
LDADD = $(lib_LTLIBRARIES) $(ROSS_LIBS) -lpthread
include Make.rules
......
......@@ -486,6 +486,7 @@ static void notify_background_traffic(
struct nw_message * m_new;
e = tw_event_new(global_dest_id, ts, lp);
m_new = (struct nw_message*)tw_event_data(e);
memset(m_new, 0, sizeof(nw_message));
m_new->msg_type = CLI_BCKGND_FIN;
tw_event_send(e);
}
......@@ -545,6 +546,7 @@ static void notify_neighbor(
struct nw_message * m_new;
e = tw_event_new(global_dest_id, ts, lp);
m_new = (struct nw_message*)tw_event_data(e);
memset(m_new, 0, sizeof(nw_message));
m_new->msg_type = CLI_NBR_FINISH;
tw_event_send(e);
}
......@@ -727,6 +729,7 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
nw_message * m_new;
e = tw_event_new(lp->gid, ts, lp);
m_new = (struct nw_message*)tw_event_data(e);
memset(m_new, 0, sizeof(nw_message));
m_new->msg_type = CLI_BCKGND_GEN;
tw_event_send(e);
......@@ -1265,6 +1268,7 @@ static void codes_issue_next_event(tw_lp* lp)
assert(ts > 0);
e = tw_event_new( lp->gid, ts, lp );
msg = (nw_message*)tw_event_data(e);
memset(msg, 0, sizeof(nw_message));
msg->msg_type = MPI_OP_GET_NEXT;
tw_event_send(e);
......@@ -1287,6 +1291,7 @@ static void codes_exec_comp_delay(
e = tw_event_new( lp->gid, ts , lp );
msg = (nw_message*)tw_event_data(e);
memset(msg, 0, sizeof(nw_message));
msg->msg_type = MPI_OP_GET_NEXT;
tw_event_send(e);
......@@ -1771,6 +1776,7 @@ static void update_arrival_queue(nw_state* s, tw_bf * bf, nw_message * m, tw_lp
tw_event_new(rank_to_lpid(global_src_id),
ts, lp);
nw_message *m_callback = (nw_message*)tw_event_data(e_callback);
memset(m_callback, 0, sizeof(nw_message));
m_callback->msg_type = MPI_SEND_ARRIVED_CB;
m_callback->fwd.msg_send_time = tw_now(lp) - m->fwd.sim_start_time;
tw_event_send(e_callback);
......@@ -1942,6 +1948,7 @@ void nw_test_init(nw_state* s, tw_lp* lp)
tw_stime ts = tw_rand_exponential(lp->rng, mean_interval/1000);
e = tw_event_new(lp->gid, ts, lp);
m_new = (nw_message*)tw_event_data(e);
memset(m_new, 0, sizeof(nw_message));
m_new->msg_type = CLI_BCKGND_GEN;
tw_event_send(e);
is_synthetic = 1;
......@@ -2018,6 +2025,7 @@ void nw_test_event_handler(nw_state* s, tw_bf * bf, nw_message * m, tw_lp * lp)
tw_event_new(rank_to_lpid(global_src_id),
codes_local_latency(lp), lp);
nw_message *m_callback = (nw_message*)tw_event_data(e_callback);
memset(m_callback, 0, sizeof(nw_message));
m_callback->msg_type = MPI_SEND_ARRIVED_CB;
m_callback->fwd.msg_send_time = tw_now(lp) - m->fwd.sim_start_time;
tw_event_send(e_callback);
......
......@@ -191,6 +191,7 @@ static void issue_event(
e = tw_event_new(lp->gid, kickoff_time, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(svr_msg));
m->svr_event_type = KICKOFF;
tw_event_send(e);
}
......
......@@ -231,6 +231,7 @@ static void issue_event(
e = tw_event_new(lp->gid, kickoff_time, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(svr_msg));
m->svr_event_type = KICKOFF;
tw_event_send(e);
}
......@@ -269,8 +270,8 @@ static void handle_kickoff_event(
char anno[MAX_NAME_LENGTH];
tw_lpid local_dest = -1, global_dest = -1;
svr_msg * m_local = malloc(sizeof(svr_msg));
svr_msg * m_remote = malloc(sizeof(svr_msg));
svr_msg * m_local = calloc(1, sizeof(svr_msg));
svr_msg * m_remote = calloc(1, sizeof(svr_msg));
m_local->svr_event_type = LOCAL;
m_local->src = lp->gid;
......
......@@ -277,6 +277,7 @@ static void issue_event(
e = tw_event_new(lp->gid, kickoff_time, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(svr_msg));
m->svr_event_type = KICKOFF;
tw_event_send(e);
}
......
......@@ -192,6 +192,7 @@ static void issue_event(
e = tw_event_new(lp->gid, kickoff_time, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(svr_msg));
m->svr_event_type = KICKOFF;
tw_event_send(e);
}
......
......@@ -1131,6 +1131,7 @@ static tw_stime dragonfly_custom_packet_event(
//msg = tw_event_data(e_new);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, DRAGONFLY_CUSTOM, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(terminal_custom_message));
strcpy(msg->category, req->category);
msg->final_dest_gid = req->final_dest_lp;
msg->total_size = req->msg_size;
......@@ -1205,10 +1206,12 @@ static void router_credit_send(router_state * s, terminal_custom_message * msg,
if (is_terminal) {
buf_e = model_net_method_event_new(dest, ts, lp, DRAGONFLY_CUSTOM,
(void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(terminal_custom_message));
buf_msg->magic = terminal_magic_num;
} else {
buf_e = model_net_method_event_new(dest, ts, lp, DRAGONFLY_CUSTOM_ROUTER,
(void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(terminal_custom_message));
buf_msg->magic = router_magic_num;
}
......@@ -1357,6 +1360,7 @@ static void packet_generate(terminal_state * s, tw_bf * bf, terminal_custom_mess
terminal_custom_message *m;
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_CUSTOM,
(void**)&m, NULL);
memset(m, 0, sizeof(terminal_custom_message));
m->type = T_SEND;
m->magic = terminal_magic_num;
s->in_send_loop = 1;
......@@ -1474,6 +1478,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_custom_message
void * remote_event;
e = model_net_method_event_new(router_id, ts, lp,
DRAGONFLY_CUSTOM_ROUTER, (void**)&m, &remote_event);
memset(m, 0, sizeof(terminal_custom_message));
memcpy(m, &cur_entry->msg, sizeof(terminal_custom_message));
if (m->remote_event_size_bytes){
memcpy(remote_event, cur_entry->event_data, m->remote_event_size_bytes);
......@@ -1501,6 +1506,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_custom_message
tw_stime local_ts = codes_local_latency(lp);
tw_event *e_new = tw_event_new(cur_entry->msg.sender_lp, local_ts, lp);
void * m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(terminal_custom_message));
void *local_event = (char*)cur_entry->event_data +
cur_entry->msg.remote_event_size_bytes;
memcpy(m_new, local_event, cur_entry->msg.local_event_size_bytes);
......@@ -1521,6 +1527,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_custom_message
ts += tw_rand_unif(lp->rng);
e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_CUSTOM,
(void**)&m_new, NULL);
memset(m_new, 0, sizeof(terminal_custom_message));
m_new->type = T_SEND;
m_new->magic = terminal_magic_num;
tw_event_send(e);
......@@ -1672,6 +1679,7 @@ static void send_remote_event(terminal_state * s, terminal_custom_message * msg,
else{
tw_event * e = tw_event_new(msg->final_dest_gid, ts, lp);
void * m_remote = tw_event_data(e);
memset(m_remote, 0, sizeof(terminal_custom_message));
memcpy(m_remote, event_data, remote_event_size);
tw_event_send(e);
}
......@@ -1728,6 +1736,7 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_custom_messag
terminal_custom_message * buf_msg;
buf_e = model_net_method_event_new(msg->intm_lp_id, ts, lp,
DRAGONFLY_CUSTOM_ROUTER, (void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(terminal_custom_message));
buf_msg->magic = router_magic_num;
buf_msg->vc_index = msg->vc_index;
buf_msg->output_chan = msg->output_chan;
......@@ -2278,6 +2287,7 @@ terminal_buf_update(terminal_state * s,
bf->c1 = 1;
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_CUSTOM,
(void**)&m, NULL);
memset(m, 0, sizeof(terminal_custom_message));
m->type = T_SEND;
m->magic = terminal_magic_num;
s->in_send_loop = 1;
......@@ -3209,6 +3219,7 @@ router_packet_receive( router_state * s,
ts = codes_local_latency(lp);
tw_event *e = model_net_method_event_new(lp->gid, ts, lp,
DRAGONFLY_CUSTOM_ROUTER, (void**)&m, NULL);
memset(m, 0, sizeof(terminal_custom_message));
m->type = R_SEND;
m->magic = router_magic_num;
m->vc_index = output_port;
......@@ -3369,10 +3380,12 @@ router_packet_send( router_state * s,
e = model_net_method_event_new(cur_entry->msg.next_stop,
s->next_output_available_time[output_port] - tw_now(lp), lp,
DRAGONFLY_CUSTOM, (void**)&m, &m_data);
memset(m, 0, sizeof(terminal_custom_message));
} else {
e = model_net_method_event_new(cur_entry->msg.next_stop,
s->next_output_available_time[output_port] - tw_now(lp), lp,
DRAGONFLY_CUSTOM_ROUTER, (void**)&m, &m_data);
memset(m, 0, sizeof(terminal_custom_message));
}
memcpy(m, &cur_entry->msg, sizeof(terminal_custom_message));
if (m->remote_event_size_bytes){
......@@ -3441,6 +3454,7 @@ router_packet_send( router_state * s,
ts += g_tw_lookahead + tw_rand_unif(lp->rng);
e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_CUSTOM_ROUTER,
(void**)&m_new, NULL);
memset(m_new, 0, sizeof(terminal_custom_message));
m_new->type = R_SEND;
m_new->magic = router_magic_num;
m_new->vc_index = output_port;
......@@ -3518,6 +3532,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, terminal_custom_mess
tw_stime ts = codes_local_latency(lp);
tw_event *e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_CUSTOM_ROUTER,
(void**)&m, NULL);
memset(m, 0, sizeof(terminal_custom_message));
m->type = R_SEND;
m->vc_index = indx;
m->magic = router_magic_num;
......
......@@ -1024,6 +1024,7 @@ static tw_stime dragonfly_packet_event(
//msg = tw_event_data(e_new);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, DRAGONFLY, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(terminal_message));
strcpy(msg->category, req->category);
msg->final_dest_gid = req->final_dest_lp;
msg->total_size = req->msg_size;
......@@ -1134,10 +1135,12 @@ static void router_credit_send(router_state * s, terminal_message * msg,
if (is_terminal) {
buf_e = model_net_method_event_new(dest, ts, lp, DRAGONFLY,
(void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(terminal_message));
buf_msg->magic = terminal_magic_num;
} else {
buf_e = model_net_method_event_new(dest, ts, lp, DRAGONFLY_ROUTER,
(void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(terminal_message));
buf_msg->magic = router_magic_num;
}
......@@ -1276,6 +1279,7 @@ static void packet_generate(terminal_state * s, tw_bf * bf, terminal_message * m
terminal_message *m;
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY,
(void**)&m, NULL);
memset(m, 0, sizeof(terminal_message));
m->type = T_SEND;
m->magic = terminal_magic_num;
s->in_send_loop = 1;
......@@ -1393,6 +1397,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_message * msg,
void * remote_event;
e = model_net_method_event_new(router_id, ts, lp,
DRAGONFLY_ROUTER, (void**)&m, &remote_event);
memset(m, 0, sizeof(terminal_message));
memcpy(m, &cur_entry->msg, sizeof(terminal_message));
if (m->remote_event_size_bytes){
memcpy(remote_event, cur_entry->event_data, m->remote_event_size_bytes);
......@@ -1415,6 +1420,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_message * msg,
tw_stime local_ts = codes_local_latency(lp);
tw_event *e_new = tw_event_new(cur_entry->msg.sender_lp, local_ts, lp);
void * m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(terminal_message));
void *local_event = (char*)cur_entry->event_data +
cur_entry->msg.remote_event_size_bytes;
memcpy(m_new, local_event, cur_entry->msg.local_event_size_bytes);
......@@ -1436,6 +1442,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_message * msg,
ts += tw_rand_unif(lp->rng);
e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY,
(void**)&m_new, NULL);
memset(m_new, 0, sizeof(terminal_message));
m_new->type = T_SEND;
m_new->magic = terminal_magic_num;
tw_event_send(e);
......@@ -1582,6 +1589,7 @@ static void send_remote_event(terminal_state * s, terminal_message * msg, tw_lp
else{
tw_event * e = tw_event_new(msg->final_dest_gid, ts, lp);
void * m_remote = tw_event_data(e);
memset(m_remote, 0, sizeof(terminal_message));
memcpy(m_remote, event_data, remote_event_size);
tw_event_send(e);
}
......@@ -1638,6 +1646,7 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_message * msg
terminal_message * buf_msg;
buf_e = model_net_method_event_new(msg->intm_lp_id, ts, lp,
DRAGONFLY_ROUTER, (void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(terminal_message));
buf_msg->magic = router_magic_num;
buf_msg->vc_index = msg->vc_index;
buf_msg->output_chan = msg->output_chan;
......@@ -1816,6 +1825,7 @@ static void dragonfly_collective(char const * category, int message_size, int re
xfer_to_nic_time = codes_local_latency(sender);
e_new = model_net_method_event_new(local_nic_id, xfer_to_nic_time,
sender, DRAGONFLY, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(terminal_message));
msg->remote_event_size_bytes = message_size;
strcpy(msg->category, category);
......@@ -1856,6 +1866,7 @@ static void send_collective_remote_event(terminal_state * s,
ts = (1/s->params->cn_bandwidth) * msg->remote_event_size_bytes;
e = tw_event_new(s->origin_svr, ts, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(terminal_message));
char* tmp_ptr = (char*)msg;
tmp_ptr += dragonfly_get_msg_sz();
memcpy(m, tmp_ptr, msg->remote_event_size_bytes);
......@@ -1897,6 +1908,7 @@ static void node_collective_init(terminal_state * s,
void* m_data;
e_new = model_net_method_event_new(parent_nic_id, xfer_to_nic_time,
lp, DRAGONFLY, (void**)&msg_new, (void**)&m_data);
memset(msg_new, 0, sizeof(terminal_message));
memcpy(msg_new, msg, sizeof(terminal_message));
if (msg->remote_event_size_bytes){
......@@ -1953,6 +1965,7 @@ static void node_collective_fan_in(terminal_state * s,
e_new = model_net_method_event_new(parent_nic_id,
xfer_to_nic_time,
lp, DRAGONFLY, (void**)&msg_new, &m_data);
memset(msg_new, 0, sizeof(terminal_message));
memcpy(msg_new, msg, sizeof(terminal_message));
msg_new->type = D_COLLECTIVE_FAN_IN;
......@@ -1991,6 +2004,7 @@ static void node_collective_fan_in(terminal_state * s,
e_new = model_net_method_event_new(child_nic_id,
xfer_to_nic_time,
lp, DRAGONFLY, (void**)&msg_new, &m_data);
memset(msg_new, 0, sizeof(terminal_message));
memcpy(msg_new, msg, sizeof(terminal_message));
if (msg->remote_event_size_bytes){
......@@ -2045,6 +2059,7 @@ static void node_collective_fan_out(terminal_state * s,
e_new = model_net_method_event_new(child_nic_id,
xfer_to_nic_time,
lp, DRAGONFLY, (void**)&msg_new, &m_data);
memset(msg_new, 0, sizeof(terminal_message));
memcpy(msg_new, msg, sizeof(nodes_message));
if (msg->remote_event_size_bytes){
memcpy(m_data, model_net_method_get_edata(DRAGONFLY, msg),
......@@ -2482,6 +2497,7 @@ terminal_buf_update(terminal_state * s,
bf->c1 = 1;
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY,
(void**)&m, NULL);
memset(m, 0, sizeof(terminal_message));
m->type = T_SEND;
m->magic = terminal_magic_num;
s->in_send_loop = 1;
......@@ -3035,6 +3051,7 @@ router_packet_receive( router_state * s,
ts = codes_local_latency(lp);
tw_event *e = model_net_method_event_new(lp->gid, ts, lp,
DRAGONFLY_ROUTER, (void**)&m, NULL);
memset(m, 0, sizeof(terminal_message));
m->type = R_SEND;
m->magic = router_magic_num;
m->vc_index = output_port;
......@@ -3198,6 +3215,7 @@ router_packet_send( router_state * s,
s->next_output_available_time[output_port] - tw_now(lp), lp,
DRAGONFLY_ROUTER, (void**)&m, &m_data);
}
memset(m, 0, sizeof(terminal_message));
memcpy(m, &cur_entry->msg, sizeof(terminal_message));
if (m->remote_event_size_bytes){
memcpy(m_data, cur_entry->event_data, m->remote_event_size_bytes);
......@@ -3272,6 +3290,7 @@ router_packet_send( router_state * s,
ts = ts + g_tw_lookahead * tw_rand_unif(lp->rng);
e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_ROUTER,
(void**)&m_new, NULL);
memset(m_new, 0, sizeof(terminal_message));
m_new->type = R_SEND;
m_new->magic = router_magic_num;
m_new->vc_index = output_port;
......@@ -3349,6 +3368,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, terminal_message * m
tw_stime ts = codes_local_latency(lp);
tw_event *e = model_net_method_event_new(lp->gid, ts, lp, DRAGONFLY_ROUTER,
(void**)&m, NULL);
memset(m, 0, sizeof(terminal_message));
m->type = R_SEND;
m->vc_index = indx;
m->magic = router_magic_num;
......
......@@ -1541,6 +1541,7 @@ static tw_stime fattree_packet_event(
xfer_to_nic_time = codes_local_latency(sender);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time + offset,
sender, FATTREE, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(fattree_message));
strcpy(msg->category, req->category);
msg->final_dest_gid = req->final_dest_lp;
msg->total_size = req->msg_size;
......@@ -1677,7 +1678,7 @@ void ft_packet_generate(ft_terminal_state * s, tw_bf * bf, fattree_message * msg
init_fattree_message_list(cur_chunk, msg);
if(msg->remote_event_size_bytes + msg->local_event_size_bytes > 0) {
cur_chunk->event_data = (char*)malloc(
cur_chunk->event_data = (char*)calloc(1,
msg->remote_event_size_bytes + msg->local_event_size_bytes);
}
......@@ -1713,6 +1714,7 @@ void ft_packet_generate(ft_terminal_state * s, tw_bf * bf, fattree_message * msg
ts = codes_local_latency(lp);
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, FATTREE,
(void**)&m, NULL);
memset(m, 0, sizeof(fattree_message));
m->type = T_SEND;
m->vc_index = target_queue;
m->magic = fattree_terminal_magic_num;
......@@ -1822,6 +1824,7 @@ void ft_packet_send(ft_terminal_state * s, tw_bf * bf, fattree_message * msg,
e = tw_event_new(s->switch_lp[msg->vc_index], ts, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(fattree_message));
memcpy(m, &cur_entry->msg, sizeof(fattree_message));
if (m->remote_event_size_bytes){
memcpy(model_net_method_get_edata(FATTREE, m), cur_entry->event_data,
......@@ -1847,6 +1850,7 @@ void ft_packet_send(ft_terminal_state * s, tw_bf * bf, fattree_message * msg,
double tsT = codes_local_latency(lp);
tw_event *e_new = tw_event_new(cur_entry->msg.sender_lp, tsT, lp);
fattree_message *m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(fattree_message));
void *local_event = (char*)cur_entry->event_data +
cur_entry->msg.remote_event_size_bytes;
memcpy(m_new, local_event, cur_entry->msg.local_event_size_bytes);
......@@ -1871,6 +1875,7 @@ void ft_packet_send(ft_terminal_state * s, tw_bf * bf, fattree_message * msg,
ts = ts + g_tw_lookahead * tw_rand_unif(lp->rng);
e = model_net_method_event_new(lp->gid, ts, lp, FATTREE,
(void**)&m_new, NULL);
memset(m_new, 0, sizeof(fattree_message));
m_new->type = T_SEND;
m_new->vc_index = msg->vc_index;
m_new->magic = fattree_terminal_magic_num;
......@@ -1955,7 +1960,7 @@ void switch_packet_receive( switch_state * s, tw_bf * bf,
{
void *m_data_src = model_net_method_get_edata(FATTREE, msg);
cur_chunk->event_data = (char*)malloc(msg->remote_event_size_bytes);
cur_chunk->event_data = (char*)calloc(1, msg->remote_event_size_bytes);
memcpy(cur_chunk->event_data, m_data_src,
msg->remote_event_size_bytes);
}
......@@ -1976,6 +1981,7 @@ void switch_packet_receive( switch_state * s, tw_bf * bf,
ts = codes_local_latency(lp);
tw_event *e = tw_event_new(lp->gid, ts, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(fattree_message));
m->type = S_SEND;
m->magic = switch_magic_num;
m->vc_index = output_port;
......@@ -2095,9 +2101,11 @@ void switch_packet_send( switch_state * s, tw_bf * bf, fattree_message * msg,
if (to_terminal) {
e = model_net_method_event_new(next_stop, ts, lp,
FATTREE, (void**)&m, &m_data);
memset(m, 0, sizeof(fattree_message));
} else {
e = tw_event_new(next_stop, ts, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(fattree_message));
m_data = model_net_method_get_edata(FATTREE, m);
}
......@@ -2146,6 +2154,7 @@ void switch_packet_send( switch_state * s, tw_bf * bf, fattree_message * msg,
ts = ts + g_tw_lookahead * tw_rand_unif(lp->rng);
e = tw_event_new(lp->gid, ts, lp);
m_new = tw_event_data(e);
memset(m_new, 0, sizeof(fattree_message));
m_new->type = S_SEND;
m_new->magic = switch_magic_num;
m_new->vc_index = output_port;
......@@ -2194,10 +2203,12 @@ void switch_credit_send(switch_state * s, tw_bf * bf, fattree_message * msg,
if (is_terminal) {
buf_e = model_net_method_event_new(dest, ts, lp, FATTREE,
(void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(fattree_message));
buf_msg->magic = fattree_terminal_magic_num;
} else {
buf_e = tw_event_new(dest, ts , lp);
buf_msg = tw_event_data(buf_e);
memset(buf_msg, 0, sizeof(fattree_message));
buf_msg->magic = switch_magic_num;
}
......@@ -2258,6 +2269,7 @@ void ft_terminal_buf_update(ft_terminal_state * s, tw_bf * bf,
bf->c1 = 1;
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, FATTREE,
(void**)&m, NULL);
memset(m, 0, sizeof(fattree_message));
m->type = T_SEND;
m->vc_index = msg->vc_index;
m->magic = fattree_terminal_magic_num;
......@@ -2340,6 +2352,7 @@ void switch_buf_update(switch_state * s, tw_bf * bf, fattree_message * msg,
tw_stime ts = codes_local_latency(lp);
tw_event *e = tw_event_new(lp->gid, ts, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(fattree_message));
m->type = S_SEND;
m->vc_index = indx;
m->magic = switch_magic_num;
......@@ -2375,6 +2388,7 @@ void ft_send_remote_event(ft_terminal_state * s, fattree_message * msg, tw_lp *
else{
tw_event * e = tw_event_new(msg->final_dest_gid, ts, lp);
void * m_remote = tw_event_data(e);
memset(m_remote, 0, sizeof(fattree_message));
memcpy(m_remote, event_data, remote_event_size);
tw_event_send(e);
}
......@@ -2500,6 +2514,7 @@ void ft_packet_arrive(ft_terminal_state * s, tw_bf * bf, fattree_message * msg,
// no method_event here - message going to switch
buf_e = tw_event_new(s->switch_lp[msg->rail_id], ts, lp);
buf_msg = tw_event_data(buf_e);
memset(buf_msg, 0, sizeof(fattree_message));
buf_msg->magic = switch_magic_num;
buf_msg->vc_index = msg->vc_index;
buf_msg->type = S_BUFFER;
......@@ -2615,7 +2630,7 @@ void ft_packet_arrive(ft_terminal_state * s, tw_bf * bf, fattree_message * msg,
if(msg->remote_event_size_bytes > 0 && !tmp->remote_event_data)
{
/* Retreive the remote event entry */
tmp->remote_event_data = (void*)malloc(msg->remote_event_size_bytes);
tmp->remote_event_data = (void*)calloc(1, msg->remote_event_size_bytes);
assert(tmp->remote_event_data);
tmp->remote_event_size = msg->remote_event_size_bytes;
memcpy(tmp->remote_event_data, m_data_src, msg->remote_event_size_bytes);
......
......@@ -441,6 +441,7 @@ static void handle_msg_ready_event(
else{
e_new = tw_event_new(m->final_dest_gid, recv_queue_time, lp);
m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(loggp_message));
memcpy(m_new, tmp_ptr, m->event_size_bytes);
tw_event_send(e_new);
}
......@@ -556,6 +557,7 @@ static void handle_msg_start_event(
void *m_data;
e_new = model_net_method_event_new(m->dest_mn_lp, send_queue_time, lp, LOGGP,
(void**)&m_new, &m_data);
memset(m_new, 0, sizeof(loggp_message));
/* copy entire previous message over, including payload from user of
* this module
*/
......@@ -584,6 +586,7 @@ static void handle_msg_start_event(
e_new = tw_event_new(m->src_gid, send_queue_time+codes_local_latency(lp), lp);
m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(loggp_message));
void * m_loc = (char*) model_net_method_get_edata(LOGGP, m) +
m->event_size_bytes;
......@@ -620,6 +623,7 @@ static tw_stime loggp_packet_event(
xfer_to_nic_time = codes_local_latency(sender);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, LOGGP, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(loggp_message));
//e_new = tw_event_new(dest_id, xfer_to_nic_time+offset, sender);
//msg = tw_event_data(e_new);
strcpy(msg->category, req->category);
......@@ -681,6 +685,7 @@ tw_stime loggp_recv_msg_event(
// this message goes to myself
tw_event *e = model_net_method_event_new(sender->gid, moffset, sender,
LOGGP, (void**)&m, &m_data);
memset(m, 0, sizeof(loggp_message));
m->magic = loggp_magic;
m->event_type = LG_MSG_READY;
......
......@@ -210,6 +210,7 @@ static void issue_sample_event(tw_lp *lp)
if (tw_now(lp) + mn_sample_interval < mn_sample_end + 0.0001) {
tw_event *e = tw_event_new(lp->gid, mn_sample_interval, lp);
model_net_wrap_msg *m = tw_event_data(e);
memset(m, 0, sizeof(model_net_wrap_msg));
msg_set_header(model_net_base_magic, MN_BASE_SAMPLE, lp->gid, &m->h);
tw_event_send(e);
}
......@@ -648,14 +649,18 @@ void handle_new_msg(
if (remote_event_size > 0) {
exp_time += delay;
tw_event *e = tw_event_new(r->final_dest_lp, exp_time, lp);
memcpy(tw_event_data(e), e_msg, remote_event_size);
model_net_wrap_msg *m_new = tw_event_data(e);
memset(m_new, 0, sizeof(model_net_wrap_msg));
memcpy(m_new, e_msg, remote_event_size);
tw_event_send(e);
e_msg = (char*)e_msg + remote_event_size;
}
if (self_event_size > 0) {
exp_time += delay;
tw_event *e = tw_event_new(r->src_lp, exp_time, lp);
memcpy(tw_event_data(e), e_msg, self_event_size);
model_net_wrap_msg *m_new = tw_event_data(e);
memset(m_new, 0, sizeof(model_net_wrap_msg));
memcpy(m_new, e_msg, self_event_size);
tw_event_send(e);
}
return;
......@@ -668,6 +673,7 @@ void handle_new_msg(
ns->next_available_time = exp_time;
tw_event *e = tw_event_new(lp->gid, exp_time - tw_now(lp), lp);
model_net_wrap_msg *m_new = tw_event_data(e);
memset(m_new, 0, sizeof(model_net_wrap_msg));
memcpy(m_new, m, sizeof(model_net_wrap_msg));
void *e_msg = (m+1);
void *e_new_msg = (m_new+1);
......@@ -800,6 +806,7 @@ void handle_sched_next(
tw_event *e = tw_event_new(lp->gid,
poffset+codes_local_latency(lp), lp);
model_net_wrap_msg *m_wrap = tw_event_data(e);
memset(m_wrap, 0, sizeof(model_net_wrap_msg));
model_net_request *r_wrap = &m_wrap->msg.m_base.req;
msg_set_header(model_net_base_magic, MN_BASE_SCHED_NEXT, lp->gid,
&m_wrap->h);
......@@ -841,6 +848,7 @@ tw_event * model_net_method_event_new(
void **extra_data){
tw_event *e = tw_event_new(dest_gid, offset_ts, sender);
model_net_wrap_msg *m_wrap = tw_event_data(e);
memset(m_wrap, 0, sizeof(model_net_wrap_msg));
msg_set_header(model_net_base_magic, MN_BASE_PASS, sender->gid,
&m_wrap->h);
*msg_data = ((char*)m_wrap)+msg_offsets[net_id];
......@@ -868,6 +876,7 @@ void model_net_method_send_msg_recv_event(
tw_event *e =
tw_event_new(dest_mn_lp, offset+codes_local_latency(sender), sender);
model_net_wrap_msg *m = tw_event_data(e);
memset(m, 0, sizeof(model_net_wrap_msg));
msg_set_header(model_net_base_magic, MN_BASE_NEW_MSG, sender->gid, &m->h);
if (sched_params != NULL)
......@@ -915,6 +924,7 @@ void model_net_method_idle_event2(tw_stime offset_ts, int is_recv_queue,
int queue_offset, tw_lp * lp){
tw_event *e = tw_event_new(lp->gid, offset_ts, lp);
model_net_wrap_msg *m_wrap = tw_event_data(e);
memset(m_wrap, 0, sizeof(model_net_wrap_msg));
model_net_request *r_wrap = &m_wrap->msg.m_base.req;
msg_set_header(model_net_base_magic, MN_BASE_SCHED_NEXT, lp->gid,
&m_wrap->h);
......
......@@ -387,6 +387,7 @@ static void handle_msg_ready_event(
else{
tw_event * e_new = tw_event_new(m->final_dest_gid, recv_queue_time, lp);
void * m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(sn_message));
memcpy(m_new, tmp_ptr, m->event_size_bytes);
tw_event_send(e_new);
}
......@@ -463,6 +464,7 @@ static void handle_msg_start_event(
void *m_data;
e_new = model_net_method_event_new(m->dest_mn_lp, send_queue_time, lp,
SIMPLENET, (void**)&m_new, &m_data);
memset(m_new, 0, sizeof(sn_message));
/* copy entire previous message over, including payload from user of
* this module
......@@ -494,6 +496,7 @@ static void handle_msg_start_event(
e_new = tw_event_new(m->src_gid, send_queue_time+codes_local_latency(lp), lp);
m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(sn_message));
void * m_loc = (char*) model_net_method_get_edata(SIMPLENET, m) +
m->event_size_bytes;
......@@ -535,6 +538,7 @@ static tw_stime simplenet_packet_event(
// this is a self message
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, SIMPLENET, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(sn_message));
strcpy(msg->category, req->category);
msg->src_gid = req->src_lp;
msg->src_mn_lp = sender->gid;
......
......@@ -1126,6 +1126,7 @@ static tw_stime slimfly_packet_event(
//msg = tw_event_data(e_new);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, SLIMFLY, (void**)&msg, (void**)&tmp_ptr);
memset(msg, 0, sizeof(slim_terminal_message));
strcpy(msg->category, req->category);
msg->final_dest_gid = req->final_dest_lp;
msg->total_size = req->msg_size;
......@@ -1206,10 +1207,12 @@ void slim_router_credit_send(router_state * s, slim_terminal_message * msg, tw_l
if (is_terminal) {
buf_e = model_net_method_event_new(dest, ts, lp, SLIMFLY,
(void**)&buf_msg, NULL);
memset(buf_msg, 0, sizeof(slim_terminal_message));
buf_msg->magic = slim_terminal_magic_num;
} else {
buf_e = tw_event_new(dest, ts , lp);
buf_msg = tw_event_data(buf_e);
memset(buf_msg, 0, sizeof(slim_terminal_message));
buf_msg->magic = slim_router_magic_num;
}
......@@ -1348,6 +1351,7 @@ void slim_packet_generate(terminal_state * s, tw_bf * bf, slim_terminal_message
slim_terminal_message *m;
tw_event* e = model_net_method_event_new(lp->gid, ts, lp, SLIMFLY,
(void**)&m, NULL);
memset(m, 0, sizeof(slim_terminal_message));
m->type = T_SEND;
m->magic = slim_terminal_magic_num;
s->in_send_loop = 1;
......@@ -1464,6 +1468,7 @@ void slim_packet_send(terminal_state * s, tw_bf * bf, slim_terminal_message * ms
// we are sending an event to the router, so no method_event here
e = tw_event_new(router_id, ts, lp);
m = tw_event_data(e);
memset(m, 0, sizeof(slim_terminal_message));
memcpy(m, &cur_entry->msg, sizeof(slim_terminal_message));
if (m->remote_event_size_bytes)
{
......@@ -1507,6 +1512,7 @@ void slim_packet_send(terminal_state * s, tw_bf * bf, slim_terminal_message * ms
tw_stime local_ts = codes_local_latency(lp);
tw_event *e_new = tw_event_new(cur_entry->msg.sender_lp, local_ts, lp);
slim_terminal_message* m_new = tw_event_data(e_new);
memset(m_new, 0, sizeof(slim_terminal_message));
void *local_event = (char*)cur_entry->event_data +
cur_entry->msg.remote_event_size_bytes;
memcpy(m_new, local_event, cur_entry->msg.local_event_size_bytes);
......@@ -1530,6 +1536,7 @@ void slim_packet_send(terminal_state * s, tw_bf * bf, slim_terminal_message * ms
ts += tw_rand_unif(lp->rng);
tw_event* e_new = model_net_method_event_new(lp->gid, ts, lp, SLIMFLY,
(void**)&m_new, NULL);
memset(m_new, 0, sizeof(slim_terminal_message));
m_new->type = T_SEND;
m_new->magic = slim_terminal_magic_num;
tw_event_send(e_new);
......@@ -1655,6 +1662,7 @@ void slim_send_remote_event(terminal_state * s, slim_terminal_message * msg, tw_
else{
tw_event * e = tw_event_new(msg->final_dest_gid, ts, lp);
void * m_remote = tw_event_data(e);