X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d4f9d0cf42605d96b91088c02ddfbf2411f89de1..1398fa7c21c0d81f808108e0803d875c6fce9b8e:/src/simgrid/sg_config.cpp diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index de7938f623..e1ba1a68f5 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -54,14 +54,14 @@ static void sg_config_cmd_line(int *argc, char **argv) opt = strchr(argv[i], '='); opt++; - xbt_cfg_set_parse(simgrid_config, opt); + xbt_cfg_set_parse(opt); XBT_DEBUG("Did apply '%s' as config setting", opt); } else if (!strcmp(argv[i], "--version")) { printf("%s\n", SIMGRID_VERSION_STRING); shall_exit = 1; } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) { printf("Description of the configuration accepted by this simulator:\n"); - xbt_cfg_help(simgrid_config); + xbt_cfg_help(); printf( "\n" "Each of these configurations can be used by adding\n" @@ -79,7 +79,7 @@ static void sg_config_cmd_line(int *argc, char **argv) shall_exit = 1; } else if (!strcmp(argv[i], "--help-aliases")) { printf("Here is a list of all deprecated option names, with their replacement.\n"); - xbt_cfg_aliases(simgrid_config); + xbt_cfg_aliases(); printf("Please consider using the recent names\n"); shall_exit = 1; } else if (!strcmp(argv[i], "--help-models")) { @@ -113,11 +113,14 @@ static void sg_config_cmd_line(int *argc, char **argv) } /* callback of the plugin variable */ -static void _sg_cfg_cb__plugin(const char *name, int pos) +static void _sg_cfg_cb__plugin(const char *name) { xbt_assert(_sg_cfg_init_status < 2, "Cannot load a plugin after the initialization"); char *val = xbt_cfg_get_string(name); + if (val==nullptr) + return; + if (!strcmp(val, "help")) { model_help("plugin", surf_plugin_description); sg_cfg_exit_early(); @@ -129,7 +132,7 @@ static void _sg_cfg_cb__plugin(const char *name, int pos) } /* callback of the host/model variable */ -static void _sg_cfg_cb__host_model(const char *name, int pos) +static void _sg_cfg_cb__host_model(const char *name) { xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); @@ -144,7 +147,7 @@ static void _sg_cfg_cb__host_model(const char *name, int pos) } /* callback of the vm/model variable */ -static void _sg_cfg_cb__vm_model(const char *name, int pos) +static void _sg_cfg_cb__vm_model(const char *name) { xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); @@ -159,7 +162,7 @@ static void _sg_cfg_cb__vm_model(const char *name, int pos) } /* callback of the cpu/model variable */ -static void _sg_cfg_cb__cpu_model(const char *name, int pos) +static void _sg_cfg_cb__cpu_model(const char *name) { xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); @@ -174,7 +177,7 @@ static void _sg_cfg_cb__cpu_model(const char *name, int pos) } /* callback of the cpu/model variable */ -static void _sg_cfg_cb__optimization_mode(const char *name, int pos) +static void _sg_cfg_cb__optimization_mode(const char *name) { char *val; @@ -193,7 +196,7 @@ static void _sg_cfg_cb__optimization_mode(const char *name, int pos) } /* callback of the cpu/model variable */ -static void _sg_cfg_cb__storage_mode(const char *name, int pos) +static void _sg_cfg_cb__storage_mode(const char *name) { char *val; @@ -212,7 +215,7 @@ static void _sg_cfg_cb__storage_mode(const char *name, int pos) } /* callback of the network_model variable */ -static void _sg_cfg_cb__network_model(const char *name, int pos) +static void _sg_cfg_cb__network_model(const char *name) { char *val; @@ -231,110 +234,106 @@ static void _sg_cfg_cb__network_model(const char *name, int pos) } /* callbacks of the network models values */ -static void _sg_cfg_cb__tcp_gamma(const char *name, int pos) +static void _sg_cfg_cb__tcp_gamma(const char *name) { sg_tcp_gamma = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__maxmin_precision(const char* name, int pos) +static void _sg_cfg_cb__maxmin_precision(const char* name) { sg_maxmin_precision = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__surf_precision(const char* name, int pos) +static void _sg_cfg_cb__surf_precision(const char* name) { sg_surf_precision = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__sender_gap(const char* name, int pos) +static void _sg_cfg_cb__sender_gap(const char* name) { sg_sender_gap = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__latency_factor(const char *name, int pos) +static void _sg_cfg_cb__latency_factor(const char *name) { sg_latency_factor = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__bandwidth_factor(const char *name, int pos) +static void _sg_cfg_cb__bandwidth_factor(const char *name) { sg_bandwidth_factor = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__weight_S(const char *name, int pos) +static void _sg_cfg_cb__weight_S(const char *name) { sg_weight_S_parameter = xbt_cfg_get_double(name); } #if HAVE_SMPI -/* callback of the mpi collectives */ -static void _sg_cfg_cb__coll(const char *category, +/* callback of the mpi collectives: simply check that this is a valid name. It will be picked up in smpi_global.cpp */ +static void _check_coll(const char *category, s_mpi_coll_description_t * table, - const char *name, int pos) + const char *name) { - char *val; - - xbt_assert(_sg_cfg_init_status < 2, - "Cannot change the model after the initialization"); + xbt_assert(_sg_cfg_init_status < 2, "Cannot change the collective algorithm after the initialization"); - val = xbt_cfg_get_string(name); + char *val = xbt_cfg_get_string(name); - if (!strcmp(val, "help")) { + if (val && !strcmp(val, "help")) { coll_help(category, table); sg_cfg_exit_early(); } - /* New Module missing */ find_coll_description(table, val, category); } -static void _sg_cfg_cb__coll_gather(const char *name, int pos){ - _sg_cfg_cb__coll("gather", mpi_coll_gather_description, name, pos); +static void _check_coll_gather(const char *name){ + _check_coll("gather", mpi_coll_gather_description, name); } -static void _sg_cfg_cb__coll_allgather(const char *name, int pos){ - _sg_cfg_cb__coll("allgather", mpi_coll_allgather_description, name, pos); +static void _check_coll_allgather(const char *name){ + _check_coll("allgather", mpi_coll_allgather_description, name); } -static void _sg_cfg_cb__coll_allgatherv(const char *name, int pos){ - _sg_cfg_cb__coll("allgatherv", mpi_coll_allgatherv_description, name, pos); +static void _check_coll_allgatherv(const char *name){ + _check_coll("allgatherv", mpi_coll_allgatherv_description, name); } -static void _sg_cfg_cb__coll_allreduce(const char *name, int pos) +static void _check_coll_allreduce(const char *name) { - _sg_cfg_cb__coll("allreduce", mpi_coll_allreduce_description, name, pos); + _check_coll("allreduce", mpi_coll_allreduce_description, name); } -static void _sg_cfg_cb__coll_alltoall(const char *name, int pos) +static void _check_coll_alltoall(const char *name) { - _sg_cfg_cb__coll("alltoall", mpi_coll_alltoall_description, name, pos); + _check_coll("alltoall", mpi_coll_alltoall_description, name); } -static void _sg_cfg_cb__coll_alltoallv(const char *name, int pos) +static void _check_coll_alltoallv(const char *name) { - _sg_cfg_cb__coll("alltoallv", mpi_coll_alltoallv_description, name, pos); + _check_coll("alltoallv", mpi_coll_alltoallv_description, name); } -static void _sg_cfg_cb__coll_bcast(const char *name, int pos) +static void _check_coll_bcast(const char *name) { - _sg_cfg_cb__coll("bcast", mpi_coll_bcast_description, name, pos); + _check_coll("bcast", mpi_coll_bcast_description, name); } -static void _sg_cfg_cb__coll_reduce(const char *name, int pos) +static void _check_coll_reduce(const char *name) { - _sg_cfg_cb__coll("reduce", mpi_coll_reduce_description, name, pos); + _check_coll("reduce", mpi_coll_reduce_description, name); } -static void _sg_cfg_cb__coll_reduce_scatter(const char *name, int pos){ - _sg_cfg_cb__coll("reduce_scatter", mpi_coll_reduce_scatter_description, name, pos); +static void _check_coll_reduce_scatter(const char *name){ + _check_coll("reduce_scatter", mpi_coll_reduce_scatter_description, name); } -static void _sg_cfg_cb__coll_scatter(const char *name, int pos){ - _sg_cfg_cb__coll("scatter", mpi_coll_scatter_description, name, pos); +static void _check_coll_scatter(const char *name){ + _check_coll("scatter", mpi_coll_scatter_description, name); } -static void _sg_cfg_cb__coll_barrier(const char *name, int pos){ - _sg_cfg_cb__coll("barrier", mpi_coll_barrier_description, name, pos); +static void _check_coll_barrier(const char *name){ + _check_coll("barrier", mpi_coll_barrier_description, name); } -static void _sg_cfg_cb__wtime_sleep(const char *name, int pos){ +static void _sg_cfg_cb__wtime_sleep(const char *name){ smpi_wtime_sleep = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__iprobe_sleep(const char *name, int pos){ +static void _sg_cfg_cb__iprobe_sleep(const char *name){ smpi_iprobe_sleep = xbt_cfg_get_double(name); } -static void _sg_cfg_cb__test_sleep(const char *name, int pos){ +static void _sg_cfg_cb__test_sleep(const char *name){ smpi_test_sleep = xbt_cfg_get_double(name); } @@ -343,10 +342,11 @@ static void _sg_cfg_cb__test_sleep(const char *name, int pos){ #endif /* callback of the inclusion path */ -static void _sg_cfg_cb__surf_path(const char *name, int pos) +static void _sg_cfg_cb__surf_path(const char *name) { - char *path = xbt_strdup(xbt_cfg_get_string_at(simgrid_config, name, pos)); - xbt_dynar_push(surf_path, &path); + char *path = xbt_strdup(xbt_cfg_get_string(name)); + if (path[0]) // ignore "" + xbt_dynar_push(surf_path, &path); } /* callback to decide if we want to use the model-checking */ @@ -357,58 +357,58 @@ extern int _sg_do_model_check; /* this variable lives in xbt_main until I find extern int _sg_do_model_check_record; #endif -static void _sg_cfg_cb_model_check_replay(const char *name, int pos) { +static void _sg_cfg_cb_model_check_replay(const char *name) { MC_record_path = xbt_cfg_get_string(name); } #if HAVE_MC -static void _sg_cfg_cb_model_check_record(const char *name, int pos) { +static void _sg_cfg_cb_model_check_record(const char *name) { _sg_do_model_check_record = xbt_cfg_get_boolean(name); } #endif extern int _sg_do_verbose_exit; -static void _sg_cfg_cb_verbose_exit(const char *name, int pos) +static void _sg_cfg_cb_verbose_exit(const char *name) { _sg_do_verbose_exit = xbt_cfg_get_boolean(name); } extern int _sg_do_clean_atexit; -static void _sg_cfg_cb_clean_atexit(const char *name, int pos) +static void _sg_cfg_cb_clean_atexit(const char *name) { _sg_do_clean_atexit = xbt_cfg_get_boolean(name); } -static void _sg_cfg_cb_context_factory(const char *name, int pos) +static void _sg_cfg_cb_context_factory(const char *name) { smx_context_factory_name = xbt_cfg_get_string(name); } -static void _sg_cfg_cb_context_stack_size(const char *name, int pos) +static void _sg_cfg_cb_context_stack_size(const char *name) { smx_context_stack_size_was_set = 1; smx_context_stack_size = xbt_cfg_get_int(name) * 1024; } -static void _sg_cfg_cb_context_guard_size(const char *name, int pos) +static void _sg_cfg_cb_context_guard_size(const char *name) { smx_context_guard_size_was_set = 1; smx_context_guard_size = xbt_cfg_get_int(name) * xbt_pagesize; } -static void _sg_cfg_cb_contexts_nthreads(const char *name, int pos) +static void _sg_cfg_cb_contexts_nthreads(const char *name) { SIMIX_context_set_nthreads(xbt_cfg_get_int(name)); } -static void _sg_cfg_cb_contexts_parallel_threshold(const char *name, int pos) +static void _sg_cfg_cb_contexts_parallel_threshold(const char *name) { SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(name)); } -static void _sg_cfg_cb_contexts_parallel_mode(const char *name, int pos) +static void _sg_cfg_cb_contexts_parallel_mode(const char *name) { const char* mode_name = xbt_cfg_get_string(name); if (!strcmp(mode_name, "posix")) { @@ -426,8 +426,7 @@ static void _sg_cfg_cb_contexts_parallel_mode(const char *name, int pos) } } -static void _sg_cfg_cb__surf_network_coordinates(const char *name, - int pos) +static void _sg_cfg_cb__surf_network_coordinates(const char *name) { static int already_set = 0; int val = xbt_cfg_get_boolean(name); @@ -442,8 +441,7 @@ static void _sg_cfg_cb__surf_network_coordinates(const char *name, xbt_die("Setting of whether to use coordinate cannot be disabled once set."); } -static void _sg_cfg_cb__surf_network_crosstraffic(const char *name, - int pos) +static void _sg_cfg_cb__surf_network_crosstraffic(const char *name) { sg_network_crosstraffic = xbt_cfg_get_boolean(name); } @@ -475,7 +473,7 @@ void sg_config_init(int *argc, char **argv) /* Plugins configuration */ describe_model(description, surf_plugin_description, "plugin", "The plugins"); - xbt_cfg_register(&simgrid_config, "plugin", description, xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__plugin); + xbt_cfg_register_string("plugin", description, nullptr, &_sg_cfg_cb__plugin); describe_model(description, surf_cpu_model_description, "model", "The model to use for the CPU"); xbt_cfg_register_string("cpu/model", description, "Cas01", &_sg_cfg_cb__cpu_model); @@ -521,8 +519,7 @@ void sg_config_init(int *argc, char **argv) NAN, _sg_cfg_cb__weight_S); /* real default for "network/weight_S" is set in network_*.cpp */ /* Inclusion path */ - xbt_cfg_register(&simgrid_config, "path", "Lookup path for inclusions in platform and deployment XML files", - xbt_cfgelm_string, 1, 0, _sg_cfg_cb__surf_path); + xbt_cfg_register_string("path", "Lookup path for inclusions in platform and deployment XML files", "", _sg_cfg_cb__surf_path); xbt_cfg_register_boolean("cpu/maxmin_selective_update", "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)", @@ -531,7 +528,7 @@ void sg_config_init(int *argc, char **argv) "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)", "no", NULL); /* Replay (this part is enabled even if MC it disabled) */ - xbt_cfg_register(&simgrid_config, "model-check/replay", "Enable replay mode with the given path", xbt_cfgelm_string, 0, 1, _sg_cfg_cb_model_check_replay); + xbt_cfg_register_string("model-check/replay", "Enable replay mode with the given path", nullptr, _sg_cfg_cb_model_check_replay); #if HAVE_MC /* do model-checking-record */ @@ -663,56 +660,23 @@ void sg_config_init(int *argc, char **argv) xbt_cfg_register_double("smpi/test", "Minimum time to inject inside a call to MPI_Test", 1e-4, _sg_cfg_cb__test_sleep); xbt_cfg_register_double("smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0, _sg_cfg_cb__wtime_sleep); - xbt_cfg_register_string("smpi/coll_selector", "Which collective selector to use", "default", NULL); - - xbt_cfg_register(&simgrid_config, "smpi/gather", - "Which collective to use for gather", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_gather); - - xbt_cfg_register(&simgrid_config, "smpi/allgather", - "Which collective to use for allgather", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allgather); - - xbt_cfg_register(&simgrid_config, "smpi/barrier", - "Which collective to use for barrier", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_barrier); - - xbt_cfg_register(&simgrid_config, "smpi/reduce_scatter", - "Which collective to use for reduce_scatter", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce_scatter); - - xbt_cfg_register(&simgrid_config, "smpi/scatter", - "Which collective to use for scatter", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_scatter); - - xbt_cfg_register(&simgrid_config, "smpi/allgatherv", - "Which collective to use for allgatherv", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allgatherv); - - xbt_cfg_register(&simgrid_config, "smpi/allreduce", - "Which collective to use for allreduce", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allreduce); - - xbt_cfg_register(&simgrid_config, "smpi/alltoall", - "Which collective to use for alltoall", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_alltoall); - - xbt_cfg_register(&simgrid_config, "smpi/alltoallv", - "Which collective to use for alltoallv", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_alltoallv); - - xbt_cfg_register(&simgrid_config, "smpi/bcast", - "Which collective to use for bcast", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_bcast); - - xbt_cfg_register(&simgrid_config, "smpi/reduce", - "Which collective to use for reduce", - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce); + xbt_cfg_register_string("smpi/coll_selector", "Which collective selector to use", "default", NULL); + xbt_cfg_register_string("smpi/gather", "Which collective to use for gather", nullptr, &_check_coll_gather); + xbt_cfg_register_string("smpi/allgather", "Which collective to use for allgather", nullptr, &_check_coll_allgather); + xbt_cfg_register_string("smpi/barrier", "Which collective to use for barrier", nullptr, &_check_coll_barrier); + xbt_cfg_register_string("smpi/reduce_scatter", "Which collective to use for reduce_scatter", nullptr, &_check_coll_reduce_scatter); + xbt_cfg_register_string("smpi/scatter", "Which collective to use for scatter", nullptr, &_check_coll_scatter); + xbt_cfg_register_string("smpi/allgatherv", "Which collective to use for allgatherv", nullptr, &_check_coll_allgatherv); + xbt_cfg_register_string("smpi/allreduce", "Which collective to use for allreduce", nullptr, &_check_coll_allreduce); + xbt_cfg_register_string("smpi/alltoall", "Which collective to use for alltoall", nullptr, &_check_coll_alltoall); + xbt_cfg_register_string("smpi/alltoallv", "Which collective to use for alltoallv", nullptr, &_check_coll_alltoallv); + xbt_cfg_register_string("smpi/bcast", "Which collective to use for bcast", nullptr, &_check_coll_bcast); + xbt_cfg_register_string("smpi/reduce", "Which collective to use for reduce", nullptr, &_check_coll_reduce); #endif // HAVE_SMPI xbt_cfg_register_boolean("exception/cutpath", "Whether to cut all path information from call traces, used e.g. in exceptions.", "no", NULL); - xbt_cfg_register_boolean("clean_atexit", "Whether to cleanup SimGrid (XBT,SIMIX,MSG) at exit. Disable it if your code segfaults at ending.", + xbt_cfg_register_boolean("clean_atexit", "Whether to cleanup SimGrid at exit. Disable it if your code segfaults at ending.", "yes", _sg_cfg_cb_clean_atexit); if (!surf_path) { @@ -724,7 +688,6 @@ void sg_config_init(int *argc, char **argv) xbt_cfg_setdefault_string("path", initial_path); } - xbt_cfg_check(simgrid_config); _sg_cfg_init_status = 1; sg_config_cmd_line(argc, argv); @@ -769,7 +732,3 @@ int sg_cfg_get_boolean(const char* name) return xbt_cfg_get_boolean(name); } -xbt_dynar_t sg_cfg_get_dynar(const char* name) -{ - return xbt_cfg_get_dynar(name); -}