From: mquinson Date: Fri, 26 Jun 2009 16:09:45 +0000 (+0000) Subject: SMPI: Change the reference speed to a command line option X-Git-Tag: SVN~1271 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/725184f3bce66a3eff87cc3a01e5d96477a5d28a?ds=sidebyside SMPI: Change the reference speed to a command line option git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6369 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index f47757cf8b..5aef7fb512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -64,6 +64,7 @@ SimGrid (3.4-svn) unstable; urgency=high - Pass the right rank value to processes according to the hostfile * Compile the examples by default, and use them as regression tests * Implement MPI_Wtime() + * Change the reference speed to a command line option SURF: * TCP_gamma can now be specified as command line option using diff --git a/include/xbt/config.h b/include/xbt/config.h index dde90d375e..41800aa9b4 100644 --- a/include/xbt/config.h +++ b/include/xbt/config.h @@ -169,13 +169,13 @@ XBT_PUBLIC(void) xbt_cfg_dump(const char *name, const char *indent, * * @{ */ -XBT_PUBLIC(void) xbt_cfg_register(xbt_cfg_t cfg, +XBT_PUBLIC(void) xbt_cfg_register(xbt_cfg_t *cfg, const char *name, const char *description, - e_xbt_cfgelm_type_t type, + e_xbt_cfgelm_type_t type, void *default_value, int min, int max, xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm); XBT_PUBLIC(void) xbt_cfg_unregister(xbt_cfg_t cfg, const char *name); -XBT_PUBLIC(void) xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry); +XBT_PUBLIC(void) xbt_cfg_register_str(xbt_cfg_t *cfg, const char *entry); XBT_PUBLIC(void) xbt_cfg_help(xbt_cfg_t cfg); XBT_PUBLIC(void) xbt_cfg_check(xbt_cfg_t cfg); XBT_PUBLIC(e_xbt_cfgelm_type_t) xbt_cfg_get_type(xbt_cfg_t cfg, diff --git a/src/smpi/private.h b/src/smpi/private.h index 705a987459..487d12913f 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -83,7 +83,6 @@ typedef struct smpi_global_t { double reference_speed; // state vars - int process_count; xbt_mallocator_t request_mallocator; xbt_mallocator_t message_mallocator; diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 16f7cf8ff2..81ff890b1a 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -15,7 +15,7 @@ void smpi_execute(double duration) SIMIX_mutex_lock(mutex); action = - SIMIX_action_execute(host, "execute", duration * SMPI_DEFAULT_SPEED); + SIMIX_action_execute(host, "execute", duration * smpi_global->reference_speed); SIMIX_register_action_to_condition(action, cond); for (state = SIMIX_action_get_state(action); diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index c853ce3dd8..9c2556f426 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -142,8 +142,6 @@ void smpi_global_init() #endif smpi_global = xbt_new(s_smpi_global_t, 1); - // config variable - smpi_global->reference_speed = SMPI_DEFAULT_SPEED; // mallocators smpi_global->request_mallocator = @@ -262,6 +260,10 @@ smx_cond_t smpi_process_cond() return pdata->cond; } +static void smpi_cfg_cb_host_speed(const char *name, int pos) { + smpi_global->reference_speed = xbt_cfg_get_double_at(_surf_cfg_set,name,pos); +} + int smpi_run_simulation(int *argc, char **argv) { smx_cond_t cond = NULL; @@ -272,6 +274,9 @@ int smpi_run_simulation(int *argc, char **argv) srand(SMPI_RAND_SEED); + double default_reference_speed = 20000.0; + xbt_cfg_register(&_surf_cfg_set,"reference_speed","Power of the host running the simulation (in flop/s). Used to bench the operations.", + xbt_cfgelm_double,&default_reference_speed,1,1,smpi_cfg_cb_host_speed,NULL); SIMIX_global_init(argc, argv); // parse the platform file: get the host list @@ -283,10 +288,6 @@ int smpi_run_simulation(int *argc, char **argv) // must initialize globals between creating environment and launching app.... smpi_global_init(); - /* Prepare to display some more info when dying on Ctrl-C pressing */ - // FIXME: doesn't work - //signal(SIGINT, inthandler); - /* Clean IO before the run */ fflush(stdout); fflush(stderr); diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c index fb2a7e114a..dbaf64d419 100644 --- a/src/surf/surf_config.c +++ b/src/surf/surf_config.c @@ -111,19 +111,19 @@ static void _surf_cfg_cb__surf_path(const char *name, int pos) { void surf_config_init(int *argc, char **argv) { /* Create the configuration support */ - if (!_surf_cfg_set) { /* Only create stuff if not already inited */ - _surf_cfg_set = xbt_cfg_new(); + if (_surf_init_status==0) { /* Only create stuff if not already inited */ _surf_init_status = 1; char *description = xbt_malloc(1024), *p = description; + char *default_value; int i; sprintf(description,"The model to use for the workstation. Possible values: "); while (*(++p) != '\0'); for (i=0;surf_workstation_model_description[i].name;i++) p+=sprintf(p,"%s%s",(i==0?"":", "),surf_workstation_model_description[i].name); - - xbt_cfg_register(_surf_cfg_set, - "workstation_model", xbt_strdup(description), xbt_cfgelm_string, 1, 1, + default_value = (char*)"CLM03"; + xbt_cfg_register(&_surf_cfg_set, + "workstation_model", xbt_strdup(description), xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__workstation_model, NULL); sprintf(description,"The model to use for the CPU. Possible values: "); @@ -131,8 +131,9 @@ void surf_config_init(int *argc, char **argv) { while (*(++p) != '\0'); for (i=0;surf_cpu_model_description[i].name;i++) p+=sprintf(p,"%s%s",(i==0?"":", "),surf_cpu_model_description[i].name); - xbt_cfg_register(_surf_cfg_set, - "cpu_model", xbt_strdup(description), xbt_cfgelm_string, 1, 1, + default_value = (char*)"Cas01"; + xbt_cfg_register(&_surf_cfg_set, + "cpu_model", xbt_strdup(description), xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL); sprintf(description,"The model to use for the network. Possible values: "); @@ -140,20 +141,17 @@ void surf_config_init(int *argc, char **argv) { while (*(++p) != '\0'); for (i=0;surf_network_model_description[i].name;i++) p+=sprintf(p,"%s%s",(i==0?"":", "),surf_network_model_description[i].name); - xbt_cfg_register(_surf_cfg_set, - "network_model", description, xbt_cfgelm_string, 1, 1, + default_value = (char*)"CM02"; + xbt_cfg_register(&_surf_cfg_set, + "network_model", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__network_model, NULL); - xbt_cfg_set_string(_surf_cfg_set, "workstation_model", "CLM03"); - xbt_cfg_set_string(_surf_cfg_set, "cpu_model", "Cas01"); - xbt_cfg_set_string(_surf_cfg_set, "network_model", "CM02"); - - xbt_cfg_register(_surf_cfg_set,"TCP_gamma","Size of the biggest TCP window",1,1, - xbt_cfgelm_double,_surf_cfg_cb__tcp_gamma,NULL); - xbt_cfg_set_double(_surf_cfg_set, "TCP_gamma", 20000.0); + double default_TCP_GAMMA = 20000.0; + xbt_cfg_register(&_surf_cfg_set,"TCP_gamma","Size of the biggest TCP window", + xbt_cfgelm_double,&default_TCP_GAMMA,1,1,_surf_cfg_cb__tcp_gamma,NULL); - xbt_cfg_register(_surf_cfg_set,"path","Lookup path for inclusions in platform and deployment XML files", - xbt_cfgelm_string, 0,0,_surf_cfg_cb__surf_path,NULL); + xbt_cfg_register(&_surf_cfg_set,"path","Lookup path for inclusions in platform and deployment XML files", + xbt_cfgelm_string, NULL,0,0,_surf_cfg_cb__surf_path,NULL); if (!surf_path) { /* retrieves the current directory of the current process */ const char *initial_path = __surf_get_initial_path(); diff --git a/src/xbt/config.c b/src/xbt/config.c index 10a9a97145..7d663cb6c9 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -86,7 +86,7 @@ void xbt_cfg_cpy(xbt_cfg_t tocopy, xbt_cfg_t * whereto) xbt_assert0(tocopy, "cannot copy NULL config"); xbt_dict_foreach((xbt_dict_t) tocopy, cursor, name, variable) { - xbt_cfg_register(*whereto, name, variable->desc, variable->type, variable->min, + xbt_cfg_register(whereto, name, variable->desc, variable->type, NULL, variable->min, variable->max, variable->cb_set, variable->cb_rm); } } @@ -199,17 +199,18 @@ void xbt_cfgelm_free(void *data) */ void -xbt_cfg_register(xbt_cfg_t cfg, - const char *name, const char *desc, e_xbt_cfgelm_type_t type, +xbt_cfg_register(xbt_cfg_t *cfg, + const char *name, const char *desc, e_xbt_cfgelm_type_t type, void *default_value, int min, int max, xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm) { xbt_cfgelm_t res; - xbt_assert(cfg); + if (*cfg==NULL) + *cfg=xbt_cfg_new(); xbt_assert4(type >= xbt_cfgelm_int && type <= xbt_cfgelm_peer, "type of %s not valid (%d should be between %d and %d)", name, type, xbt_cfgelm_int, xbt_cfgelm_peer); - res = xbt_dict_get_or_null((xbt_dict_t) cfg, name); + res = xbt_dict_get_or_null((xbt_dict_t) *cfg, name); if (res) { WARN1("Config elem %s registered twice.", name); @@ -218,7 +219,7 @@ xbt_cfg_register(xbt_cfg_t cfg, res = xbt_new(s_xbt_cfgelm_t, 1); DEBUG8("Register cfg elm %s (%s) (%d to %d %s (=%d) @%p in set %p)", - name, desc, min, max, xbt_cfgelm_type_name[type], type, res, cfg); + name, desc, min, max, xbt_cfgelm_type_name[type], type, res, *cfg); res->desc = desc; res->type = type; @@ -230,25 +231,33 @@ xbt_cfg_register(xbt_cfg_t cfg, switch (type) { case xbt_cfgelm_int: res->content = xbt_dynar_new(sizeof(int), NULL); + if (default_value) + xbt_dynar_push(res->content,default_value); break; case xbt_cfgelm_double: res->content = xbt_dynar_new(sizeof(double), NULL); + if (default_value) + xbt_dynar_push(res->content,default_value); break; case xbt_cfgelm_string: res->content = xbt_dynar_new(sizeof(char *), xbt_free_ref); + if (default_value) + xbt_dynar_push(res->content,default_value); break; case xbt_cfgelm_peer: res->content = xbt_dynar_new(sizeof(xbt_peer_t), xbt_peer_free_voidp); + if (default_value) + xbt_dynar_push(res->content,default_value); break; default: ERROR1("%d is an invalide type code", type); } - xbt_dict_set((xbt_dict_t) cfg, name, res, &xbt_cfgelm_free); + xbt_dict_set((xbt_dict_t) *cfg, name, res, &xbt_cfgelm_free); } /** @brief Unregister an element from a config set. @@ -279,7 +288,7 @@ void xbt_cfg_unregister(xbt_cfg_t cfg, const char *name) * @fixme: this does not allow to set the description */ -void xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry) +void xbt_cfg_register_str(xbt_cfg_t *cfg, const char *entry) { char *entrycpy = xbt_strdup(entry); char *tok; @@ -315,7 +324,7 @@ void xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry) "Invalid type in config element descriptor: %s%s", entry, "; Should be one of 'string', 'int', 'peer' or 'double'."); - xbt_cfg_register(cfg, entrycpy, NULL, type, min, max, NULL, NULL); + xbt_cfg_register(cfg, entrycpy, NULL, type, NULL, min, max, NULL, NULL); free(entrycpy); /* strdup'ed by dict mechanism, but cannot be const */ } @@ -415,9 +424,11 @@ static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, xbt_cfgelm_t res = NULL; res = xbt_dict_get_or_null((xbt_dict_t) cfg, name); - if (!res) + if (!res) { + xbt_cfg_help(cfg); THROW1(not_found_error, 0, "No registered variable '%s' in this config set", name); + } xbt_assert3(type == xbt_cfgelm_any || res->type == type, "You tried to access to the config element %s as an %s, but its type is %s.", @@ -1222,10 +1233,9 @@ static xbt_cfg_t make_set() xbt_cfg_t set = NULL; xbt_log_threshold_set(&_XBT_LOGV(xbt_cfg),xbt_log_priority_critical); - set = xbt_cfg_new(); - xbt_cfg_register_str(set, "speed:1_to_2_int"); - xbt_cfg_register_str(set, "peername:1_to_1_string"); - xbt_cfg_register_str(set, "user:1_to_10_string"); + xbt_cfg_register_str(&set, "speed:1_to_2_int"); + xbt_cfg_register_str(&set, "peername:1_to_1_string"); + xbt_cfg_register_str(&set, "user:1_to_10_string"); return set; } /* end_of_make_set */