- 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
*
* @{
*/
-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,
double reference_speed;
// state vars
-
int process_count;
xbt_mallocator_t request_mallocator;
xbt_mallocator_t message_mallocator;
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);
#endif
smpi_global = xbt_new(s_smpi_global_t, 1);
- // config variable
- smpi_global->reference_speed = SMPI_DEFAULT_SPEED;
// mallocators
smpi_global->request_mallocator =
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;
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
// 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);
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: ");
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: ");
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();
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);
}
}
*/
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);
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;
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.
* @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;
"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 */
}
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.",
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 */