Commit defaa102 authored by Misbah Mubarak's avatar Misbah Mubarak

Updates to modelnet torus plugin: reporting torus average+maximum latency and...

Updates to modelnet torus plugin: reporting torus average+maximum latency and hops traversed via model-net API function
parent ee56819b
......@@ -27,6 +27,7 @@ struct model_net_method
void (*model_net_method_packet_event_rc)(tw_lp *sender);
const tw_lptype* (*mn_get_lp_type)();
int (*mn_get_msg_sz)();
void (*mn_report_stats)();
};
#endif /* MODELNET_METHOD_H */
......
......@@ -128,6 +128,8 @@ const tw_lptype* model_net_get_lp_type(int net_id);
const int model_net_get_packet_size(int net_id);
void model_net_add_lp_type(int net_id);
void model_net_report_stats(int net_id);
#endif /* MODELNET_H */
/*
......
......@@ -49,6 +49,7 @@ static void torus_packet_event_rc(tw_lp *sender);
static void torus_setup(const void* net_params);
static int torus_get_msg_sz(void);
static const tw_lptype* torus_get_lp_type(void);
static void torus_report_stats(void);
/* data structure for torus statistics */
struct model_net_method torus_method =
......@@ -59,6 +60,7 @@ struct model_net_method torus_method =
.model_net_method_packet_event_rc = torus_packet_event_rc,
.mn_get_lp_type = torus_get_lp_type,
.mn_get_msg_sz = torus_get_msg_sz,
.mn_report_stats = torus_report_stats,
};
enum nodes_event_t
......
......@@ -96,7 +96,7 @@ int model_net_set_params()
{
char mn_name[MAX_NAME_LENGTH];
int packet_size = 0;
int net_id;
int net_id=-1;
config_lpgroups_t paramconf;
configuration_get_lpgroups(&config, "PARAMS", &paramconf);
......@@ -176,7 +176,6 @@ int model_net_set_params()
exit(-1);
}
i++;
token = strtok(NULL,",");
}
net_id = model_net_setup("torus", packet_size, (const void*)&net_params);
......@@ -249,6 +248,18 @@ const tw_lptype* model_net_get_lp_type(int net_id)
return method_array[net_id]->mn_get_lp_type();
}
void model_net_report_stats(int net_id)
{
if(net_id < 0 || net_id > NUM_NETS)
{
fprintf(stderr, "%s Error: Uninitializied modelnet network, call modelnet_init first\n", __FUNCTION__);
exit(-1);
}
// TODO: ADd checks by network names
// // Add dragonfly and torus network models
return method_array[net_id]->mn_report_stats();
}
/* registers the lp type */
void model_net_add_lp_type(int net_id)
{
......
......@@ -121,6 +121,9 @@ static void simplenet_packet_event(
static void simplenet_packet_event_rc(tw_lp *sender);
static void simplenet_packet_event_rc(tw_lp *sender);
static void sn_report_stats();
/* data structure for model-net statistics */
struct model_net_method simplenet_method =
{
......@@ -130,6 +133,7 @@ struct model_net_method simplenet_method =
.model_net_method_packet_event_rc = simplenet_packet_event_rc,
.mn_get_lp_type = sn_get_lp_type,
.mn_get_msg_sz = sn_get_msg_sz,
.mn_report_stats = sn_report_stats,
};
static void sn_init(
......@@ -204,6 +208,12 @@ static void sn_set_params(double net_startup_ns, double net_bw_mbs)
return;
}
/* report network statistics */
static void sn_report_stats()
{
/* TODO: Do we have some simplenet statistics to report like we have for torus and dragonfly? */
return;
}
static void sn_init(
sn_state * ns,
tw_lp * lp)
......
......@@ -460,6 +460,21 @@ static void packet_arrive( nodes_state * s,
}
}
static void torus_report_stats()
{
unsigned long long avg_hops, total_finished_packets;
tw_stime avg_time, max_time;
MPI_Reduce( &total_hops, &avg_hops, 1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce( &N_finished_packets, &total_finished_packets, 1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce( &total_time, &avg_time, 1,MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce( &max_latency, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
if(!g_tw_mynode)
{
printf(" Average number of hops traversed %f average message latency %lf us maximum message latency %lf us \n", (float)avg_hops/total_finished_packets, avg_time/(total_finished_packets*1000), max_time/1000);
}
}
void
final( nodes_state * s, tw_lp * lp )
{
......
......@@ -195,7 +195,8 @@ int main(
}
tw_run();
model_net_report_stats(net_id);
ret = lp_io_flush(handle, MPI_COMM_WORLD);
assert(ret == 0);
......
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