diff --git a/codes/model-net-method.h b/codes/model-net-method.h index 34f28aa55476a6718e1cfbee30b75159f535d964..901b7dbbe00ade4e7c8b8b86cc89c4c2c2fee507 100644 --- a/codes/model-net-method.h +++ b/codes/model-net-method.h @@ -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 */ diff --git a/codes/model-net.h b/codes/model-net.h index 249a66a4421ac58b2102082735ed45571217b2f0..768c8be0ed61e8f8925a994ea1f9bb9ab1fa535e 100644 --- a/codes/model-net.h +++ b/codes/model-net.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 */ /* diff --git a/codes/torus.h b/codes/torus.h index 768e219f500a69e320655188b87ecec74a5c3c08..b0a6a6b56966517e7e58c7d9e20866236195b65a 100644 --- a/codes/torus.h +++ b/codes/torus.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 diff --git a/src/models/networks/model-net/model-net.c b/src/models/networks/model-net/model-net.c index 57c0c12ec2359d10e5635adf5e634a9a8c5cdded..60d763e9c395a029e32a4e249acd9dd748ef0982 100644 --- a/src/models/networks/model-net/model-net.c +++ b/src/models/networks/model-net/model-net.c @@ -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", ¶mconf); @@ -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) { diff --git a/src/models/networks/model-net/simplenet-upd.c b/src/models/networks/model-net/simplenet-upd.c index a1fdcbd662bd8378b4ad5ac7f6e3a8dc9e51e488..b7e0ae84c84c37ce5aef1ed6c8f1b5c5f538a521 100644 --- a/src/models/networks/model-net/simplenet-upd.c +++ b/src/models/networks/model-net/simplenet-upd.c @@ -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) diff --git a/src/models/networks/model-net/torus.c b/src/models/networks/model-net/torus.c index 4a037078800498825398ca9fa1fb475dec0c23d3..a1b468f98dcb869693c629edaea6c4bbcc3cd1ed 100644 --- a/src/models/networks/model-net/torus.c +++ b/src/models/networks/model-net/torus.c @@ -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 ) { diff --git a/tests/modelnet-test.c b/tests/modelnet-test.c index 3dcb4c2068c95fe2c70bbf6a73c3c3b416efe966..2a837a7923e91a7faf2dc9c4f98494374ab799ff 100644 --- a/tests/modelnet-test.c +++ b/tests/modelnet-test.c @@ -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);