Commit 8ef0ddb7 authored by Jonathan Jenkins's avatar Jonathan Jenkins

configuration method change allowing multiple networks

- "modelnet" parameter in cfg is now a no-op
- "modelnet_order" parameter in cfg is required,
  listing order in which networks are indexed to
  the model
- modified "model_net_set_params" signature
- updated tests to use the new interface
parent 192c119f
...@@ -49,7 +49,7 @@ void * model_net_method_get_edata(int net_id, void * msg); ...@@ -49,7 +49,7 @@ void * model_net_method_get_edata(int net_id, void * msg);
/// use them /// use them
// init method // init method
void model_net_base_init(); void model_net_base_init(int id_count, int *ids);
enum model_net_base_event_type { enum model_net_base_event_type {
MN_BASE_NEW_MSG, MN_BASE_NEW_MSG,
......
...@@ -140,14 +140,12 @@ struct torus_param ...@@ -140,14 +140,12 @@ struct torus_param
/* In general we need to figure out how to pass configuration information to /* In general we need to figure out how to pass configuration information to
* the methods and we need to be able to calculate ross event message size. * the methods and we need to be able to calculate ross event message size.
*/ */
/*Initialize the network by specifying the network parameters. The
* underlying model-net.c function call will set the network parameters /* Initialize/configure the network(s) based on the CODES configuration.
* according to the network name specified*/ * returns an array of the network ids, indexed in the order given by the
// return an integer being the identifier for the type of network * modelnet_order configuration parameter
// call modelnet setup 1 time for a torus and retur value is 0 for e.g. * OUTPUT id_count - the output number of networks */
int* model_net_set_params(int *id_count);
/* call set params for configuring the network parameters from the config file*/
int model_net_set_params();
// setup the modelnet parameters // setup the modelnet parameters
int model_net_setup(char* net_name, uint64_t packet_size, const void* net_params); int model_net_setup(char* net_name, uint64_t packet_size, const void* net_params);
......
...@@ -93,7 +93,7 @@ tw_lptype model_net_base_lp = { ...@@ -93,7 +93,7 @@ tw_lptype model_net_base_lp = {
/**** BEGIN IMPLEMENTATIONS ****/ /**** BEGIN IMPLEMENTATIONS ****/
void model_net_base_init(){ void model_net_base_init(int id_count, int *ids){
uint32_t h1=0, h2=0; uint32_t h1=0, h2=0;
bj_hashlittle2(MN_NAME, strlen(MN_NAME), &h1, &h2); bj_hashlittle2(MN_NAME, strlen(MN_NAME), &h1, &h2);
...@@ -101,16 +101,37 @@ void model_net_base_init(){ ...@@ -101,16 +101,37 @@ void model_net_base_init(){
// here, we initialize ALL lp types to use the base type // here, we initialize ALL lp types to use the base type
// TODO: only initialize ones that are actually used // TODO: only initialize ones that are actually used
for (int i = 0; i < MAX_NETS; i++){ for (int i = 0; i < id_count; i++){
lp_type_register(model_net_lp_config_names[i], &model_net_base_lp); lp_type_register(model_net_lp_config_names[ids[i]], &model_net_base_lp);
} }
// initialize the msg-specific offsets // initialize the msg-specific offsets
msg_offsets[SIMPLENET] = offsetof(model_net_wrap_msg, msg.m_snet); for (int i = 0; i < id_count; i++){
msg_offsets[SIMPLEWAN] = offsetof(model_net_wrap_msg, msg.m_swan); switch(ids[i]){
msg_offsets[TORUS] = offsetof(model_net_wrap_msg, msg.m_torus); case SIMPLENET:
msg_offsets[DRAGONFLY] = offsetof(model_net_wrap_msg, msg.m_dfly); msg_offsets[SIMPLENET] =
msg_offsets[LOGGP] = offsetof(model_net_wrap_msg, msg.m_loggp); offsetof(model_net_wrap_msg, msg.m_snet);
break;
case SIMPLEWAN:
msg_offsets[SIMPLEWAN] =
offsetof(model_net_wrap_msg, msg.m_swan);
break;
case TORUS:
msg_offsets[TORUS] =
offsetof(model_net_wrap_msg, msg.m_torus);
break;
case DRAGONFLY:
msg_offsets[DRAGONFLY] =
offsetof(model_net_wrap_msg, msg.m_dfly);
break;
case LOGGP:
msg_offsets[LOGGP] =
offsetof(model_net_wrap_msg, msg.m_loggp);
break;
default:
assert(0);
}
}
} }
void model_net_base_lp_init( void model_net_base_lp_init(
...@@ -192,6 +213,8 @@ void model_net_base_event_rc( ...@@ -192,6 +213,8 @@ void model_net_base_event_rc(
assert(!"model_net_base event type not known"); assert(!"model_net_base event type not known");
break; break;
} }
*(int*)b = 0;
} }
void model_net_base_finalize( void model_net_base_finalize(
......
...@@ -251,19 +251,34 @@ void model_net_pull_event( ...@@ -251,19 +251,34 @@ void model_net_pull_event(
1, offset, self_event_size, self_event, 0, NULL, sender); 1, offset, self_event_size, self_event, 0, NULL, sender);
} }
int* model_net_set_params(int *id_count)
int model_net_set_params()
{ {
char mn_name[MAX_NAME_LENGTH];
char sched[MAX_NAME_LENGTH]; char sched[MAX_NAME_LENGTH];
long int packet_size_l = 0; long int packet_size_l = 0;
uint64_t packet_size; uint64_t packet_size;
int net_id=-1;
int ret; int ret;
config_lpgroups_t lpconf;
// TODO: currently just hard-coding the name determination, should probably
// refactor to do this elsewhere (in codes-base?)
int do_config_nets[MAX_NETS];
memset(do_config_nets, 0, MAX_NETS*sizeof(*do_config_nets));
// TODO: inefficient (codes_mapping opens up the same section), but at least
// this avoids the need to call codes_mapping_setup first
configuration_get_lpgroups(&config, "LPGROUPS", &lpconf);
for (int grp = 0; grp < lpconf.lpgroups_count; grp++){
config_lpgroup_t *lpgroup = &lpconf.lpgroups[grp];
for (int lpt = 0; lpt < lpgroup->lptypes_count; lpt++){
char *nm = lpgroup->lptypes[lpt].name;
for (int n = 0; n < MAX_NETS; n++){
if (strcmp(model_net_lp_config_names[n], nm) == 0){
do_config_nets[n] = 1;
break;
}
}
}
}
config_lpgroups_t paramconf;
configuration_get_lpgroups(&config, "PARAMS", &paramconf);
configuration_get_value(&config, "PARAMS", "modelnet", mn_name, MAX_NAME_LENGTH);
ret = configuration_get_value(&config, "PARAMS", "modelnet_scheduler", sched, ret = configuration_get_value(&config, "PARAMS", "modelnet_scheduler", sched,
MAX_NAME_LENGTH); MAX_NAME_LENGTH);
...@@ -298,10 +313,10 @@ int model_net_set_params() ...@@ -298,10 +313,10 @@ int model_net_set_params()
else if (!packet_size && mn_sched_type != MN_SCHED_FCFS_FULL) else if (!packet_size && mn_sched_type != MN_SCHED_FCFS_FULL)
{ {
packet_size = 512; packet_size = 512;
fprintf(stderr, "\n Warning, no packet size specified, setting packet size to %llu ", packet_size); fprintf(stderr, "\n Warning, no packet size specified, setting packet size to %llu\n", packet_size);
} }
if(strcmp(model_net_method_names[SIMPLENET],mn_name)==0) if(do_config_nets[SIMPLENET])
{ {
double net_startup_ns, net_bw_mbps; double net_startup_ns, net_bw_mbps;
simplenet_param net_params; simplenet_param net_params;
...@@ -310,25 +325,25 @@ int model_net_set_params() ...@@ -310,25 +325,25 @@ int model_net_set_params()
configuration_get_value_double(&config, "PARAMS", "net_bw_mbps", &net_bw_mbps); configuration_get_value_double(&config, "PARAMS", "net_bw_mbps", &net_bw_mbps);
net_params.net_startup_ns = net_startup_ns; net_params.net_startup_ns = net_startup_ns;
net_params.net_bw_mbps = net_bw_mbps; net_params.net_bw_mbps = net_bw_mbps;
net_id = model_net_setup(model_net_method_names[SIMPLENET], packet_size, (const void*)&net_params); /* Sets the network as simplenet and packet size 512 */ model_net_setup(model_net_method_names[SIMPLENET], packet_size, (const void*)&net_params); /* Sets the network as simplenet and packet size 512 */
} }
else if (strcmp(model_net_method_names[SIMPLEWAN],mn_name)==0){ if (do_config_nets[SIMPLEWAN]){
simplewan_param net_params; simplewan_param net_params;
configuration_get_value_relpath(&config, "PARAMS", "net_startup_ns_file", net_params.startup_filename, MAX_NAME_LENGTH); configuration_get_value_relpath(&config, "PARAMS", "net_startup_ns_file", net_params.startup_filename, MAX_NAME_LENGTH);
configuration_get_value_relpath(&config, "PARAMS", "net_bw_mbps_file", net_params.bw_filename, MAX_NAME_LENGTH); configuration_get_value_relpath(&config, "PARAMS", "net_bw_mbps_file", net_params.bw_filename, MAX_NAME_LENGTH);
net_id = model_net_setup(model_net_method_names[SIMPLEWAN], packet_size, (const void*)&net_params); model_net_setup(model_net_method_names[SIMPLEWAN], packet_size, (const void*)&net_params);
} }
else if(strcmp(model_net_method_names[LOGGP],mn_name)==0) if(do_config_nets[LOGGP])
{ {
char net_config_file[256]; char net_config_file[256];
loggp_param net_params; loggp_param net_params;
configuration_get_value_relpath(&config, "PARAMS", "net_config_file", net_config_file, 256); configuration_get_value_relpath(&config, "PARAMS", "net_config_file", net_config_file, 256);
net_params.net_config_file = net_config_file; net_params.net_config_file = net_config_file;
net_id = model_net_setup(model_net_method_names[LOGGP], packet_size, (const void*)&net_params); /* Sets the network as loggp and packet size 512 */ model_net_setup(model_net_method_names[LOGGP], packet_size, (const void*)&net_params); /* Sets the network as loggp and packet size 512 */
} }
else if(strcmp(model_net_method_names[DRAGONFLY], mn_name)==0) if(do_config_nets[DRAGONFLY])
{ {
dragonfly_param net_params; dragonfly_param net_params;
int num_routers=0, num_vcs=0, local_vc_size=0, global_vc_size=0, cn_vc_size=0, chunk_size=0; int num_routers=0, num_vcs=0, local_vc_size=0, global_vc_size=0, cn_vc_size=0, chunk_size=0;
...@@ -420,9 +435,9 @@ int model_net_set_params() ...@@ -420,9 +435,9 @@ int model_net_set_params()
printf("\n No routing protocol specified, setting to minimal routing"); printf("\n No routing protocol specified, setting to minimal routing");
net_params.routing = 0; net_params.routing = 0;
} }
net_id = model_net_setup(model_net_method_names[DRAGONFLY], packet_size, (const void*)&net_params); model_net_setup(model_net_method_names[DRAGONFLY], packet_size, (const void*)&net_params);
} }
else if(strcmp(model_net_method_names[TORUS], mn_name)==0) if(do_config_nets[TORUS])
{ {
torus_param net_params; torus_param net_params;
char dim_length[MAX_NAME_LENGTH]; char dim_length[MAX_NAME_LENGTH];
...@@ -484,12 +499,58 @@ int model_net_set_params() ...@@ -484,12 +499,58 @@ int model_net_set_params()
i++; i++;
token = strtok(NULL,","); token = strtok(NULL,",");
} }
net_id = model_net_setup(model_net_method_names[TORUS], packet_size, (const void*)&net_params); model_net_setup(model_net_method_names[TORUS], packet_size, (const void*)&net_params);
} }
else
printf("\n Invalid network argument %s ", mn_name); // now that the LP-specific nets are set up...
model_net_base_init(); // - get the number of nets used
return net_id; *id_count = 0;
for (int i = 0; i < MAX_NETS; i++){
if (do_config_nets[i]){
(*id_count)++;
}
}
// - allocate the output
int *ids = malloc(*id_count * sizeof(int));
// - read the ordering provided by modelnet_order
char **values;
size_t length;
ret = configuration_get_multivalue(&config, "PARAMS", "modelnet_order", &values, &length);
if (ret != 1){
fprintf(stderr, "unable to read PARAMS:modelnet_order variable\n");
abort();
}
if (length != (size_t) *id_count){
fprintf(stderr, "number of networks in PARAMS:modelnet_order "
"do not match number in LPGROUPS\n");
abort();
}
// - set the index
for (int i = 0; i < *id_count; i++){
ids[i] = -1;
for (int n = 0; n < MAX_NETS; n++){
if (strcmp(values[i], model_net_method_names[n]) == 0){
if (!do_config_nets[n]){
fprintf(stderr, "network in PARAMS:modelnet_order not "
"present in LPGROUPS: %s\n", values[i]);
abort();
}
ids[i] = n;
break;
}
}
if (ids[i] == -1){
fprintf(stderr, "unknown network in PARAMS:modelnet_order: %s\n",
values[i]);
abort();
}
free(values[i]);
}
free(values);
// - pass along to model_net_base_init
model_net_base_init(*id_count, ids);
// - done
return ids;
} }
void model_net_event_rc( void model_net_event_rc(
......
check_PROGRAMS += tests/modelnet-test tests/modelnet-p2p-bw \ check_PROGRAMS += tests/modelnet-test tests/modelnet-p2p-bw \
tests/concurrent-msg-recv tests/modelnet-simplewan-test \ tests/concurrent-msg-recv tests/modelnet-simplewan-test \
tests/modelnet-test-collective tests/modelnet-test-collective
TESTS += tests/modelnet-test.sh \ TESTS += tests/modelnet-test.sh \
......
...@@ -454,6 +454,7 @@ tw_stime s_to_ns(tw_stime ns) ...@@ -454,6 +454,7 @@ tw_stime s_to_ns(tw_stime ns)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int num_nets, *net_ids;
g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */ g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */
tw_opt_add(app_opt); tw_opt_add(app_opt);
...@@ -475,8 +476,11 @@ int main(int argc, char *argv[]) ...@@ -475,8 +476,11 @@ int main(int argc, char *argv[])
} }
/* Setup the model-net parameters specified in the global config object, /* Setup the model-net parameters specified in the global config object,
* returned is the identifier for the network type */ * returned are the identifier for the network type */
net_id = model_net_set_params(); net_ids = model_net_set_params(&num_nets);
assert(num_nets==1);
net_id = *net_ids;
free(net_ids);
/* currently restrict to simplenet, as other networks are trickier to /* currently restrict to simplenet, as other networks are trickier to
* setup. TODO: handle other networks properly */ * setup. TODO: handle other networks properly */
......
...@@ -13,7 +13,7 @@ PARAMS ...@@ -13,7 +13,7 @@ PARAMS
# modelnet params # modelnet params
packet_size="2097152"; packet_size="2097152";
message_size="560"; message_size="560";
modelnet="simplenet"; modelnet_ordering=( "simplenet" );
net_startup_ns = "6.782182"; net_startup_ns = "6.782182";
# net bandwidth, in floating point MiB/s # net bandwidth, in floating point MiB/s
......
...@@ -11,7 +11,7 @@ PARAMS ...@@ -11,7 +11,7 @@ PARAMS
{ {
packet_size="2147483648"; packet_size="2147483648";
message_size="208"; message_size="208";
modelnet="loggp"; modelnet_order=( "loggp" );
# scheduler options # scheduler options
modelnet_scheduler="fcfs"; modelnet_scheduler="fcfs";
# modelnet_scheduler="round-robin"; # modelnet_scheduler="round-robin";
......
...@@ -11,7 +11,7 @@ LPGROUPS ...@@ -11,7 +11,7 @@ LPGROUPS
PARAMS PARAMS
{ {
packet_size="512"; packet_size="512";
modelnet="dragonfly"; modelnet_order=( "dragonfly" );
# scheduler options # scheduler options
modelnet_scheduler="fcfs"; modelnet_scheduler="fcfs";
chunk_size="32"; chunk_size="32";
......
...@@ -11,7 +11,7 @@ PARAMS ...@@ -11,7 +11,7 @@ PARAMS
{ {
packet_size="512"; packet_size="512";
message_size="256"; message_size="256";
modelnet="loggp"; modelnet_order=( "loggp" );
# scheduler options # scheduler options
modelnet_scheduler="fcfs"; modelnet_scheduler="fcfs";
# modelnet_scheduler="round-robin"; # modelnet_scheduler="round-robin";
......
...@@ -10,7 +10,7 @@ LPGROUPS ...@@ -10,7 +10,7 @@ LPGROUPS
PARAMS PARAMS
{ {
packet_size="512"; packet_size="512";
modelnet="torus"; modelnet_order=( "torus" );
# scheduler options # scheduler options
modelnet_scheduler="fcfs"; modelnet_scheduler="fcfs";
# modelnet_scheduler="round-robin"; # modelnet_scheduler="round-robin";
......
...@@ -11,7 +11,7 @@ PARAMS ...@@ -11,7 +11,7 @@ PARAMS
{ {
packet_size="512"; packet_size="512";
message_size="256"; message_size="256";
modelnet="simplenet"; modelnet_order=( "simplenet" );
# scheduler options # scheduler options
modelnet_scheduler="fcfs"; modelnet_scheduler="fcfs";
# modelnet_scheduler="round-robin"; # modelnet_scheduler="round-robin";
......
...@@ -130,6 +130,8 @@ int main( ...@@ -130,6 +130,8 @@ int main(
{ {
int nprocs; int nprocs;
int rank; int rank;
int num_nets;
int *net_ids;
g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */ g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */
lp_io_handle handle; lp_io_handle handle;
...@@ -146,7 +148,10 @@ int main( ...@@ -146,7 +148,10 @@ int main(
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
configuration_load(argv[2], MPI_COMM_WORLD, &config); configuration_load(argv[2], MPI_COMM_WORLD, &config);
net_id=model_net_set_params(); net_ids = model_net_set_params(&num_nets);
assert(num_nets==1);
net_id = *net_ids;
free(net_ids);
svr_add_lp_type(); svr_add_lp_type();
codes_mapping_setup(); codes_mapping_setup();
......
...@@ -142,6 +142,7 @@ int main( ...@@ -142,6 +142,7 @@ int main(
{ {
int nprocs; int nprocs;
int rank; int rank;
int num_nets, *net_ids;
//printf("\n Config count %d ",(int) config.lpgroups_count); //printf("\n Config count %d ",(int) config.lpgroups_count);
g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */ g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */
lp_io_handle handle; lp_io_handle handle;
...@@ -159,7 +160,10 @@ int main( ...@@ -159,7 +160,10 @@ int main(
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
configuration_load(argv[2], MPI_COMM_WORLD, &config); configuration_load(argv[2], MPI_COMM_WORLD, &config);
net_id=model_net_set_params(); net_ids = model_net_set_params(&num_nets);
assert(num_nets==1);
net_id = *net_ids;
free(net_ids);
svr_add_lp_type(); svr_add_lp_type();
codes_mapping_setup(); codes_mapping_setup();
......
...@@ -142,6 +142,7 @@ int main( ...@@ -142,6 +142,7 @@ int main(
{ {
int nprocs; int nprocs;
int rank; int rank;
int num_nets, *net_ids;
//printf("\n Config count %d ",(int) config.lpgroups_count); //printf("\n Config count %d ",(int) config.lpgroups_count);
g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */ g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */
lp_io_handle handle; lp_io_handle handle;
...@@ -159,7 +160,10 @@ int main( ...@@ -159,7 +160,10 @@ int main(
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
configuration_load(argv[2], MPI_COMM_WORLD, &config); configuration_load(argv[2], MPI_COMM_WORLD, &config);
net_id=model_net_set_params(); net_ids = model_net_set_params(&num_nets);
assert(num_nets==1);
net_id = *net_ids;
free(net_ids);
svr_add_lp_type(); svr_add_lp_type();
codes_mapping_setup(); codes_mapping_setup();
......
...@@ -152,6 +152,8 @@ int main( ...@@ -152,6 +152,8 @@ int main(
{ {
int nprocs; int nprocs;
int rank; int rank;
int num_nets;
int *net_ids;
//printf("\n Config count %d ",(int) config.lpgroups_count); //printf("\n Config count %d ",(int) config.lpgroups_count);
g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */ g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */
lp_io_handle handle; lp_io_handle handle;
...@@ -169,7 +171,10 @@ int main( ...@@ -169,7 +171,10 @@ int main(
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
configuration_load(argv[2], MPI_COMM_WORLD, &config); configuration_load(argv[2], MPI_COMM_WORLD, &config);
net_id=model_net_set_params(); net_ids = model_net_set_params(&num_nets);
assert(num_nets==1);
net_id = *net_ids;
free(net_ids);
svr_add_lp_type(); svr_add_lp_type();
codes_mapping_setup(); codes_mapping_setup();
......
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