From 86a08ab9c895a99c7efb4ee38db24c3541deb6bd Mon Sep 17 00:00:00 2001 From: mquinson Date: Fri, 26 Jun 2009 10:33:52 +0000 Subject: [PATCH 1/1] Sanitize the way surf options are declared: in surf_config not dupplicated in simix and simdag git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6362 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- ChangeLog | 9 +- include/xbt/config.h | 42 +++--- src/Makefile.am | 6 +- src/include/simix/simix.h | 1 - src/include/surf/surf.h | 31 ++++- src/msg/msg_config.c | 14 +- src/simdag/sd_global.c | 248 ++---------------------------------- src/simix/private.h | 10 +- src/simix/smx_config.c | 129 ------------------- src/simix/smx_environment.c | 80 ++---------- src/simix/smx_global.c | 102 +++------------ src/surf/cpu.c | 3 +- src/surf/surf.c | 9 +- src/surf/surf_config.c | 203 +++++++++++++++++++++++++++++ src/surf/surf_private.h | 5 + src/xbt/config.c | 25 ++-- 16 files changed, 338 insertions(+), 579 deletions(-) delete mode 100644 src/simix/smx_config.c create mode 100644 src/surf/surf_config.c diff --git a/ChangeLog b/ChangeLog index e79c503304..75614da404 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,10 @@ SimGrid (3.4-svn) unstable; urgency=high * Add SIMIX_process_set_name() to change the name of the current process in the log messages. * Store smx_hosts in a dict since we only retrieve them by name + * Move the configuration infrastructure to surf + + SIMDAG: + * Move the configuration infrastructure to surf XBT: * Also include strbuff from xbt.h public header @@ -51,7 +55,7 @@ SimGrid (3.4-svn) unstable; urgency=high This allows to do more with the given exception afterward. Users should call xbt_ex_free() themselves. - SMPI: + SMPI: * Massive internal cleanups: - Store internal structures on processes instead of hosts (allows to have more than one process per host, in addition of being more @@ -62,7 +66,8 @@ SimGrid (3.4-svn) unstable; urgency=high - Move queues from global tables to process data fields * Improve smpirun: - now accept -platform and -hostfile arguments - - Pass the right rank value to processes according on hostfile + - Pass the right rank value to processes according to the hostfile + * Compile the examples by default, and use them as regression tests Build Chain: * Do not require doxygen in maintainer mode diff --git a/include/xbt/config.h b/include/xbt/config.h index a4b1bf1b94..b2505611b8 100644 --- a/include/xbt/config.h +++ b/include/xbt/config.h @@ -12,6 +12,7 @@ #ifndef _XBT_CONFIG_H_ #define _XBT_CONFIG_H_ +#include #include "xbt/dynar.h" SG_BEGIN_DECL() @@ -19,31 +20,31 @@ SG_BEGIN_DECL() /** @addtogroup XBT_config * @brief Changing the configuration of SimGrid components (grounding feature) * - * All modules of the SimGrid toolkit can be configured with this API. - * User modules and libraries can also use these facilities to handle + * All modules of the SimGrid toolkit can be configured with this API. + * User modules and libraries can also use these facilities to handle * their own configuration. * * A configuration set contain several \e variables which have a unique name - * in the set and can take a given type of value. For example, it may - * contain a \a size variable, accepting \e int values. + * in the set and can take a given type of value. For example, it may + * contain a \a size variable, accepting \e int values. * * It is impossible to set a value to a variable which has not been registered before. * Usually, the module registers all the options it accepts in the configuration set, * during its initialization and user code then set and unset values. * - * The easiest way to register a variable is to use the xbt_str_register_str function, - * which accepts a string representation of the config element descriptor. The syntax + * The easiest way to register a variable is to use the xbt_str_register_str function, + * which accepts a string representation of the config element descriptor. The syntax * is the following: \verbatim :_to__\endverbatim * - * For example, size:1_to_1_int describes a variable called \e size which - * must take exactly one value, and the value being an integer. Set the maximum to 0 to + * For example, size:1_to_1_int describes a variable called \e size which + * must take exactly one value, and the value being an integer. Set the maximum to 0 to * disable the upper bound on data count. * * Another example could be outputfiles:0_to_10_string which describes a variable * called \e outputfiles and which can take between 0 and 10 strings as value. * * To some extend, configuration sets can be seen as typed hash structures. - * + * * \todo This great mechanism is not used in SimGrid yet... * * @@ -67,24 +68,24 @@ SG_BEGIN_DECL() * \skip dyn * \until cfg_free * - * All those functions throws mismatch_error if asked to deal with an + * All those functions throws mismatch_error if asked to deal with an * unregistered variable. * \skip myset * \until cfg_free - * + * */ /** @defgroup XBT_cfg_use User interface: changing values * @ingroup XBT_config * - * This is the only interface you should use unless you want to let your + * This is the only interface you should use unless you want to let your * own code become configurable with this. * - * If the variable accept at most one value, those functions replace the - * current value with the provided one. If max>1, the provided value is + * If the variable accept at most one value, those functions replace the + * current value with the provided one. If max>1, the provided value is * appended to the list. * * string values are strdup'ed before use, so you can (and should) free - * your copy + * your copy * * @{ */ @@ -163,13 +164,14 @@ XBT_PUBLIC(void) xbt_cfg_dump(const char *name, const char *indent, /** @defgroup XBT_cfg_register Registering stuff * @ingroup XBT_config * - * This how to add new variables to an existing configuration set. Use it to make your code + * This how to add new variables to an existing configuration set. Use it to make your code * configurable. * * @{ */ XBT_PUBLIC(void) xbt_cfg_register(xbt_cfg_t cfg, - const char *name, e_xbt_cfgelm_type_t type, + const char *name, const char *description, + e_xbt_cfgelm_type_t type, 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); @@ -181,11 +183,11 @@ XBT_PUBLIC(e_xbt_cfgelm_type_t) xbt_cfg_get_type(xbt_cfg_t cfg, /** @defgroup XBT_cfg_get Getting the stored values * @ingroup XBT_config * - * This is how to retrieve the values stored in the configuration set. This is only + * This is how to retrieve the values stored in the configuration set. This is only * intended to configurable code, naturally. * - * Note that those function return a pointer to the values actually stored - * in the set. Do not modify them unless you really know what you're doing. + * Note that those function return a pointer to the values actually stored + * in the set. Do not modify them unless you really know what you're doing. * Likewise, do not free the strings after use, they are not copy of the data, * but the data themselves. * diff --git a/src/Makefile.am b/src/Makefile.am index 5fd51a917f..a59dca355e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -169,11 +169,12 @@ XBT_SG_SRC = \ xbt/xbt_sg_time.c SURF_SRC= \ + surf/surf_config.c \ surf/maxmin.c \ - surf/fair_bottleneck.c \ + surf/fair_bottleneck.c \ surf/lagrange.c \ surf/trace_mgr.c \ - surf/random_mgr.c \ + surf/random_mgr.c \ surf/surf.c \ surf/surfxml_parse.c \ surf/cpu.c surf/network.c surf/network_constant.c surf/workstation.c \ @@ -200,7 +201,6 @@ CTX_SRC= xbt/xbt_context.c SIMIX_SRC= \ simix/smx_global.c \ simix/smx_deployment.c \ - simix/smx_config.c \ simix/smx_environment.c \ simix/smx_host.c \ simix/smx_process.c \ diff --git a/src/include/simix/simix.h b/src/include/simix/simix.h index 86e257fb75..eb8503f500 100644 --- a/src/include/simix/simix.h +++ b/src/include/simix/simix.h @@ -20,7 +20,6 @@ SG_BEGIN_DECL() /************************** Global ******************************************/ -XBT_PUBLIC(void) SIMIX_config(const char *name, va_list pa); XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv); XBT_PUBLIC(void) SIMIX_clean(void); XBT_PUBLIC(void) SIMIX_function_register(const char *name, diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 92b1c62da5..4cfc3b922f 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -13,6 +13,7 @@ #include "xbt/dict.h" #include "xbt/misc.h" #include "portable.h" +#include "xbt/config.h" SG_BEGIN_DECL() @@ -21,7 +22,7 @@ SG_BEGIN_DECL() /* Actions and models are higly connected structures... */ /** \brief Action datatype * \ingroup SURF_actions - * + * * An action is some working amount on a model. * It is represented as a cost, a priority, a duration and a state. * @@ -31,7 +32,7 @@ SG_BEGIN_DECL() /** \brief Model datatype * \ingroup SURF_models - * + * * Generic data structure for a model. The workstations, * the CPUs and the network links are examples of models. */ @@ -57,7 +58,7 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table, * * Never create s_surf_action_t by yourself ! The actions are created * on the fly when you call execute or communicate on a model. - * + * * \see e_surf_action_state_t */ typedef struct surf_action { @@ -172,7 +173,7 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table, /** \brief Model datatype * \ingroup SURF_models - * + * * Generic data structure for a model. The workstations, * the CPUs and the network links are examples of models. */ @@ -227,7 +228,7 @@ XBT_PUBLIC(void) surf_timer_model_init(const char *filename); /** \brief CPU model extension public * \ingroup SURF_models - * + * * Public functions specific to the CPU model. */ typedef struct surf_cpu_model_extension_public { @@ -392,7 +393,7 @@ XBT_PUBLIC(void) surf_network_model_init_Reno2(const char *filename); * \ingroup SURF_models * \param filename XML platform file name * - * This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent + * This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent * to the proportional fairness. * * Reference: @@ -414,7 +415,7 @@ XBT_PUBLIC(void) surf_network_model_init_Vegas(const char *filename); * * Reference: * - * [TAG03]. Corinne Touati, Eitan Altman, and Jerome Galtier. + * [TAG03]. Corinne Touati, Eitan Altman, and Jerome Galtier. * Semi-definite programming approach for bandwidth allocation and routing in networks. * Game Theory and Applications, 9:169-179, December 2003. Nova publisher. * @@ -558,6 +559,7 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list; /*******************************************/ /*** SURF Globals **************************/ /*******************************************/ +xbt_cfg_t _surf_cfg_set; /** \brief Initialize SURF * \ingroup SURF_simulation @@ -575,6 +577,21 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list; */ XBT_PUBLIC(void) surf_init(int *argc, char **argv); /* initialize common structures */ +/** \brief Initialize the used models. + * + * Must be called after the surf_init so that configuration infrastructure is created + * Must be called before parsing/creating the environment + * Must not be called within the initialization process so that the use get a chance to change the settings from + * its code between, say, MSG_init and MSG_create_environment using MSG_config + */ +XBT_PUBLIC(void) surf_config_models_setup(const char *platform_file); + +/** \brief create the elements of the models + * + * Must be called after parsing the platform file and before using any elements + */ +XBT_PUBLIC(void) surf_config_models_create_elms(void); + /** \brief Finish simulation initialization * \ingroup SURF_simulation * diff --git a/src/msg/msg_config.c b/src/msg/msg_config.c index 77afd4c39e..502a5c83a0 100644 --- a/src/msg/msg_config.c +++ b/src/msg/msg_config.c @@ -13,9 +13,9 @@ #include "simix/simix.h" /** \brief set a configuration variable - * + * * Currently existing configuation variable: - * - workstation_model (string): Model of workstation to use. + * - workstation_model (string): Model of workstation to use. * Possible values (defaults to "KCCFLN05"): * - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + support for parallel tasks * - "KCCFLN05": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file. @@ -23,7 +23,7 @@ * - "KCCFLN05_proportional": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file. Uses the proportional approahc as described in the Corine Touati's PhD Thesis. * - "KCCFLN05_Vegas": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file. Uses the fairness adapted to the TCP Vegas flow control. * - "KCCFLN05_Reno": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file. Uses the fairness adapted to the TCP Reno flow control. - * + * * Example: * MSG_config("workstation_model","KCCFLN05"); */ @@ -36,14 +36,8 @@ void MSG_config(const char *name, ...) "ERROR: Please call MSG_init() before using MSG_config()\n"); abort(); } - - - - /* xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set); */ va_start(pa, name); - - SIMIX_config(name, pa); - + xbt_cfg_set_vargs(_surf_cfg_set,name,pa); va_end(pa); return; } diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index a2caf4bf78..431dae51b6 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -21,179 +21,10 @@ SD_global_t sd_global = NULL; /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -static int _sd_init_status = 0; /* 0: beginning of time; - 1: pre-inited (cfg_set created); - 2: inited (running) */ -static xbt_cfg_t _sd_cfg_set = NULL; - -/* callback of the workstation_model variable */ -static void _sd_cfg_cb__workstation_model(const char *name, int pos) -{ - char *val; - - xbt_assert0(_sd_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_sd_cfg_set, name); - find_model_description(surf_workstation_model_description, val); -} - -/* callback of the cpu_model variable */ -static void _sd_cfg_cb__cpu_model(const char *name, int pos) -{ - char *val; - - xbt_assert0(_sd_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_sd_cfg_set, name); - find_model_description(surf_cpu_model_description, val); -} - -/* callback of the workstation_model variable */ -static void _sd_cfg_cb__network_model(const char *name, int pos) -{ - char *val; - - xbt_assert0(_sd_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_sd_cfg_set, name); - find_model_description(surf_network_model_description, val); -} - XBT_LOG_EXTERNAL_CATEGORY(sd_kernel); XBT_LOG_EXTERNAL_CATEGORY(sd_task); XBT_LOG_EXTERNAL_CATEGORY(sd_workstation); -/* create the config set and register what should be */ -static void sd_config_init(void) -{ - - if (_sd_init_status) - return; /* Already inited, nothing to do */ - - /* Connect our log channels: that must be done manually under windows */ - XBT_LOG_CONNECT(sd_kernel, sd); - XBT_LOG_CONNECT(sd_task, sd); - XBT_LOG_CONNECT(sd_workstation, sd); - - _sd_init_status = 1; - _sd_cfg_set = xbt_cfg_new(); - - xbt_cfg_register(_sd_cfg_set, - "workstation_model", xbt_cfgelm_string, 1, 1, - &_sd_cfg_cb__workstation_model, NULL); - - xbt_cfg_register(_sd_cfg_set, - "cpu_model", xbt_cfgelm_string, 1, 1, - &_sd_cfg_cb__cpu_model, NULL); - xbt_cfg_register(_sd_cfg_set, - "network_model", xbt_cfgelm_string, 1, 1, - &_sd_cfg_cb__network_model, NULL); - - xbt_cfg_set_string(_sd_cfg_set, "workstation_model", "ptask_L07"); -} - -static void sd_config_finalize(void) -{ - - if (!_sd_init_status) - return; /* Not initialized yet. Nothing to do */ - - xbt_cfg_free(&_sd_cfg_set); - _sd_init_status = 0; -} - -static void sd_config(const char *name, va_list pa) -{ - if (!_sd_init_status) { - sd_config_init(); - } - xbt_cfg_set_vargs(_sd_cfg_set, name, pa); -} - - -static void __sd_config_helper(const char *name, ...) -{ - va_list pa; - va_start(pa, name); - - sd_config(name, pa); - - va_end(pa); -} - -static void sd_cfg_control_set(const char *control_string) -{ - /* To split the string in commands, and the cursors */ - xbt_dynar_t set_strings; - char *str; - unsigned int cpt; - - if (!control_string) - return; - DEBUG1("Parse log settings '%s'", control_string); - - /* split the string, and remove empty entries */ - set_strings = xbt_str_split_quoted(control_string); - - if (xbt_dynar_length(set_strings) == 0) { /* vicious user! */ - xbt_dynar_free(&set_strings); - return; - } - /* Parse each entry and either use it right now (if the category was already - created), or store it for further use */ - xbt_dynar_foreach(set_strings, cpt, str) { - char *control_string, *control_string_sav, *name, *value; - - - control_string = control_string_sav = strdup(str); - control_string += strspn(control_string, " "); - name = control_string; - control_string += strcspn(str, ":="); - value = control_string; - *value = 0; - value++; - - xbt_assert1(strlen(name) != 0, "Invalid name for configuration: '%s'", - name); - xbt_assert1(strlen(value) != 0, - "Invalid value for configuration: '%s'", value); - INFO2("setting '%s' to '%s'", name, value); - - __sd_config_helper(name, value); - - free(control_string_sav); - } - xbt_dynar_free(&set_strings); -} - -static void sd_cfg_init(int *argc, char **argv) -{ - int i, j; - char *opt; - - for (i = 1; i < *argc; i++) { - if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) { - opt = strchr(argv[i], '='); - opt++; - - sd_cfg_control_set(opt); - DEBUG1("Did apply '%s' as config setting", opt); - /*remove this from argv */ - - for (j = i + 1; j < *argc; j++) { - argv[j - 1] = argv[j]; - } - - argv[j - 1] = NULL; - (*argc)--; - i--; /* compensate effect of next loop incrementation */ - } - } -} - /** * \brief Initialises SD internal data * @@ -211,6 +42,12 @@ void SD_init(int *argc, char **argv) xbt_assert0(!SD_INITIALISED(), "SD_init() already called"); + /* Connect our log channels: that must be done manually under windows */ + XBT_LOG_CONNECT(sd_kernel, sd); + XBT_LOG_CONNECT(sd_task, sd); + XBT_LOG_CONNECT(sd_workstation, sd); + + sd_global = xbt_new(s_SD_global_t, 1); sd_global->workstations = xbt_dict_new(); sd_global->workstation_count = 0; @@ -238,15 +75,15 @@ void SD_init(int *argc, char **argv) sd_global->task_number = 0; surf_init(argc, argv); - sd_cfg_init(argc, argv); + xbt_cfg_set_string(_surf_cfg_set, "workstation_model", "ptask_L07"); } /** * \brief Reinits the application part of the simulation (experimental feature) - * - * This function allows you to run several simulations on the same platform - * by resetting the part describing the application. - * + * + * This function allows you to run several simulations on the same platform + * by resetting the part describing the application. + * * @warning: this function is still experimental and not perfect. For example, * the simulation clock (and traces usage) is not reset. So, do not use it if * you use traces in your simulation, and do not use absolute timing after using it. @@ -304,7 +141,7 @@ void SD_application_reinit(void) * * \include simgrid.dtd * - * Here is a small example of such a platform: + * Here is a small example of such a platform: * * \include small_platform.xml */ @@ -314,73 +151,16 @@ void SD_create_environment(const char *platform_file) char *name = NULL; void *surf_workstation = NULL; void *surf_link = NULL; - char *workstation_model_name; - int workstation_id = -1; SD_CHECK_INIT_DONE(); DEBUG0("SD_create_environment"); - sd_config_init(); surf_timer_model_init(platform_file); - - workstation_model_name = - xbt_cfg_get_string(_sd_cfg_set, "workstation_model"); - - DEBUG1("Model : %s", workstation_model_name); - workstation_id = - find_model_description(surf_workstation_model_description, - workstation_model_name); - if (!strcmp(workstation_model_name, "compound")) { - xbt_ex_t e; - char *network_model_name = NULL; - char *cpu_model_name = NULL; - int network_id = -1; - int cpu_id = -1; - - TRY { - cpu_model_name = xbt_cfg_get_string(_sd_cfg_set, "cpu_model"); - } CATCH(e) { - if (e.category == bound_error) { - xbt_assert0(0, - "Set a cpu model to use with the 'compound' workstation model"); - xbt_ex_free(e); - } else { - RETHROW; - } - } - - TRY { - network_model_name = xbt_cfg_get_string(_sd_cfg_set, "network_model"); - } - CATCH(e) { - if (e.category == bound_error) { - xbt_assert0(0, - "Set a network model to use with the 'compound' workstation model"); - xbt_ex_free(e); - } else { - RETHROW; - } - } - - network_id = - find_model_description(surf_network_model_description, - network_model_name); - cpu_id = - find_model_description(surf_cpu_model_description, cpu_model_name); - - surf_cpu_model_description[cpu_id].model_init(platform_file); - surf_network_model_description[network_id].model_init(platform_file); - } - - DEBUG0("Call workstation_model_init"); - surf_workstation_model_description[workstation_id].model_init - (platform_file); + surf_config_models_setup(platform_file); parse_platform_file(platform_file); - _sd_init_status = 2; - /* now let's create the SD wrappers for workstations and links */ xbt_dict_foreach(workstation_set, cursor, name, surf_workstation) { __SD_workstation_create(surf_workstation, NULL); @@ -401,7 +181,7 @@ void SD_create_environment(const char *platform_file) * The simulation will be stopped when its time reaches \a how_long, * when a watch point is reached, or when no more task can be executed. * Then you can call SD_simulate() again. - * + * * \param how_long maximum duration of the simulation (a negative value means no time limit) * \return a NULL-terminated array of \ref SD_task_t whose state has changed. * \see SD_task_schedule(), SD_task_watch() diff --git a/src/simix/private.h b/src/simix/private.h index 655815b953..88655fe974 100644 --- a/src/simix/private.h +++ b/src/simix/private.h @@ -16,7 +16,6 @@ #include "xbt/swag.h" #include "xbt/dict.h" #include "xbt/context.h" -#include "xbt/config.h" #include "xbt/function_types.h" /******************************* Datatypes **********************************/ @@ -102,14 +101,7 @@ typedef struct s_smx_simdata_action { -/******************************* Configuration support **********************************/ - -void simix_config_init(void); /* create the config set, call this before use! */ -void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */ -extern int _simix_init_status; /* 0: beginning of time; - 1: pre-inited (cfg_set created); - 2: inited (running) */ -extern xbt_cfg_t _simix_cfg_set; +/******************************* Other **********************************/ #define SIMIX_CHECK_HOST() xbt_assert0(surf_workstation_model->extension_public-> \ diff --git a/src/simix/smx_config.c b/src/simix/smx_config.c deleted file mode 100644 index bb727bc1ca..0000000000 --- a/src/simix/smx_config.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $Id$ */ - -/* Copyright (c) 2007 Arnaud Legrand, Bruno Donassolo. - All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#include "private.h" -#include "xbt/sysdep.h" -#include "xbt/log.h" - -int _simix_init_status = 0; /* 0: beginning of time; - 1: pre-inited (cfg_set created); - 2: inited (running) */ -xbt_cfg_t _simix_cfg_set = NULL; - -/* callback of the workstation_model variable */ -static void _simix_cfg_cb__workstation_model(const char *name, int pos) -{ - char *val; - - xbt_assert0(_simix_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_simix_cfg_set, name); - /* New Module missing */ - - find_model_description(surf_workstation_model_description, val); -} - -/* callback of the cpu_model variable */ -static void _simix_cfg_cb__cpu_model(const char *name, int pos) -{ - char *val; - - xbt_assert0(_simix_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_simix_cfg_set, name); - /* New Module missing */ - find_model_description(surf_cpu_model_description, val); -} - -/* callback of the workstation_model variable */ -static void _simix_cfg_cb__network_model(const char *name, int pos) -{ - char *val; - - xbt_assert0(_simix_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_simix_cfg_set, name); - /* New Module missing */ - find_model_description(surf_network_model_description, val); -} - -XBT_LOG_EXTERNAL_CATEGORY(simix); -XBT_LOG_EXTERNAL_CATEGORY(simix_action); -XBT_LOG_EXTERNAL_CATEGORY(simix_deployment); -XBT_LOG_EXTERNAL_CATEGORY(simix_environment); -XBT_LOG_EXTERNAL_CATEGORY(simix_host); -XBT_LOG_EXTERNAL_CATEGORY(simix_kernel); -XBT_LOG_EXTERNAL_CATEGORY(simix_process); -XBT_LOG_EXTERNAL_CATEGORY(simix_synchro); - -/* create the config set and register what should be */ -void simix_config_init(void) -{ - - if (_simix_init_status) - return; /* Already inited, nothing to do */ - - /* Connect our log channels: that must be done manually under windows */ - XBT_LOG_CONNECT(simix_action, simix); - XBT_LOG_CONNECT(simix_deployment, simix); - XBT_LOG_CONNECT(simix_environment, simix); - XBT_LOG_CONNECT(simix_host, simix); - XBT_LOG_CONNECT(simix_kernel, simix); - XBT_LOG_CONNECT(simix_process, simix); - XBT_LOG_CONNECT(simix_synchro, simix); - - _simix_init_status = 1; - _simix_cfg_set = xbt_cfg_new(); - - xbt_cfg_register(_simix_cfg_set, - "workstation_model", xbt_cfgelm_string, 1, 1, - &_simix_cfg_cb__workstation_model, NULL); - - xbt_cfg_register(_simix_cfg_set, - "cpu_model", xbt_cfgelm_string, 1, 1, - &_simix_cfg_cb__cpu_model, NULL); - xbt_cfg_register(_simix_cfg_set, - "network_model", xbt_cfgelm_string, 1, 1, - &_simix_cfg_cb__network_model, NULL); - - xbt_cfg_set_string(_simix_cfg_set, "workstation_model", "CLM03"); -} - -void simix_config_finalize(void) -{ - - if (!_simix_init_status) - return; /* Not initialized yet. Nothing to do */ - - xbt_cfg_free(&_simix_cfg_set); - _simix_init_status = 0; -} - -/** \brief Set a configuration variable - * - * FIXME - - * Currently existing configuration variable: - * - workstation_model (string): Model of workstation to use. - * Possible values (defaults to "KCCFLN05"): - * - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + support for parallel tasks - * - "KCCFLN05": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file. - * - compound - * \param name Configuration variable name that will change. - * \param pa A va_list with the others parameters - */ -void SIMIX_config(const char *name, va_list pa) -{ - if (!_simix_init_status) { - simix_config_init(); - } - xbt_cfg_set_vargs(_simix_cfg_set, name, pa); -} diff --git a/src/simix/smx_environment.c b/src/simix/smx_environment.c index 507967e9db..979958d392 100644 --- a/src/simix/smx_environment.c +++ b/src/simix/smx_environment.c @@ -10,105 +10,47 @@ #include "xbt/sysdep.h" #include "xbt/log.h" #include "xbt/xbt_os_time.h" +#include "xbt/config.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix, "Logging specific to SIMIX (environment)"); /********************************* SIMIX **************************************/ -/** +/** * \brief A platform constructor. * * Creates a new platform, including hosts, links and the - * routing_table. - * \param file a filename of a xml description of a platform. This file + * routing_table. + * \param file a filename of a xml description of a platform. This file * follows this DTD : * * \include surfxml.dtd * - * Here is a small example of such a platform + * Here is a small example of such a platform * * \include small_platform.xml * */ void SIMIX_create_environment(const char *file) { - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = NULL; char *name = NULL; void *workstation = NULL; - char *workstation_model_name; - int workstation_id = -1; + double start, end; - simix_config_init(); /* make sure that our configuration set is created */ surf_timer_model_init(file); - - /* which model do you want today? */ - workstation_model_name = - xbt_cfg_get_string(_simix_cfg_set, "workstation_model"); - - DEBUG1("Model : %s", workstation_model_name); - workstation_id = - find_model_description(surf_workstation_model_description, - workstation_model_name); - if (!strcmp(workstation_model_name, "compound")) { - xbt_ex_t e; - char *network_model_name = NULL; - char *cpu_model_name = NULL; - int network_id = -1; - int cpu_id = -1; - - TRY { - cpu_model_name = xbt_cfg_get_string(_simix_cfg_set, "cpu_model"); - } CATCH(e) { - if (e.category == bound_error) { - xbt_assert0(0, - "Set a cpu model to use with the 'compound' workstation model"); - xbt_ex_free(e); - } else { - RETHROW; - } - } - - TRY { - network_model_name = - xbt_cfg_get_string(_simix_cfg_set, "network_model"); - } - CATCH(e) { - if (e.category == bound_error) { - xbt_assert0(0, - "Set a network model to use with the 'compound' workstation model"); - xbt_ex_free(e); - } else { - RETHROW; - } - } - - network_id = - find_model_description(surf_network_model_description, - network_model_name); - cpu_id = - find_model_description(surf_cpu_model_description, cpu_model_name); - - surf_cpu_model_description[cpu_id].model_init(file); - surf_network_model_description[network_id].model_init(file); - - - } - surf_workstation_model_description[workstation_id].model_init(file); - - start = xbt_os_time(); + surf_config_models_setup(file); parse_platform_file(file); + surf_config_models_create_elms(); + start = xbt_os_time(); - if (surf_workstation_model_description[workstation_id].create_ws != NULL) - surf_workstation_model_description[workstation_id].create_ws(); end = xbt_os_time(); DEBUG1("PARSE TIME: %lg", (end - start)); - _simix_init_status = 2; /* inited; don't change settings now */ - xbt_dict_foreach(workstation_set, cursor, name, workstation) { - __SIMIX_host_create(name, workstation, NULL); + __SIMIX_host_create(name, workstation, NULL); } return; diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index c7185685ce..9d261b165f 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -11,91 +11,18 @@ #include "xbt/log.h" #include "xbt/str.h" #include "xbt/ex.h" /* ex_backtrace_display */ +XBT_LOG_EXTERNAL_CATEGORY(simix); +XBT_LOG_EXTERNAL_CATEGORY(simix_action); +XBT_LOG_EXTERNAL_CATEGORY(simix_deployment); +XBT_LOG_EXTERNAL_CATEGORY(simix_environment); +XBT_LOG_EXTERNAL_CATEGORY(simix_host); +XBT_LOG_EXTERNAL_CATEGORY(simix_process); +XBT_LOG_EXTERNAL_CATEGORY(simix_synchro); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX (kernel)"); SIMIX_Global_t simix_global = NULL; -/********************************* SIMIX **************************************/ -static void __simix_config_helper(const char *name, ...) -{ - va_list pa; - va_start(pa, name); - - SIMIX_config(name, pa); - - va_end(pa); -} - -static void simix_cfg_control_set(const char *control_string) -{ - /* To split the string in commands, and the cursors */ - xbt_dynar_t set_strings; - char *str; - unsigned int cpt; - - if (!control_string) - return; - DEBUG1("Parse log settings '%s'", control_string); - - /* split the string, and remove empty entries */ - set_strings = xbt_str_split_quoted(control_string); - - if (xbt_dynar_length(set_strings) == 0) { /* vicious user! */ - xbt_dynar_free(&set_strings); - return; - } - /* Parse each entry and either use it right now (if the category was already - created), or store it for further use */ - xbt_dynar_foreach(set_strings, cpt, str) { - char *control_string, *control_string_sav, *name, *value; - - - control_string = control_string_sav = strdup(str); - control_string += strspn(control_string, " "); - name = control_string; - control_string += strcspn(str, ":="); - value = control_string; - *value = 0; - value++; - - xbt_assert1(strlen(name) != 0, "Invalid name for configuration: '%s'", - name); - xbt_assert1(strlen(value) != 0, - "Invalid value for configuration: '%s'", value); - INFO2("setting '%s' to '%s'", name, value); - - __simix_config_helper(name, value); - - free(control_string_sav); - } - xbt_dynar_free(&set_strings); -} - -static void simix_cfg_init(int *argc, char **argv) -{ - int i, j; - char *opt; - - for (i = 1; i < *argc; i++) { - if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) { - opt = strchr(argv[i], '='); - opt++; - - simix_cfg_control_set(opt); - DEBUG1("Did apply '%s' as config setting", opt); - /*remove this from argv */ - - for (j = i + 1; j < *argc; j++) { - argv[j - 1] = argv[j]; - } - - argv[j - 1] = NULL; - (*argc)--; - i--; /* compensate effect of next loop incrementation */ - } - } -} /* FIXME: Yeah, I'll do it in a portable maner one day [Mt] */ #include @@ -107,9 +34,10 @@ static void _XBT_CALL inthandler(int ignored) exit(1); } +/********************************* SIMIX **************************************/ /** - * \brief Initialize some SIMIX internal data. + * \brief Initialize SIMIX internal data. * * \param argc Argc * \param argv Argv @@ -119,8 +47,14 @@ void SIMIX_global_init(int *argc, char **argv) s_smx_process_t proc; if (!simix_global) { - surf_init(argc, argv); /* Initialize some common structures. Warning, it sets simix_global=NULL */ - simix_cfg_init(argc, argv); + /* Connect our log channels: that must be done manually under windows */ + XBT_LOG_CONNECT(simix_action, simix); + XBT_LOG_CONNECT(simix_deployment, simix); + XBT_LOG_CONNECT(simix_environment, simix); + XBT_LOG_CONNECT(simix_host, simix); + XBT_LOG_CONNECT(simix_kernel, simix); + XBT_LOG_CONNECT(simix_process, simix); + XBT_LOG_CONNECT(simix_synchro, simix); simix_global = xbt_new0(s_SIMIX_Global_t, 1); @@ -138,6 +72,7 @@ void SIMIX_global_init(int *argc, char **argv) /* Prepare to display some more info when dying on Ctrl-C pressing */ signal(SIGINT, inthandler); + surf_init(argc, argv); /* Initialize SURF structures */ } } @@ -296,7 +231,6 @@ void SIMIX_clean(void) xbt_swag_free(simix_global->process_to_run); xbt_swag_free(simix_global->process_list); xbt_dict_free(&(simix_global->registered_functions)); - simix_config_finalize(); free(simix_global); simix_global = NULL; diff --git a/src/surf/cpu.c b/src/surf/cpu.c index 2e44f44833..e2883b9e43 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -33,7 +33,6 @@ static cpu_Cas01_t cpu_new(char *name, double power_scale, cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1); xbt_assert1(!xbt_dict_get_or_null(cpu_set, name), "Host '%s' declared several times in the platform file", name); - cpu->model = (surf_model_t) surf_cpu_model; cpu->name = name; cpu->power_scale = power_scale; @@ -283,7 +282,7 @@ static surf_action_t execute(void *cpu, double size) action->generic_action.start = surf_get_clock(); action->generic_action.finish = -1.0; action->generic_action.model_type = (surf_model_t) surf_cpu_model; - action->suspended = 0; /* Should be useless because of the + action->suspended = 0; /* Should be useless because of the calloc but it seems to help valgrind... */ if (CPU->state_current == SURF_CPU_ON) diff --git a/src/surf/surf.c b/src/surf/surf.c index 564e4a06e7..a6fcd8db71 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -125,7 +125,7 @@ const char *surf_action_state_names[6] = { "SURF_ACTION_NOT_IN_THE_SYSTEM" }; - +/* Don't forget to update the option description in smx_config when you change this */ s_surf_model_description_t surf_network_model_description[] = { {"Constant", NULL, surf_network_model_init_Constant}, {"CM02", NULL, surf_network_model_init_CM02}, @@ -311,6 +311,8 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_network); XBT_LOG_EXTERNAL_CATEGORY(surf_parse); XBT_LOG_EXTERNAL_CATEGORY(surf_timer); XBT_LOG_EXTERNAL_CATEGORY(surf_workstation); +XBT_LOG_EXTERNAL_CATEGORY(surf_config); + #ifdef HAVE_SDP XBT_LOG_EXTERNAL_CATEGORY(surf_sdp_out); @@ -337,6 +339,7 @@ void surf_init(int *argc, char **argv) XBT_LOG_CONNECT(surf_parse, surf); XBT_LOG_CONNECT(surf_timer, surf); XBT_LOG_CONNECT(surf_workstation, surf); + XBT_LOG_CONNECT(surf_config, surf); #ifdef HAVE_SDP XBT_LOG_CONNECT(surf_sdp_out, surf); @@ -377,6 +380,8 @@ void surf_init(int *argc, char **argv) model_list = xbt_dynar_new(sizeof(surf_model_private_t), NULL); if (!history) history = tmgr_history_new(); + + surf_config_init(argc,argv); } static char *path_name = NULL; @@ -425,6 +430,8 @@ void surf_exit(void) unsigned int iter; surf_model_t model = NULL; + surf_config_finalize(); + xbt_dynar_foreach(model_list, iter, model) { model->common_private->finalize(); } diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c new file mode 100644 index 0000000000..5c32d96fcb --- /dev/null +++ b/src/surf/surf_config.c @@ -0,0 +1,203 @@ +/* $Id$ */ + +/* Copyright (c) 2009 The SimGrid team. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +/* surf_config: configuration infrastructure for the simulation world */ + +#include "xbt/config.h" +#include "xbt/str.h" +#include "surf/surf_private.h" + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config,surf,"About the configuration of surf (and the rest of the simulation)"); + +xbt_cfg_t _surf_cfg_set = NULL; + +int _surf_init_status = 0; /* 0: beginning of time; + 1: pre-inited (cfg_set created); + 2: inited (running) */ + +/* callback of the workstation_model variable */ +static void _surf_cfg_cb__workstation_model(const char *name, int pos) +{ + char *val; + + xbt_assert0(_surf_init_status < 2, + "Cannot change the model after the initialization"); + + val = xbt_cfg_get_string(_surf_cfg_set, name); + /* New Module missing */ + + find_model_description(surf_workstation_model_description, val); +} + +/* callback of the cpu_model variable */ +static void _surf_cfg_cb__cpu_model(const char *name, int pos) +{ + char *val; + + xbt_assert0(_surf_init_status < 2, + "Cannot change the model after the initialization"); + + val = xbt_cfg_get_string(_surf_cfg_set, name); + /* New Module missing */ + find_model_description(surf_cpu_model_description, val); +} + +/* callback of the workstation_model variable */ +static void _surf_cfg_cb__network_model(const char *name, int pos) +{ + char *val; + + xbt_assert0(_surf_init_status < 2, + "Cannot change the model after the initialization"); + + val = xbt_cfg_get_string(_surf_cfg_set, name); + /* New Module missing */ + find_model_description(surf_network_model_description, val); +} + +/* Parse the command line, looking for options */ +static void surf_config_cmd_line(int *argc,char **argv) +{ + int i, j; + char *opt; + + for (i = 1; i < *argc; i++) { + if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) { + opt = strchr(argv[i], '='); + opt++; + + xbt_cfg_set_parse(_surf_cfg_set,opt); + DEBUG1("Did apply '%s' as config setting", opt); + /*remove this from argv */ + + for (j = i + 1; j < *argc; j++) { + argv[j - 1] = argv[j]; + } + + argv[j - 1] = NULL; + (*argc)--; + i--; /* compensate effect of next loop incrementation */ + } + } +} + +/* create the config set, register what should be and parse the command line*/ +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(); + _surf_init_status = 1; + + char *description = xbt_malloc(1024), *p = description; + 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", description, xbt_cfgelm_string, 1, 1, + &_surf_cfg_cb__workstation_model, NULL); + + sprintf(description,"The model to use for the CPU. Possible values: "); + p = description; + 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", description, xbt_cfgelm_string, 1, 1, + &_surf_cfg_cb__cpu_model, NULL); + + sprintf(description,"The model to use for the network. Possible values: "); + p = description; + 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, + &_surf_cfg_cb__network_model, NULL); + + xbt_cfg_set_string(_surf_cfg_set, "workstation_model", "CLM03"); + + surf_config_cmd_line(argc,argv); + } +} +void surf_config_finalize(void) +{ + if (!_surf_init_status) + return; /* Not initialized yet. Nothing to do */ + + xbt_cfg_free(&_surf_cfg_set); + _surf_init_status = 0; +} + +void surf_config_models_setup(const char *platform_file){ + char *workstation_model_name; + int workstation_id = -1; + + workstation_model_name = + xbt_cfg_get_string(_surf_cfg_set, "workstation_model"); + + DEBUG1("Model : %s", workstation_model_name); + workstation_id = + find_model_description(surf_workstation_model_description, + workstation_model_name); + if (!strcmp(workstation_model_name, "compound")) { + xbt_ex_t e; + char *network_model_name = NULL; + char *cpu_model_name = NULL; + int network_id = -1; + int cpu_id = -1; + + TRY { + cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu_model"); + } CATCH(e) { + if (e.category == bound_error) { + xbt_assert0(0, + "Set a cpu model to use with the 'compound' workstation model"); + xbt_ex_free(e); + } else { + RETHROW; + } + } + + TRY { + network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network_model"); + } + CATCH(e) { + if (e.category == bound_error) { + xbt_assert0(0, + "Set a network model to use with the 'compound' workstation model"); + xbt_ex_free(e); + } else { + RETHROW; + } + } + + network_id = + find_model_description(surf_network_model_description, + network_model_name); + cpu_id = + find_model_description(surf_cpu_model_description, cpu_model_name); + + surf_cpu_model_description[cpu_id].model_init(platform_file); + surf_network_model_description[network_id].model_init(platform_file); + } + + DEBUG0("Call workstation_model_init"); + surf_workstation_model_description[workstation_id].model_init(platform_file); +} + +void surf_config_models_create_elms(void) { + char *workstation_model_name = xbt_cfg_get_string(_surf_cfg_set, "workstation_model"); + int workstation_id = + find_model_description(surf_workstation_model_description, + workstation_model_name); + if (surf_workstation_model_description[workstation_id].create_ws != NULL) + surf_workstation_model_description[workstation_id].create_ws(); +} diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 4d4193237d..3d742f6e0c 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -66,6 +66,11 @@ FILE *surf_fopen(const char *name, const char *mode); extern tmgr_history_t history; extern xbt_dynar_t surf_path; +void surf_config_init(int *argc,char **argv); +void surf_config_finalize(void); +void surf_config(const char *name, va_list pa); + + /* * Returns the initial path. On Windows the initial path is * the current directory for the current process in the other diff --git a/src/xbt/config.c b/src/xbt/config.c index d9a0166d31..72ad05ece4 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -28,6 +28,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support"); defend my thesis. */ typedef struct { + /* Description */ + const char *desc; + /* Allowed type of the variable */ e_xbt_cfgelm_type_t type; int min, max; @@ -83,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->type, variable->min, + xbt_cfg_register(*whereto, name, variable->desc, variable->type, variable->min, variable->max, variable->cb_set, variable->cb_rm); } } @@ -197,7 +200,7 @@ void xbt_cfgelm_free(void *data) void xbt_cfg_register(xbt_cfg_t cfg, - const char *name, e_xbt_cfgelm_type_t type, + const char *name, const char *desc, e_xbt_cfgelm_type_t type, int min, int max, xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm) { xbt_cfgelm_t res; @@ -214,9 +217,10 @@ xbt_cfg_register(xbt_cfg_t cfg, } res = xbt_new(s_xbt_cfgelm_t, 1); - DEBUG7("Register cfg elm %s (%d to %d %s (=%d) @%p in set %p)", - name, min, max, xbt_cfgelm_type_name[type], type, res, cfg); + 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); + res->desc = desc; res->type = type; res->min = min; res->max = max; @@ -271,6 +275,8 @@ void xbt_cfg_unregister(xbt_cfg_t cfg, const char *name) * The string may consist in several variable descriptions separated by a space. * Each of them must use the following syntax: \:\_to_\_\ * with type being one of 'string','int', 'peer' or 'double'. + * + * @fixme: this does not allow to set the description */ void xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry) @@ -309,7 +315,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, type, min, max, NULL, NULL); + xbt_cfg_register(cfg, entrycpy, NULL, type, min, max, NULL, NULL); free(entrycpy); /* strdup'ed by dict mechanism, but cannot be const */ } @@ -465,7 +471,7 @@ void xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...) * * \arg cfg config set to fill * \arg options a string containing the content to add to the config set. This - * is a '\\t',' ' or '\\n' separated list of variables. Each individual variable is + * is a '\\t',' ' or '\\n' or ',' separated list of variables. Each individual variable is * like "[name]:[value]" where [name] is the name of an already registred * variable, and [value] conforms to the data type under which this variable was * registred. @@ -506,7 +512,7 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) /* Pass the value */ while (option - name <= (len - 1) && *option != ' ' && *option != '\n' - && *option != '\t') { + && *option != '\t' && *option != ',') { DEBUG1("Take %c.", *option); option++; } @@ -544,7 +550,7 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) } *(val++) = '\0'; - DEBUG2("name='%s';val='%s'", name, val); + INFO2("Configuration change: Set '%s' to '%s'", name, val); TRY { variable = xbt_dict_get((xbt_dict_t) cfg, name); @@ -1150,12 +1156,15 @@ xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name, int pos, #include "xbt.h" #include "xbt/ex.h" +XBT_LOG_EXTERNAL_CATEGORY(xbt_cfg); + XBT_TEST_SUITE("config", "Configuration support"); 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"); -- 2.20.1