Commit bae020ee authored by Xin Wang's avatar Xin Wang

update reverse handler

parent 2ff1d030
......@@ -304,6 +304,7 @@ struct nw_message
int msg_type;
int op_type;
model_net_event_return event_rc;
model_net_event_return *event_array_rc;
struct
{
......@@ -330,6 +331,10 @@ struct nw_message
double saved_wait_time;
double saved_delay;
int64_t saved_num_bytes;
int saved_num_msg_sizes;
uint64_t saved_col_size;
double saved_col_time;
int saved_syn_length;
} rc;
};
......@@ -611,11 +616,13 @@ static void gen_synthetic_tr_rc(nw_state * s, tw_bf * bf, nw_message * m, tw_lp
{
if(bf->c0)
return;
int i;
for (i=0; i < m->rc.saved_syn_length; i++){
model_net_event_rc2(lp, &m->event_array_rc[i]);
s->gen_data -= payload_sz;
num_syn_bytes_sent -= payload_sz;
}
model_net_event_rc2(lp, &m->event_rc);
s->gen_data -= payload_sz;
num_syn_bytes_sent -= payload_sz;
tw_rand_reverse_unif(lp->rng);
tw_rand_reverse_unif(lp->rng);
......@@ -648,7 +655,7 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
{
case UNIFORM:
{
length = 1;
length = 1;
dest_svr = (int*) calloc(1, sizeof(int));
dest_svr[0] = tw_rand_integer(lp->rng, 0, num_clients - 1);
if(dest_svr[0] == s->local_rank)
......@@ -657,7 +664,7 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
break;
case NEAREST_NEIGHBOR:
{
length = 1;
length = 1;
dest_svr = (int*) calloc(1, sizeof(int));
dest_svr[0] = (s->local_rank + 1) % num_clients;
}
......@@ -672,12 +679,12 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
{
dest_svr[index] = i;
index++;
length++;
length++;
}
}
}
break;
case STENCIL:
case STENCIL: //2D 4-point stencil
{
int digits, x=1, y=1, row, col, temp=num_clients;
length = 4;
......@@ -700,13 +707,17 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
break;
}
/* Record length for reverse handler*/
m->rc.saved_syn_length = length
if(length > 0)
{
m->event_array_rc = (model_net_event_return) malloc(length * sizeof(model_net_event_return));
//printf("\nRANK %d Dests %d", s->local_rank, length);
for (i = 0; i < length; i++)
{
/* Generate synthetic traffic */
//printf("\nAPP %d SRC %d Dest %d", jid.job, s->local_rank, dest_svr[i]);
//printf("\nAPP %d SRC %d Dest %d", jid.job, s->local_rank, dest_svr[i]);
jid.rank = dest_svr[i];
intm_dest_id = codes_jobmap_to_global_id(jid, jobmap_ctx);
global_dest_id = codes_mapping_get_lpid_from_relative(intm_dest_id, NULL, NW_LP_NM, NULL, 0);
......@@ -718,7 +729,7 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
remote_m.fwd.app_id = s->app_id;
remote_m.fwd.src_rank = s->local_rank;
m->event_rc = model_net_event(net_id, "synthetic-tr", global_dest_id, payload_sz, 0.0,
m->event_array_rc[i] = model_net_event(net_id, "synthetic-tr", global_dest_id, payload_sz, 0.0,
sizeof(nw_message), (const void*)&remote_m,
0, NULL, lp);
......@@ -2170,16 +2181,21 @@ static void get_next_mpi_operation_rc(nw_state* s, tw_bf * bf, nw_message * m, t
{
if(bf->c1)
{
s->col_latency[s->num_msg_sizes] = 0;
s->col_msizes[s->num_msg_sizes] = 0;
//todo: reverse handler for num_msg_sizes
s->num_msg_sizes = m->rc.saved_num_msg_sizes;
if(s->num_msg_sizes > 0){
s->col_latency[s->num_msg_sizes-1] = m->rc.saved_col_time;
s->col_msizes[s->num_msg_sizes-1] = m->rc.saved_col_size;
}
s->num_all_reduce--;
s->col_time = m->rc.saved_send_time;
s->all_reduce_time = m->rc.saved_delay;
if(enable_col_overhead)
s->is_collective = 1;
}
else
{
s->col_time = 0;
s->is_collective = 0;
}
codes_issue_next_event_rc(lp);
}
......@@ -2318,15 +2334,20 @@ static void get_next_mpi_operation(nw_state* s, tw_bf * bf, nw_message * m, tw_l
{
bf->c1 = 1;
m->rc.saved_delay = s->all_reduce_time;
if(s->num_msg_sizes == 0)
{
s->num_msg_sizes += 1;
}
else if(s->col_msizes[s->num_msg_sizes-1] != mpi_op.u.collective.num_bytes)
{
s->num_msg_sizes += 1;
}
s->col_latency[s->num_msg_sizes-1] += (tw_now(lp) - s->col_time);
m->rc.saved_num_msg_sizes = s->num_msg_sizes;
if (s->num_msg_sizes>0){
m->rc.saved_col_size = s->col_msizes[s->num_msg_sizes-1];
m->rc.saved_col_time = s->col_latency[s->num_msg_sizes-1];
}
if(s->num_msg_sizes == 0)
{
s->num_msg_sizes += 1;
}
else if(s->col_msizes[s->num_msg_sizes-1] != mpi_op.u.collective.num_bytes)
{
s->num_msg_sizes += 1;
}
s->col_latency[s->num_msg_sizes-1] += (tw_now(lp) - s->col_time);
s->col_msizes[s->num_msg_sizes-1] = mpi_op.u.collective.num_bytes;
s->all_reduce_time += (tw_now(lp) - s->col_time);
m->rc.saved_send_time = s->col_time;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment