Commit 4457f310 authored by Caitlin Ross's avatar Caitlin Ross
Browse files

adding support for ROSS analysis LP feature

parent e213f4ce
......@@ -2624,7 +2624,7 @@ int modelnet_mpi_replay(MPI_Comm comm, int* argc, char*** argv )
nw_add_lp_type();
model_net_register();
if (g_st_ev_trace || g_st_model_stats)
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
nw_lp_register_model();
net_ids = model_net_configure(&num_nets);
......
......@@ -137,8 +137,11 @@ st_model_types svr_model_types[] = {
(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, 0, NULL, 0, NULL, 0, NULL, NULL, 0}
};
static const st_model_types *svr_get_model_stat_types(void)
......@@ -424,7 +427,7 @@ int main(
model_net_register();
svr_add_lp_type();
if (g_st_ev_trace || g_st_model_stats)
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
svr_register_model_types();
codes_mapping_setup();
......
......@@ -278,6 +278,7 @@ struct terminal_state
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) */
......@@ -367,12 +368,17 @@ struct router_state
/* following used for ROSS model-level stats collection */
tw_stime* busy_time_ross_sample;
int64_t * link_traffic_ross_sample;
struct dfly_router_sample ross_rsample;
};
/* had to pull some of the ROSS model stats collection stuff up here */
void dragonfly_event_collect(terminal_message *m, tw_lp *lp, char *buffer, int *collect_flag);
void dragonfly_model_stat_collect(terminal_state *s, tw_lp *lp, char *buffer);
void dfly_router_model_stat_collect(router_state *s, tw_lp *lp, char *buffer);
static void ross_dragonfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample);
static void ross_dragonfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample);
static void ross_dragonfly_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample);
static void ross_dragonfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample);
st_model_types dragonfly_model_types[] = {
{(rbev_trace_f) dragonfly_event_collect,
......@@ -380,14 +386,20 @@ st_model_types dragonfly_model_types[] = {
(ev_trace_f) dragonfly_event_collect,
sizeof(int),
(model_stat_f) dragonfly_model_stat_collect,
sizeof(tw_lpid) + sizeof(long) * 2 + sizeof(double) + sizeof(tw_stime) *2},
sizeof(tw_lpid) + sizeof(long) * 2 + sizeof(double) + sizeof(tw_stime) *2,
(sample_event_f) ross_dragonfly_sample_fn,
(sample_revent_f) ross_dragonfly_sample_rc_fn,
sizeof(struct dfly_cn_sample) } ,
{(rbev_trace_f) dragonfly_event_collect,
sizeof(int),
(ev_trace_f) dragonfly_event_collect,
sizeof(int),
(model_stat_f) dfly_router_model_stat_collect,
0}, //updated in router_setup() since it's based on the radix
{NULL, 0, NULL, 0, NULL, 0}
0, //updated in router_setup() since it's based on the radix
(sample_event_f) ross_dragonfly_rsample_fn,
(sample_revent_f) ross_dragonfly_rsample_rc_fn,
0 } , //updated in router_setup() since it's based on the radix
{NULL, 0, NULL, 0, NULL, 0, NULL, NULL, 0}
};
/* End of ROSS model stats collection */
......@@ -872,6 +884,8 @@ static void router_setup(router_state * r, tw_lp * lp)
r->fwd_events = 0;
r->rev_events = 0;
r->ross_rsample.fwd_events = 0;
r->ross_rsample.rev_events = 0;
r->global_channel = (int*)malloc(p->num_global_channels * sizeof(int));
r->next_output_available_time = (tw_stime*)malloc(p->radix * sizeof(tw_stime));
......@@ -901,6 +915,10 @@ static void router_setup(router_state * r, tw_lp * lp)
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)
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++)
......@@ -1320,6 +1338,7 @@ static void packet_send_rc(terminal_state * s, tw_bf * bf, terminal_message * ms
s->busy_time = msg->saved_total_time;
s->last_buf_full[0] = 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;
}
}
......@@ -1444,6 +1463,7 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_message * msg,
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]);
s->busy_time_ross_sample += (tw_now(lp) - s->last_buf_full[0]);
s->last_buf_full[0] = 0.0;
}
......@@ -1467,14 +1487,17 @@ static void packet_arrive_rc(terminal_state * s, tw_bf * bf, terminal_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;
......@@ -1512,6 +1535,7 @@ static void packet_arrive_rc(terminal_state * s, tw_bf * bf, terminal_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 = rc_stack_pop(s->st);
......@@ -1635,6 +1659,7 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_message * msg
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 */
......@@ -1665,6 +1690,7 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_message * msg
/* 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);
......@@ -1677,6 +1703,7 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_message * msg
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);
......@@ -1760,6 +1787,7 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_message * msg
s->total_msg_size += msg->total_size;
s->finished_msgs++;
s->data_size_sample += msg->total_size;
s->ross_sample.data_size_sample += msg->total_size;
s->data_size_ross_sample += msg->total_size;
if(tmp->remote_event_data && tmp->remote_event_size > 0) {
......@@ -2042,6 +2070,94 @@ static void node_collective_fan_out(terminal_state * s,
}
}
static void ross_dragonfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample)
{
(void)lp;
(void)bf;
const dragonfly_param * p = s->params;
int i = 0;
sample->router_id = s->router_id;
sample->end_time = tw_now(lp);
sample->fwd_events = s->ross_rsample.fwd_events;
sample->rev_events = s->ross_rsample.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->ross_rsample.fwd_events = 0;
s->ross_rsample.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;
}
}
static void ross_dragonfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample)
{
(void)lp;
(void)bf;
const dragonfly_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->ross_rsample.fwd_events = sample->fwd_events;
s->ross_rsample.rev_events = sample->rev_events;
}
static void ross_dragonfly_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->ross_sample.fwd_events;
sample->rev_events = s->ross_sample.rev_events;
s->ross_sample.fin_chunks_sample = 0;
s->ross_sample.data_size_sample = 0;
s->ross_sample.fin_hops_sample = 0;
s->ross_sample.fwd_events = 0;
s->ross_sample.rev_events = 0;
s->ross_sample.fin_chunks_time = 0;
s->ross_sample.busy_time_sample = 0;
}
static void ross_dragonfly_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->ross_sample.fwd_events = sample->fwd_events;
s->ross_sample.rev_events = sample->rev_events;
}
static void dragonfly_rsample_init(router_state * s,
tw_lp * lp)
{
......@@ -2385,6 +2501,7 @@ terminal_event( terminal_state * s,
tw_lp * lp )
{
s->fwd_events++;
s->ross_sample.fwd_events++;
//*(int *)bf = (int)0;
assert(msg->magic == terminal_magic_num);
......@@ -2972,12 +3089,14 @@ static void router_packet_send_rc(router_state * s,
{
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;
......@@ -3102,12 +3221,15 @@ router_packet_send( router_state * s,
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;
}
......@@ -3177,6 +3299,7 @@ static void router_buf_update_rc(router_state * s,
{
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][output_chan] = msg->saved_busy_time;
}
......@@ -3210,6 +3333,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, terminal_message * m
msg->saved_busy_time_ross = s->busy_time_ross_sample[indx];
s->busy_time[indx] += (tw_now(lp) - s->last_buf_full[indx][output_chan]);
s->busy_time_sample[indx] += (tw_now(lp) - s->last_buf_full[indx][output_chan]);
s->ross_rsample.busy_time[indx] += (tw_now(lp) - s->last_buf_full[indx][output_chan]);
s->busy_time_ross_sample[indx] += (tw_now(lp) - s->last_buf_full[indx][output_chan]);
s->last_buf_full[indx][output_chan] = 0.0;
}
......@@ -3243,6 +3367,7 @@ static void router_event(router_state * s, tw_bf * bf, terminal_message * msg,
tw_lp * lp) {
s->fwd_events++;
s->ross_rsample.fwd_events++;
rc_stack_gc(lp, s->st);
assert(msg->magic == router_magic_num);
......@@ -3274,6 +3399,7 @@ static void terminal_rc_event_handler(terminal_state * s, tw_bf * bf,
terminal_message * msg, tw_lp * lp) {
s->rev_events++;
s->ross_sample.rev_events++;
switch(msg->type)
{
case T_GENERATE:
......@@ -3328,6 +3454,7 @@ static void terminal_rc_event_handler(terminal_state * s, tw_bf * bf,
static void router_rc_event_handler(router_state * s, tw_bf * bf,
terminal_message * msg, tw_lp * lp) {
s->rev_events++;
s->ross_rsample.rev_events++;
switch(msg->type) {
case R_SEND:
......
......@@ -164,6 +164,16 @@ void mn_model_stat_collect(model_net_base_state *s, tw_lp *lp, char *buffer)
return;
}
void mn_sample_event(model_net_base_state *s, tw_bf * bf, tw_lp * lp, void *sample)
{
(*s->sub_model_type->sample_event_fn)(s->sub_state, bf, lp, sample);
}
void mn_sample_rc_event(model_net_base_state *s, tw_bf * bf, tw_lp * lp, void *sample)
{
(*s->sub_model_type->sample_revent_fn)(s->sub_state, bf, lp, sample);
}
st_model_types mn_model_types[MAX_NETS];
st_model_types mn_model_base_type = {
......@@ -172,6 +182,9 @@ st_model_types mn_model_base_type = {
(ev_trace_f) mn_event_collect,
sizeof(int),
(model_stat_f) mn_model_stat_collect,
0,
(sample_event_f) mn_sample_event,
(sample_revent_f) mn_sample_rc_event,
0
};
......@@ -213,7 +226,7 @@ void model_net_base_register(int *do_config_nets){
&model_net_base_lp);
else
method_array[i]->mn_register(&model_net_base_lp);
if (g_st_ev_trace || g_st_model_stats) // for ROSS event tracing
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps) // for ROSS event tracing
{
memcpy(&mn_model_types[i], &mn_model_base_type, sizeof(st_model_types));
......@@ -465,10 +478,11 @@ void model_net_base_lp_init(
ns->sub_type = model_net_get_lp_type(ns->net_id);
/* some ROSS instrumentation setup */
if (g_st_ev_trace || g_st_model_stats)
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
{
ns->sub_model_type = model_net_get_model_stat_type(ns->net_id);
mn_model_types[ns->net_id].mstat_sz = ns->sub_model_type->mstat_sz;
mn_model_types[ns->net_id].sample_struct_sz = ns->sub_model_type->sample_struct_sz;
}
// NOTE: some models actually expect LP state to be 0 initialized...
......
......@@ -5,7 +5,7 @@ n is the number of input bgp-log files */
#include <sys/stat.h>
#include <mpi.h>
#include <assert.h>
#define RADIX 16
#define RADIX 8
struct dfly_samples
{
......
......@@ -489,7 +489,7 @@ static void codes_mapping_init(void)
else
/* sorry, const... */
tw_lp_settype(ross_lid, (tw_lptype*) lptype);
if (g_st_ev_trace || g_st_model_stats)
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
{
trace_type = st_model_type_lookup(lp_type_name);
st_model_settype(ross_lid, (st_model_types*) trace_type);
......
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