Commit b186dfb4 authored by Misbah Mubarak's avatar Misbah Mubarak

Merge branch 'analysis-lp' into 'master'

Analysis LP/Virtual Time Sampling

See merge request codes/codes!50
parents 296e38d1 6f4c0603
## README for using ROSS instrumentation with CODES
For details about the ROSS instrumentation, see the [ROSS Instrumentation blog post](http://carothersc.github.io/ROSS/feature/instrumentation.html)
For details about the ROSS instrumentation, see the [ROSS Instrumentation blog post](http://carothersc.github.io/ROSS/instrumentation/instrumentation.html)
on the ROSS webpage.
There are currently 3 types of instrumentation: GVT-based, real time, and event tracing. See the ROSS documentation for more info on
the specific options or use `--help` with your model. To collect data about the simulation engine, no changes are needed to model code
for any of the instrumentation modes. Some additions to the model code is needed in order to turn on any model-level data collection.
See the "Model-level data sampling" section on [ROSS Instrumentation blog post](http://carothersc.github.io/ROSS/feature/instrumentation.html).
There are currently 4 types of instrumentation: GVT-based, real time sampling, virtual time sampling, and event tracing.
See the ROSS documentation for more info on the specific options or use `--help` with your model.
To collect data about the simulation engine, no changes are needed to model code for any of the instrumentation modes.
Some additions to the model code is needed in order to turn on any model-level data collection.
See the "Model-level data sampling" section on [ROSS Instrumentation blog post](http://carothersc.github.io/ROSS/instrumentation/instrumentation.html).
Here we describe CODES specific details.
### Register Instrumentation Callback Functions
......@@ -17,15 +18,11 @@ The examples here are based on the dragonfly router and terminal LPs (`src/netwo
As described in the ROSS Vis documentation, we need to create a `st_model_types` struct with the pointer and size information.
```C
st_model_types dragonfly_model_types[] = {
{(rbev_trace_f) dragonfly_event_collect,
sizeof(int),
(ev_trace_f) dragonfly_event_collect,
{(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},
{(rbev_trace_f) dragonfly_event_collect,
sizeof(int),
(ev_trace_f) dragonfly_event_collect,
{(ev_trace_f) dragonfly_event_collect,
sizeof(int),
(model_stat_f) dfly_router_model_stat_collect,
0}, // updated in router_setup()
......@@ -33,20 +30,17 @@ st_model_types dragonfly_model_types[] = {
}
```
`dragonfly_model_types[0]` is the function pointers for the terminal LP and `dragonfly_model_types[1]` is for the router LP.
For the first two function pointers for each LP, we use the same `dragonfly_event_collec()` because right now we just collect the event type, so
it's the same for both of these LPs. You can change these if you want to use different functions for different LP types or if you want a different
function for the full event tracing than that used for the rollback event trace (`rbev_trace_f` is for the event tracing of rollback triggering events only,
while `ev_trace_f` is for the full event tracing).
The number following each function pointer is the size of the data that will be saved when the function is called.
The third pointer is for the data to be sampled at the GVT or real time sampling points.
For the first function pointer for each LP type, we use the same `dragonfly_event_collect()` because right now we just collect the event type, so it's the same for both of these LP types.
You can change these if you want to use different functions for different LP types.
The number following that function pointer is the size of the data that will be saved when the function is called.
The second pointer is for the data to be sampled at the GVT or real time sampling points.
In this case the LPs have different function pointers since we want to collect different types of data for the two LP types.
For the terminal, I set the appropriate size of the data to be collected, but for the router, the size of the data is dependent on the radix for the
dragonfly configuration being used, which isn't known until runtime.
For the terminal, I set the appropriate size of the data to be collected, but for the router, the size of the data is dependent on the radix for the dragonfly configuration being used, which isn't known until runtime.
*Note*: You can only reuse the function for event tracing for LPs that use the same type of message struct.
For example, the dragonfly terminal and router LPs both use the `terminal_message` struct, so they can
use the same functions for event tracing. However the model net base LP uses the `model_net_wrap_msg` struct, so it gets its own event collection function and
`st_trace_type` struct, in order to read the event type correctly from the model.
use the same functions for event tracing.
However the model net base LP uses the `model_net_wrap_msg` struct, so it gets its own event collection function and `st_trace_type` struct, in order to read the event type correctly from the model.
In the ROSS instrumentation documentation, there are two methods provided for letting ROSS know about these `st_model_types` structs.
In CODES, this step is a little different, as `codes_mapping_setup()` calls `tw_lp_settype()`.
......@@ -106,9 +100,7 @@ Using the synthetic workload LP for dragonfly as an example (`src/network-worklo
In the main function, you call the register function *before* calling `codes_mapping_setup()`.
```C
st_model_types svr_model_types[] = {
{(rbev_trace_f) svr_event_collect,
sizeof(int),
(ev_trace_f) svr_event_collect,
{(ev_trace_f) svr_event_collect,
sizeof(int),
(model_stat_f) svr_model_stat_collect,
0}, // at the moment, we're not actually collecting any data about this LP
......@@ -143,10 +135,13 @@ modes are collecting model-level data as well.
### CODES LPs that currently have event type collection implemented:
If you're using any of the following CODES models, you don't have to add anything, unless you want to change the data that's being collected.
- nw-lp (model-net-mpi-replay.c)
- original dragonfly router and terminal LPs (dragonfly.c)
- dfly server LP (model-net-synthetic.c)
- model-net-base-lp (model-net-lp.c)
- custom dfly server LP (model-net-synthetic-custom-dfly.c)
- fat tree server LP (model-net-synthetic-fattree.c)
- slimfly server LP (model-net-synthetic-slimfly.c)
- original dragonfly router and terminal LPs (dragonfly.c)
- dragonfly custom router and terminal LPs (dragonfly-custom.C)
- slimfly router and terminal LPs (slimfly.c)
- fat tree switch and terminal LPs (fat-tree.c)
- model-net-base-lp (model-net-lp.c)
The fat-tree terminal and switch LPs (fattree.c) are only partially implemented at the moment. It needs two `model_net_method` structs to fully implement,
but currently both terminal and switch LPs use the same `fattree_method` struct.
......@@ -85,6 +85,8 @@ struct terminal_custom_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
......
......@@ -2554,8 +2554,6 @@ static void nw_add_lp_type()
}
/* 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 nw_lp_event_collect(nw_message *m, tw_lp *lp, char *buffer, int *collect_flag)
{
......@@ -2580,13 +2578,14 @@ void nw_lp_model_stat_collect(nw_state *s, tw_lp *lp, char *buffer)
}
st_model_types nw_lp_model_types[] = {
{(rbev_trace_f) nw_lp_event_collect,
sizeof(int),
(ev_trace_f) nw_lp_event_collect,
{(ev_trace_f) nw_lp_event_collect,
sizeof(int),
(model_stat_f) nw_lp_model_stat_collect,
0,
NULL,
NULL,
0},
{NULL, 0, NULL, 0, NULL, 0}
{NULL, 0, NULL, 0, NULL, NULL, 0}
};
static const st_model_types *nw_lp_get_model_stat_types(void)
......@@ -2705,7 +2704,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);
......
......@@ -107,6 +107,49 @@ tw_lptype svr_lp = {
sizeof(svr_state),
};
/* setup for the ROSS event tracing
*/
void custom_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 custom_svr_model_stat_collect(svr_state *s, tw_lp *lp, char *buffer)
{
(void)s;
(void)lp;
(void)buffer;
return;
}
st_model_types custom_svr_model_types[] = {
{(ev_trace_f) custom_svr_event_collect,
sizeof(int),
(model_stat_f) custom_svr_model_stat_collect,
0,
NULL,
NULL,
0},
{NULL, 0, NULL, 0, NULL, NULL, 0}
};
static const st_model_types *custom_svr_get_model_stat_types(void)
{
return(&custom_svr_model_types[0]);
}
void custom_svr_register_model_types()
{
st_model_type_register("nw-lp", custom_svr_get_model_stat_types());
}
const tw_optdef app_opt [] =
{
TWOPT_GROUP("Model net synthetic traffic " ),
......@@ -380,6 +423,9 @@ int main(
model_net_register();
svr_add_lp_type();
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
custom_svr_register_model_types();
codes_mapping_setup();
net_ids = model_net_configure(&num_nets);
......
......@@ -123,8 +123,6 @@ tw_lptype svr_lp = {
};
/* 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 ft_svr_event_collect(svr_msg *m, tw_lp *lp, char *buffer, int *collect_flag)
{
......@@ -150,13 +148,14 @@ void ft_svr_model_stat_collect(svr_state *s, tw_lp *lp, char *buffer)
}
st_model_types ft_svr_model_types[] = {
{(rbev_trace_f) ft_svr_event_collect,
sizeof(int),
(ev_trace_f) ft_svr_event_collect,
{(ev_trace_f) ft_svr_event_collect,
sizeof(int),
(model_stat_f) ft_svr_model_stat_collect,
0,
NULL,
NULL,
0},
{NULL, 0, NULL, 0, NULL, 0}
{NULL, 0, NULL, 0, NULL, NULL, 0}
};
static const st_model_types *ft_svr_get_model_stat_types(void)
......@@ -456,7 +455,7 @@ int main(
svr_add_lp_type();
if (g_st_ev_trace)
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
ft_svr_register_model_stats();
codes_mapping_setup();
......
......@@ -120,6 +120,49 @@ tw_lptype svr_lp = {
sizeof(svr_state),
};
/* setup for the ROSS event tracing
*/
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[] = {
{(ev_trace_f) svr_event_collect,
sizeof(int),
(model_stat_f) svr_model_stat_collect,
0,
NULL,
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 +508,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);
......
......@@ -108,8 +108,6 @@ tw_lptype svr_lp = {
};
/* 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)
{
......@@ -132,13 +130,14 @@ void svr_model_stat_collect(svr_state *s, tw_lp *lp, char *buffer)
}
st_model_types svr_model_types[] = {
{(rbev_trace_f) svr_event_collect,
sizeof(int),
(ev_trace_f) svr_event_collect,
{(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, NULL, 0}
};
static const st_model_types *svr_get_model_stat_types(void)
......@@ -424,7 +423,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();
......
......@@ -284,6 +284,14 @@ struct terminal_state
/* for logging forward and reverse events */
long fwd_events;
long rev_events;
/* following used for ROSS model-level stats collection */
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) */
......@@ -365,7 +373,40 @@ struct router_state
long fwd_events;
long rev_events;
/* 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 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);
static void ross_custom_dragonfly_rsample_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample);
static void ross_custom_dragonfly_rsample_rc_fn(router_state * s, tw_bf * bf, tw_lp * lp, struct dfly_router_sample *sample);
static void ross_custom_dragonfly_sample_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample);
static void ross_custom_dragonfly_sample_rc_fn(terminal_state * s, tw_bf * bf, tw_lp * lp, struct dfly_cn_sample *sample);
st_model_types custom_dragonfly_model_types[] = {
{(ev_trace_f) custom_dragonfly_event_collect,
sizeof(int),
(model_stat_f) custom_dragonfly_model_stat_collect,
sizeof(tw_lpid) + sizeof(long) * 2 + sizeof(double) + sizeof(tw_stime) *2,
(sample_event_f) ross_custom_dragonfly_sample_fn,
(sample_revent_f) ross_custom_dragonfly_sample_rc_fn,
sizeof(struct dfly_cn_sample) } ,
{(ev_trace_f) custom_dragonfly_event_collect,
sizeof(int),
(model_stat_f) custom_dfly_router_model_stat_collect,
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_custom_setup() since it's based on the radix
{NULL, 0, NULL, 0, NULL, NULL, 0}
};
/* End of ROSS model stats collection */
static short routing = MINIMAL;
......@@ -987,6 +1028,8 @@ void router_custom_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));
......@@ -1013,6 +1056,16 @@ void router_custom_setup(router_state * r, tw_lp * lp)
r->busy_time = (tw_stime*)malloc(p->radix * sizeof(tw_stime));
r->busy_time_sample = (tw_stime*)malloc(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->num_router_rows; i++)
......@@ -1362,6 +1415,8 @@ static void packet_send_rc(terminal_state * s, tw_bf * bf, terminal_custom_messa
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;
}
}
return;
......@@ -1489,6 +1544,8 @@ 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]);
s->busy_time_ross_sample += (tw_now(lp) - s->last_buf_full[0]);
s->last_buf_full[0] = 0.0;
}
}
......@@ -1511,12 +1568,18 @@ static void packet_arrive_rc(terminal_state * s, tw_bf * bf, terminal_custom_mes
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;
......@@ -1559,6 +1622,8 @@ static void packet_arrive_rc(terminal_state * s, tw_bf * bf, terminal_custom_mes
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));
......@@ -1680,6 +1745,8 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_custom_messag
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);
......@@ -1706,6 +1773,9 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_custom_messag
/* 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;
......@@ -1716,6 +1786,8 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_custom_messag
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;
......@@ -1803,6 +1875,8 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_custom_messag
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;
......@@ -1821,6 +1895,94 @@ static void packet_arrive(terminal_state * s, tw_bf * bf, terminal_custom_messag
return;
}
static void ross_custom_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_custom_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_custom_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_custom_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;
}
void dragonfly_custom_rsample_init(router_state * s,
tw_lp * lp)
{
......@@ -2131,6 +2293,7 @@ terminal_custom_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);
......@@ -3102,11 +3265,15 @@ 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;
......@@ -3226,10 +3393,16 @@ 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;
}
if(cur_entry->msg.packet_ID == LLU(TRACK_PKT) && cur_entry->msg.src_terminal_id == T_ID)
......@@ -3291,6 +3464,8 @@ 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;
}
if(bf->c1) {
......@@ -3320,8 +3495,11 @@ static void router_buf_update(router_state * s, tw_bf * bf, terminal_custom_mess
msg->saved_rcv_time = s->busy_time[indx];
msg->saved_busy_time = s->last_buf_full[indx][output_chan];
msg->saved_sample_time = s->busy_time_sample[indx];
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;
}
if(s->queued_msgs[indx][output_chan] != NULL) {
......@@ -3352,6 +3530,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, terminal_custom_mess
void router_custom_event(router_state * s, tw_bf * bf, terminal_custom_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);
......@@ -3383,6 +3562,7 @@ void terminal_custom_rc_event_handler(terminal_state * s, tw_bf * bf,
terminal_custom_message * msg, tw_lp * lp) {
s->rev_events++;
s->ross_sample.rev_events++;
switch(msg->type)
{
case T_GENERATE:
......@@ -3410,6 +3590,7 @@ void terminal_custom_rc_event_handler(terminal_state * s, tw_bf * bf,
void router_custom_rc_event_handler(router_state * s, tw_bf * bf,
terminal_custom_message * msg, tw_lp * lp) {
s->rev_events++;
s->ross_rsample.rev_events++;
switch(msg->type) {
case R_SEND:
......@@ -3454,6 +3635,108 @@ tw_lptype dragonfly_custom_lps[] =
};
}
/* For ROSS event tracing */
void custom_dragonfly_event_collect(terminal_custom_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));
}
void custom_dragonfly_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;