Commit ea6155f3 authored by Caitlin Ross's avatar Caitlin Ross

fixed bugs in slimfly virtual time sampling

parent 9950b0f8
......@@ -120,6 +120,53 @@ tw_lptype svr_lp = {
sizeof(svr_state),
};
/* setup for the ROSS event tracing
* can have a different function for rbev_trace_f and ev_trace_f
* but right now it is set to the same function for both
*/
void svr_event_collect(svr_msg *m, tw_lp *lp, char *buffer, int *collect_flag)
{
(void)lp;
(void)collect_flag;
int type = (int) m->svr_event_type;
memcpy(buffer, &type, sizeof(type));
}
/* can add in any model level data to be collected along with simulation engine data
* in the ROSS instrumentation. Will need to update the last field in
* svr_model_types[0] for the size of the data to save in each function call
*/
void svr_model_stat_collect(svr_state *s, tw_lp *lp, char *buffer)
{
(void)s;
(void)lp;
(void)buffer;
return;
}
st_model_types svr_model_types[] = {
{(rbev_trace_f) svr_event_collect,
sizeof(int),
(ev_trace_f) svr_event_collect,
sizeof(int),
(model_stat_f) svr_model_stat_collect,
0,
NULL,
NULL,
0},
{NULL, 0, NULL, 0, NULL, 0, NULL, NULL, 0}
};
static const st_model_types *svr_get_model_stat_types(void)
{
return(&svr_model_types[0]);
}
void svr_register_model_types()
{
st_model_type_register("server", svr_get_model_stat_types());
}
const tw_optdef app_opt [] =
{
TWOPT_GROUP("Model net synthetic traffic " ),
......@@ -465,6 +512,10 @@ int main(
configuration_load(argv[2], MPI_COMM_WORLD, &config);
model_net_register();
svr_add_lp_type();
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
svr_register_model_types();
codes_mapping_setup();
net_ids = model_net_configure(&num_nets);
// assert(num_nets==1);
......
......@@ -396,10 +396,10 @@ st_model_types custom_dragonfly_model_types[] = {
(ev_trace_f) custom_dragonfly_event_collect,
sizeof(int),
(model_stat_f) custom_dfly_router_model_stat_collect,
0, //updated in router_setup() since it's based on the radix
0, //updated in router_custom_setup() since it's based on the radix
(sample_event_f) ross_custom_dragonfly_rsample_fn,
(sample_revent_f) ross_custom_dragonfly_rsample_rc_fn,
0 } , //updated in router_setup() since it's based on the radix
0 } , //updated in router_custom_setup() since it's based on the radix
{NULL, 0, NULL, 0, NULL, 0, NULL, NULL, 0}
};
/* End of ROSS model stats collection */
......
......@@ -285,17 +285,26 @@ struct router_state
};
/* ROSS Instrumentation Support */
struct slimfly_sample
struct slimfly_cn_sample
{
tw_lpid lpid;
tw_lpid terminal_id;
tw_stime end_time;
int vc_occupancy; // will sum occupancy for all vc
};
struct slimfly_router_sample
{
tw_lpid router_id;
int* vc_occupancy; // sum for all vc for each port
tw_stime end_time;
};
void slimfly_event_collect(slim_terminal_message *m, tw_lp *lp, char *buffer, int *collect_flag);
void slimfly_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer);
static void ross_slimfly_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample);
static void ross_slimfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample);
static void ross_slimfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample);
static void ross_slimfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample);
static void ross_slimfly_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_cn_sample *sample);
static void ross_slimfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_cn_sample *sample);
static void ross_slimfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_router_sample *sample);
static void ross_slimfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_router_sample *sample);
st_model_types slimfly_model_types[] = {
{(rbev_trace_f) slimfly_event_collect,
......@@ -306,7 +315,7 @@ st_model_types slimfly_model_types[] = {
0, // update this when changing slimfly_model_stat_collect
(sample_event_f) ross_slimfly_sample_fn,
(sample_revent_f) ross_slimfly_sample_rc_fn,
sizeof(struct slimfly_sample) } ,
sizeof(struct slimfly_cn_sample) } ,
{(rbev_trace_f) slimfly_event_collect,
sizeof(int),
(ev_trace_f) slimfly_event_collect,
......@@ -315,7 +324,7 @@ st_model_types slimfly_model_types[] = {
0, // update this when changing slimfly_model_stat_collect
(sample_event_f) ross_slimfly_rsample_fn,
(sample_revent_f) ross_slimfly_rsample_rc_fn,
sizeof(struct slimfly_sample) } ,
0 } , //updated in slim_router_setup() since it's based on the radix
{NULL, 0, NULL, 0, NULL, 0, NULL, NULL, 0}
};
/* End of ROSS model stats collection */
......@@ -896,6 +905,10 @@ void slim_router_setup(router_state * r, tw_lp * lp)
r->last_buf_full = (tw_stime**)malloc(p->radix * sizeof(tw_stime*));
r->busy_time = (tw_stime*)malloc(p->radix * sizeof(tw_stime));
// ROSS Instrumentation
if (g_st_use_analysis_lps)
lp->model_types->sample_struct_sz = sizeof(struct slimfly_router_sample) + sizeof(int) * p->radix;
rc_stack_create(&r->st);
for(int i=0; i < p->radix; i++)
......@@ -3428,17 +3441,23 @@ void slimfly_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer)
return;
}
static void ross_slimfly_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample)
static void ross_slimfly_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_cn_sample *sample)
{
(void)lp;
(void)bf;
(void)s;
(void)sample;
sample->terminal_id = s->terminal_id;
sample->end_time = tw_now(lp);
sample->vc_occupancy = 0;
// sum vc_occupancy
int i;
for (i = 0; i < s->num_vcs; i++)
sample->vc_occupancy += s->vc_occupancy[i];
return;
}
static void ross_slimfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample)
static void ross_slimfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_cn_sample *sample)
{
(void)lp;
(void)bf;
......@@ -3448,17 +3467,30 @@ static void ross_slimfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp
return;
}
static void ross_slimfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample)
static void ross_slimfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_router_sample *sample)
{
(void)lp;
(void)bf;
(void)s;
(void)sample;
const slimfly_param * p = s->params;
int i, j, total;
sample->router_id = s->router_id;
sample->end_time = tw_now(lp);
sample->vc_occupancy = (int*)((&sample->end_time) + 1);
// sum vc occupancy for each port
for(i = 0; i < p->radix; i++)
{
total = 0;
for (j = 0; j < p->num_vcs; j++)
total += s->vc_occupancy[i][j];
sample->vc_occupancy[i] = total;
}
return;
}
static void ross_slimfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_sample *sample)
static void ross_slimfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct slimfly_router_sample *sample)
{
(void)lp;
(void)bf;
......@@ -3468,7 +3500,7 @@ static void ross_slimfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp,
return;
}
static const st_model_types *slimfly_get_model_types(void)
static const st_model_types *slimfly_get_cn_model_types()
{
return(&slimfly_model_types[0]);
}
......@@ -3476,7 +3508,7 @@ static const st_model_types *slimfly_get_model_types(void)
static void slimfly_register_model_types(st_model_types *base_type)
{
st_model_type_register(LP_CONFIG_NM, base_type);
st_model_type_register("slimfly_router", base_type);
st_model_type_register("slimfly_router", &slimfly_model_types[1]);
}
/*** END of ROSS event tracing additions */
......@@ -3493,5 +3525,5 @@ struct model_net_method slimfly_method =
.mn_get_msg_sz = slimfly_get_msg_sz,
.mn_report_stats = slimfly_report_stats,
.mn_model_stat_register = slimfly_register_model_types,
.mn_get_model_stat_types = slimfly_get_model_types
.mn_get_model_stat_types = slimfly_get_cn_model_types
};
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