Commit ea65139b authored by Caitlin Ross's avatar Caitlin Ross
Browse files

adding in all the necessary callback and registration functions for using ROSS...

adding in all the necessary callback and registration functions for using ROSS instrumentation with DFP
parent d1e36f84
......@@ -92,6 +92,8 @@ struct terminal_plus_message
tw_stime saved_total_time;
tw_stime saved_sample_time;
tw_stime msg_start_time;
tw_stime saved_busy_time_ross;
tw_stime saved_fin_chunks_ross;
};
#ifdef __cplusplus
......
......@@ -380,7 +380,7 @@ struct router_state
struct dfly_router_sample ross_rsample;
};
/* had to pull some of the ROSS model stats collection stuff up here */
/* ROSS model instrumentation */
void custom_dragonfly_event_collect(terminal_custom_message *m, tw_lp *lp, char *buffer, int *collect_flag);
void custom_dragonfly_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer);
void custom_dfly_router_model_stat_collect(router_state *s, tw_lp *lp, char *buffer);
......@@ -1545,6 +1545,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_custom_message
s->busy_time += (tw_now(lp) - s->last_buf_full[0]);
s->busy_time_sample += (tw_now(lp) - s->last_buf_full[0]);
s->ross_sample.busy_time_sample += (tw_now(lp) - s->last_buf_full[0]);
msg->saved_busy_time_ross = s->busy_time_ross_sample;
s->busy_time_ross_sample += (tw_now(lp) - s->last_buf_full[0]);
s->last_buf_full[0] = 0.0;
}
......@@ -3635,7 +3636,8 @@ tw_lptype dragonfly_custom_lps[] =
};
}
/* For ROSS event tracing */
/* ROSS Instrumentation layer */
// event tracing callback - used router and terminal LPs
void custom_dragonfly_event_collect(terminal_custom_message *m, tw_lp *lp, char *buffer, int *collect_flag)
{
(void)lp;
......@@ -3645,6 +3647,7 @@ void custom_dragonfly_event_collect(terminal_custom_message *m, tw_lp *lp, char
memcpy(buffer, &type, sizeof(type));
}
// GVT-based and real time sampling callback for terminals
void custom_dragonfly_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer)
{
(void)lp;
......@@ -3686,6 +3689,7 @@ void custom_dragonfly_model_stat_collect(terminal_state *s, tw_lp *lp, char *buf
return;
}
// GVT-based and real time sampling callback for routers
void custom_dfly_router_model_stat_collect(router_state *s, tw_lp *lp, char *buffer)
{
(void)lp;
......@@ -3735,7 +3739,7 @@ static void custom_router_register_model_types(st_model_types *base_type)
{
st_model_type_register(LP_CONFIG_NM_ROUT, base_type);
}
/*** END of ROSS event tracing additions */
/*** END of ROSS Instrumentation support */
/* returns the dragonfly lp type for lp registration */
static const tw_lptype* dragonfly_custom_get_cn_lp_type(void)
......
......@@ -338,6 +338,14 @@ struct terminal_state
/* for logging forward and reverse events */
long fwd_events;
long rev_events;
// for ROSS Instrumentation
long fin_chunks_ross_sample;
long data_size_ross_sample;
long fin_hops_ross_sample;
tw_stime fin_chunks_time_ross_sample;
tw_stime busy_time_ross_sample;
struct dfly_cn_sample ross_sample;
};
/* terminal event type (1-4) */
......@@ -479,8 +487,41 @@ struct router_state
long fwd_events;
long rev_events;
// for ROSS instrumentation
tw_stime* busy_time_ross_sample;
int64_t * link_traffic_ross_sample;
struct dfly_router_sample ross_rsample;
};
/* ROSS model instrumentation */
void dfly_plus_event_collect(terminal_plus_message *m, tw_lp *lp, char *buffer, int *collect_flag);
void dfly_plus_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer);
void dfly_plus_router_model_stat_collect(router_state *s, tw_lp *lp, char *buffer);
static void ross_dfly_plus_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample);
static void ross_dfly_plus_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample);
static void ross_dfly_plus_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample);
static void ross_dfly_plus_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample);
st_model_types dfly_plus_model_types[] = {
{(ev_trace_f) dfly_plus_event_collect,
sizeof(int),
(model_stat_f) dfly_plus_model_stat_collect,
sizeof(tw_lpid) + sizeof(long) * 2 + sizeof(double) + sizeof(tw_stime) *2,
(sample_event_f) ross_dfly_plus_sample_fn,
(sample_revent_f) ross_dfly_plus_sample_rc_fn,
sizeof(struct dfly_cn_sample) } ,
{(ev_trace_f) dfly_plus_event_collect,
sizeof(int),
(model_stat_f) dfly_plus_router_model_stat_collect,
0, //updated in router_plus_setup() since it's based on the radix
(sample_event_f) ross_dfly_plus_rsample_fn,
(sample_revent_f) ross_dfly_plus_rsample_rc_fn,
0 } , //updated in router_plus_setup() since it's based on the radix
{NULL, 0, NULL, 0, NULL, NULL, 0}
};
/* End of ROSS model instrumentation */
int dragonfly_plus_get_assigned_router_id(int terminal_id, const dragonfly_plus_param *p);
static short routing = MINIMAL;
......@@ -1258,6 +1299,16 @@ void router_plus_setup(router_state *r, tw_lp *lp)
r->busy_time = (tw_stime *) calloc(p->radix, sizeof(tw_stime));
r->busy_time_sample = (tw_stime *) calloc(p->radix, sizeof(tw_stime));
/* set up for ROSS stats sampling */
r->link_traffic_ross_sample = (int64_t*)calloc(p->radix, sizeof(int64_t));
r->busy_time_ross_sample = (tw_stime*)calloc(p->radix, sizeof(tw_stime));
if (g_st_model_stats)
lp->model_types->mstat_sz = sizeof(tw_lpid) + (sizeof(int64_t) + sizeof(tw_stime)) * p->radix;
if (g_st_use_analysis_lps && g_st_model_stats)
lp->model_types->sample_struct_sz = sizeof(struct dfly_router_sample) + (sizeof(tw_stime) + sizeof(int64_t)) * p->radix;
r->ross_rsample.busy_time = (tw_stime*)calloc(p->radix, sizeof(tw_stime));
r->ross_rsample.link_traffic_sample = (int64_t*)calloc(p->radix, sizeof(int64_t));
rc_stack_create(&r->st);
for (int i = 0; i < p->radix; i++) {
......@@ -1591,6 +1642,8 @@ static void packet_send_rc(terminal_state *s, tw_bf *bf, terminal_plus_message *
s->busy_time = msg->saved_total_time;
s->last_buf_full = msg->saved_busy_time;
s->busy_time_sample = msg->saved_sample_time;
s->ross_sample.busy_time_sample = msg->saved_sample_time;
s->busy_time_ross_sample = msg->saved_busy_time_ross;
}
}
return;
......@@ -1709,6 +1762,9 @@ static void packet_send(terminal_state *s, tw_bf *bf, terminal_plus_message *msg
s->busy_time += (tw_now(lp) - s->last_buf_full);
s->busy_time_sample += (tw_now(lp) - s->last_buf_full);
s->ross_sample.busy_time_sample += (tw_now(lp) - s->last_buf_full);
msg->saved_busy_time_ross = s->busy_time_ross_sample;
s->busy_time_ross_sample += (tw_now(lp) - s->last_buf_full);
s->last_buf_full = 0.0;
}
}
......@@ -1732,12 +1788,18 @@ static void packet_arrive_rc(terminal_state *s, tw_bf *bf, terminal_plus_message
N_finished_chunks--;
s->finished_chunks--;
s->fin_chunks_sample--;
s->ross_sample.fin_chunks_sample--;
s->fin_chunks_ross_sample--;
total_hops -= msg->my_N_hop;
s->total_hops -= msg->my_N_hop;
s->fin_hops_sample -= msg->my_N_hop;
s->ross_sample.fin_hops_sample -= msg->my_N_hop;
s->fin_hops_ross_sample -= msg->my_N_hop;
dragonfly_total_time = msg->saved_total_time;
s->fin_chunks_time = msg->saved_sample_time;
s->ross_sample.fin_chunks_time = msg->saved_sample_time;
s->fin_chunks_time_ross_sample = msg->saved_fin_chunks_ross;
s->total_time = msg->saved_avg_time;
struct qhash_head *hash_link = NULL;
......@@ -1776,6 +1838,8 @@ static void packet_arrive_rc(terminal_state *s, tw_bf *bf, terminal_plus_message
total_msg_sz -= msg->total_size;
s->total_msg_size -= msg->total_size;
s->data_size_sample -= msg->total_size;
s->ross_sample.data_size_sample -= msg->total_size;
s->data_size_ross_sample -= msg->total_size;
struct dfly_qhash_entry *d_entry_pop = (dfly_qhash_entry *) rc_stack_pop(s->st);
qhash_add(s->rank_tbl, &key, &(d_entry_pop->hash_link));
......@@ -1898,6 +1962,8 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m
s->finished_chunks++;
/* Finished chunks per sample */
s->fin_chunks_sample++;
s->ross_sample.fin_chunks_sample++;
s->fin_chunks_ross_sample++;
/* WE do not allow self messages through dragonfly */
assert(lp->gid != msg->src_terminal_id);
......@@ -1927,6 +1993,9 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m
/* save the sample time */
msg->saved_sample_time = s->fin_chunks_time;
s->fin_chunks_time += (tw_now(lp) - msg->travel_start_time);
s->ross_sample.fin_chunks_time += (tw_now(lp) - msg->travel_start_time);
msg->saved_fin_chunks_ross = s->fin_chunks_time_ross_sample;
s->fin_chunks_time_ross_sample += (tw_now(lp) - msg->travel_start_time);
/* save the total time per LP */
msg->saved_avg_time = s->total_time;
......@@ -1937,6 +2006,8 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m
total_hops += msg->my_N_hop;
s->total_hops += msg->my_N_hop;
s->fin_hops_sample += msg->my_N_hop;
s->ross_sample.fin_hops_sample += msg->my_N_hop;
s->fin_hops_ross_sample += msg->my_N_hop;
mn_stats *stat = model_net_find_stats(msg->category, s->dragonfly_stats_array);
msg->saved_rcv_time = stat->recv_time;
......@@ -2015,6 +2086,8 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m
bf->c7 = 1;
s->data_size_sample += msg->total_size;
s->ross_sample.data_size_sample += msg->total_size;
s->data_size_ross_sample += msg->total_size;
N_finished_msgs++;
total_msg_sz += msg->total_size;
s->total_msg_size += msg->total_size;
......@@ -3386,6 +3459,8 @@ static void router_packet_send_rc(router_state *s, tw_bf *bf, terminal_plus_mess
{
s->busy_time[output_port] = msg->saved_rcv_time;
s->busy_time_sample[output_port] = msg->saved_sample_time;
s->ross_rsample.busy_time[output_port] = msg->saved_sample_time;
s->busy_time_ross_sample[output_port] = msg->saved_busy_time_ross;
s->last_buf_full[output_port] = msg->saved_busy_time;
}
......@@ -3397,10 +3472,14 @@ static void router_packet_send_rc(router_state *s, tw_bf *bf, terminal_plus_mess
if (bf->c11) {
s->link_traffic[output_port] -= cur_entry->msg.packet_size % s->params->chunk_size;
s->link_traffic_sample[output_port] -= cur_entry->msg.packet_size % s->params->chunk_size;
s->ross_rsample.link_traffic_sample[output_port] -= cur_entry->msg.packet_size % s->params->chunk_size;
s->link_traffic_ross_sample[output_port] -= cur_entry->msg.packet_size % s->params->chunk_size;
}
if (bf->c12) {
s->link_traffic[output_port] -= s->params->chunk_size;
s->link_traffic_sample[output_port] -= s->params->chunk_size;
s->ross_rsample.link_traffic_sample[output_port] -= s->params->chunk_size;
s->link_traffic_ross_sample[output_port] -= s->params->chunk_size;
}
s->next_output_available_time[output_port] = msg->saved_available_time;
......@@ -3461,6 +3540,9 @@ static void router_packet_send(router_state *s, tw_bf *bf, terminal_plus_message
msg->saved_sample_time = s->busy_time_sample[output_port];
s->busy_time[output_port] += (tw_now(lp) - s->last_buf_full[output_port]);
s->busy_time_sample[output_port] += (tw_now(lp) - s->last_buf_full[output_port]);
s->ross_rsample.busy_time[output_port] += (tw_now(lp) - s->last_buf_full[output_port]);
msg->saved_busy_time_ross = s->busy_time_ross_sample[output_port];
s->busy_time_ross_sample[output_port] += (tw_now(lp) - s->last_buf_full[output_port]);
s->last_buf_full[output_port] = 0.0;
}
......@@ -3529,11 +3611,15 @@ static void router_packet_send(router_state *s, tw_bf *bf, terminal_plus_message
bf->c11 = 1;
s->link_traffic[output_port] += (cur_entry->msg.packet_size % s->params->chunk_size);
s->link_traffic_sample[output_port] += (cur_entry->msg.packet_size % s->params->chunk_size);
s->ross_rsample.link_traffic_sample[output_port] += (cur_entry->msg.packet_size % s->params->chunk_size);
s->link_traffic_ross_sample[output_port] += (cur_entry->msg.packet_size % s->params->chunk_size);
}
else {
bf->c12 = 1;
s->link_traffic[output_port] += s->params->chunk_size;
s->link_traffic_sample[output_port] += s->params->chunk_size;
s->ross_rsample.link_traffic_sample[output_port] += s->params->chunk_size;
s->link_traffic_ross_sample[output_port] += s->params->chunk_size;
}
/* Determine the event type. If the packet has arrived at the final
......@@ -3588,6 +3674,8 @@ static void router_buf_update_rc(router_state *s, tw_bf *bf, terminal_plus_messa
if (bf->c3) {
s->busy_time[indx] = msg->saved_rcv_time;
s->busy_time_sample[indx] = msg->saved_sample_time;
s->ross_rsample.busy_time[indx] = msg->saved_sample_time;
s->busy_time_ross_sample[indx] = msg->saved_busy_time_ross;
s->last_buf_full[indx] = msg->saved_busy_time;
}
if (bf->c1) {
......@@ -3618,6 +3706,9 @@ static void router_buf_update(router_state *s, tw_bf *bf, terminal_plus_message
msg->saved_sample_time = s->busy_time_sample[indx];
s->busy_time[indx] += (tw_now(lp) - s->last_buf_full[indx]);
s->busy_time_sample[indx] += (tw_now(lp) - s->last_buf_full[indx]);
s->ross_rsample.busy_time[indx] += (tw_now(lp) - s->last_buf_full[indx]);
msg->saved_busy_time_ross = s->busy_time_ross_sample[indx];
s->busy_time_ross_sample[indx] += (tw_now(lp) - s->last_buf_full[indx]);
s->last_buf_full[indx] = 0.0;
}
if (s->queued_msgs[indx][output_chan] != NULL) {
......@@ -3766,6 +3857,203 @@ static void router_plus_register(tw_lptype *base_type)
lp_type_register(LP_CONFIG_NM_ROUT, base_type);
}
/* ROSS Instrumentation layer */
// virtual time sampling callback - router forward
static void ross_dfly_plus_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample)
{
(void)lp;
(void)bf;
const dragonfly_plus_param * p = s->params;
int i = 0;
sample->router_id = s->router_id;
sample->end_time = tw_now(lp);
sample->fwd_events = s->fwd_events;
sample->rev_events = s->rev_events;
sample->busy_time = (tw_stime*)((&sample->rev_events) + 1);
sample->link_traffic_sample = (int64_t*)((&sample->busy_time[0]) + p->radix);
for(; i < p->radix; i++)
{
sample->busy_time[i] = s->ross_rsample.busy_time[i];
sample->link_traffic_sample[i] = s->ross_rsample.link_traffic_sample[i];
}
/* clear up the current router stats */
s->fwd_events = 0;
s->rev_events = 0;
for( i = 0; i < p->radix; i++)
{
s->ross_rsample.busy_time[i] = 0;
s->ross_rsample.link_traffic_sample[i] = 0;
}
}
// virtual time sampling callback - router reverse
static void ross_dfly_plus_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample)
{
(void)lp;
(void)bf;
const dragonfly_plus_param * p = s->params;
int i =0;
for(; i < p->radix; i++)
{
s->ross_rsample.busy_time[i] = sample->busy_time[i];
s->ross_rsample.link_traffic_sample[i] = sample->link_traffic_sample[i];
}
s->fwd_events = sample->fwd_events;
s->rev_events = sample->rev_events;
}
// virtual time sampling callback - terminal forward
static void ross_dfly_plus_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample)
{
(void)lp;
(void)bf;
sample->terminal_id = s->terminal_id;
sample->fin_chunks_sample = s->ross_sample.fin_chunks_sample;
sample->data_size_sample = s->ross_sample.data_size_sample;
sample->fin_hops_sample = s->ross_sample.fin_hops_sample;
sample->fin_chunks_time = s->ross_sample.fin_chunks_time;
sample->busy_time_sample = s->ross_sample.busy_time_sample;
sample->end_time = tw_now(lp);
sample->fwd_events = s->fwd_events;
sample->rev_events = s->rev_events;
s->ross_sample.fin_chunks_sample = 0;
s->ross_sample.data_size_sample = 0;
s->ross_sample.fin_hops_sample = 0;
s->fwd_events = 0;
s->rev_events = 0;
s->ross_sample.fin_chunks_time = 0;
s->ross_sample.busy_time_sample = 0;
}
// virtual time sampling callback - terminal reverse
static void ross_dfly_plus_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample)
{
(void)lp;
(void)bf;
s->ross_sample.busy_time_sample = sample->busy_time_sample;
s->ross_sample.fin_chunks_time = sample->fin_chunks_time;
s->ross_sample.fin_hops_sample = sample->fin_hops_sample;
s->ross_sample.data_size_sample = sample->data_size_sample;
s->ross_sample.fin_chunks_sample = sample->fin_chunks_sample;
s->fwd_events = sample->fwd_events;
s->rev_events = sample->rev_events;
}
// event tracing callback - used router and terminal LPs
void dfly_plus_event_collect(terminal_plus_message *m, tw_lp *lp, char *buffer, int *collect_flag)
{
(void)lp;
(void)collect_flag;
int type = (int) m->type;
memcpy(buffer, &type, sizeof(type));
}
// GVT-based and real time sampling callback for terminals
void dfly_plus_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer)
{
(void)lp;
int index = 0;
tw_lpid id = 0;
long tmp = 0;
tw_stime tmp2 = 0;
id = s->terminal_id;
memcpy(&buffer[index], &id, sizeof(id));
index += sizeof(id);
tmp = s->fin_chunks_ross_sample;
memcpy(&buffer[index], &tmp, sizeof(tmp));
index += sizeof(tmp);
s->fin_chunks_ross_sample = 0;
tmp = s->data_size_ross_sample;
memcpy(&buffer[index], &tmp, sizeof(tmp));
index += sizeof(tmp);
s->data_size_ross_sample = 0;
tmp = s->fin_hops_ross_sample;
memcpy(&buffer[index], &tmp, sizeof(tmp));
index += sizeof(tmp);
s->fin_hops_ross_sample = 0;
tmp2 = s->fin_chunks_time_ross_sample;
memcpy(&buffer[index], &tmp2, sizeof(tmp2));
index += sizeof(tmp2);
s->fin_chunks_time_ross_sample = 0;
tmp2 = s->busy_time_ross_sample;
memcpy(&buffer[index], &tmp2, sizeof(tmp2));
index += sizeof(tmp2);
s->busy_time_ross_sample = 0;
return;
}
// GVT-based and real time sampling callback for routers
void dfly_plus_router_model_stat_collect(router_state *s, tw_lp *lp, char *buffer)
{
(void)lp;
const dragonfly_plus_param * p = s->params;
int i, index = 0;
tw_lpid id = 0;
tw_stime tmp = 0;
int64_t tmp2 = 0;
id = s->router_id;
memcpy(&buffer[index], &id, sizeof(id));
index += sizeof(id);
for(i = 0; i < p->radix; i++)
{
tmp = s->busy_time_ross_sample[i];
memcpy(&buffer[index], &tmp, sizeof(tmp));
index += sizeof(tmp);
s->busy_time_ross_sample[i] = 0;
tmp2 = s->link_traffic_ross_sample[i];
memcpy(&buffer[index], &tmp2, sizeof(tmp2));
index += sizeof(tmp2);
s->link_traffic_ross_sample[i] = 0;
}
return;
}
static const st_model_types *dfly_plus_get_model_types(void)
{
return(&dfly_plus_model_types[0]);
}
static const st_model_types *dfly_plus_router_get_model_types(void)
{
return(&dfly_plus_model_types[1]);
}
static void dfly_plus_register_model_types(st_model_types *base_type)
{
st_model_type_register(LP_CONFIG_NM_TERM, base_type);
}
static void dfly_plus_router_register_model_types(st_model_types *base_type)
{
st_model_type_register(LP_CONFIG_NM_ROUT, base_type);
}
/*** END of ROSS Instrumentation support */
extern "C" {
/* data structure for dragonfly statistics */
struct model_net_method dragonfly_plus_method = {
......@@ -3781,10 +4069,12 @@ struct model_net_method dragonfly_plus_method = {
dragonfly_plus_report_stats,
NULL,
NULL,
NULL, //(event_f)dragonfly_plus_sample_fn,
NULL, //(revent_f)dragonfly_plus_sample_rc_fn,
NULL, //(event_f)dragonfly_plus_sample_fn,
NULL, //(revent_f)dragonfly_plus_sample_rc_fn,
(init_f) dragonfly_plus_sample_init,
NULL, //(final_f)dragonfly_plus_sample_fin
NULL, //(final_f)dragonfly_plus_sample_fin,
dfly_plus_register_model_types,
dfly_plus_get_model_types,
};
struct model_net_method dragonfly_plus_router_method = {
......@@ -3800,10 +4090,12 @@ struct model_net_method dragonfly_plus_router_method = {
NULL, // not yet supported
NULL,
NULL,
NULL, //(event_f)dragonfly_plus_rsample_fn,
NULL, //(revent_f)dragonfly_plus_rsample_rc_fn,
NULL, //(event_f)dragonfly_plus_rsample_fn,
NULL, //(revent_f)dragonfly_plus_rsample_rc_fn,
(init_f) dragonfly_plus_rsample_init,
NULL, //(final_f)dragonfly_plus_rsample_fin
NULL, //(final_f)dragonfly_plus_rsample_fin,
dfly_plus_router_register_model_types,
dfly_plus_router_get_model_types,
};
// #ifdef ENABLE_CORTEX
......
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