Commit 5e226ab7 authored by Xin's avatar Xin

bug fix: add multiple synthetic traffic patterns

parent 4b002c5e
......@@ -616,6 +616,8 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
/* Get job information */
tw_lpid global_dest_id;
int intm_dest_id;
nw_message remote_m;
struct codes_jobmap_id jid;
jid = codes_jobmap_to_local_id(s->nw_id, jobmap_ctx);
......@@ -624,24 +626,27 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
/* Find destination */
int* dest_svr; int i;
int* dest_svr = NULL;
int i, length=0;
switch(s->synthetic_pattern)
{
case(UNIFORM):
case UNIFORM:
{
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)
dest_svr[0] = (s->local_rank + 1) % num_clients;
}
break;
case(NEAREST_NEIGHBOR):
case NEAREST_NEIGHBOR:
{
length = 1;
dest_svr = (int*) calloc(1, sizeof(int));
dest_svr[0] = (s->local_rank + 1) % num_clients;
}
break;
case(ALLTOALL):
case ALLTOALL:
{
dest_svr = (int*) calloc(num_clients-1, sizeof(int));
int index = 0;
......@@ -651,21 +656,23 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
{
dest_svr[index] = i;
index++;
length++;
}
}
}
break;
case(STENCIL):
case STENCIL:
{
int digits, x=1, y=1, row, col;
int digits, x=1, y=1, row, col, temp=num_clients;
length = 4;
dest_svr = (int*) calloc(4, sizeof(int));
for (digits = 0; num_clients > 0; num_clients >>= 1)
for (digits = 0; temp > 0; temp >>= 1)
digits++;
digits = digits/2;
for (i = 0; i < digits; i++)
x = x * 2;
y = num_clients / y;
printf("\nStencil Syn: x=%d, y=%d", x, y);
y = num_clients / x;
//printf("\nStencil Syn: x=%d, y=%d", x, y);
row = s->local_rank / y;
col = s->local_rank % y;
......@@ -675,23 +682,19 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
dest_svr[3] = ((row+1+x)%x) * y + col; /* up neighbor */
}
break;
default:
{
printf("\n Invalid op type %d ", mpi_op.op_type);
dest_svr = NULL;
}
}
if(dest_svr != NULL)
if(length > 0)
{
for (i = 0; i < sizeof(dest_svr)/sizeof(int); i++)
//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]);
jid.rank = dest_svr[i];
int intm_dest_id = codes_jobmap_to_global_id(jid, jobmap_ctx);
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);
nw_message remote_m;
remote_m.fwd.sim_start_time = tw_now(lp);
remote_m.fwd.dest_rank = dest_svr[i];
remote_m.msg_type = CLI_BCKGND_ARRIVE;
......@@ -706,7 +709,6 @@ static void gen_synthetic_tr(nw_state * s, tw_bf * bf, nw_message * m, tw_lp * l
s->gen_data += payload;
num_syn_bytes_sent += payload;
}
printf("\n Number of Syn Dest: %d", i);
/* New event after MEAN_INTERVAL */
tw_stime ts = mean_interval + tw_rand_exponential(lp->rng, noise);
......@@ -1804,7 +1806,7 @@ void nw_test_init(nw_state* s, tw_lp* lp)
#endif
}
if(strcmp(file_name_of_job[lid.job], "synthetic") != 0)
if(strncmp(file_name_of_job[lid.job], "synthetic", 9) != 0)
wrkld_id = codes_workload_load("dumpi-trace-workload", params, s->app_id, s->local_rank);
double overhead;
......@@ -1837,11 +1839,12 @@ void nw_test_init(nw_state* s, tw_lp* lp)
s->app_id = lid.job;
s->local_rank = lid.rank;
if(strncmp(file_name_of_job[lid.job], "synthetic", 9) == 0)
{
sscanf(file_name_of_job[lid.job][9], "%d", &s->synthetic_pattern);
tw_event * e;
sscanf(file_name_of_job[lid.job], "synthetic%d", &s->synthetic_pattern);
tw_event * e;
nw_message * m_new;
tw_stime ts = tw_rand_exponential(lp->rng, mean_interval/1000);
e = tw_event_new(lp->gid, ts, lp);
......@@ -2578,7 +2581,7 @@ int modelnet_mpi_replay(MPI_Comm comm, int* argc, char*** argv )
{
ref = fscanf(name_file, "%d %s", &num_traces_of_job[i], file_name_of_job[i]);
if(ref != EOF && strcmp(file_name_of_job[i], "synthetic") == 0)
if(ref != EOF && strncmp(file_name_of_job[i], "synthetic", 9) == 0)
{
num_syn_clients = num_traces_of_job[i];
num_net_traces += num_traces_of_job[i];
......
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