From: Paul Bédaride Date: Mon, 17 Dec 2012 10:04:19 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_9_rc1~86^2~110 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7d9a2608433e246294b7c4b339371fd4d3530ba6?hp=3ee5e2ac47abb878c628539714f57dbb4898032b Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 170a986334..6252c8bd24 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -4,6 +4,7 @@ set(EXTRA_DIST src/include/mc/datatypes.h src/include/mc/mc.h src/include/simgrid/platf_interface.h + src/include/simgrid/sg_config.h src/include/surf/datatypes.h src/include/surf/maxmin.h src/include/surf/random_mgr.h @@ -311,6 +312,7 @@ set(LUA_SRC ) set(TRACING_SRC + src/simgrid/sg_config.c src/instr/instr_config.c src/instr/instr_interface.c src/instr/instr_msg_process.c diff --git a/include/simgrid/modelchecker.h b/include/simgrid/modelchecker.h index d5f8bca700..ae58a10401 100644 --- a/include/simgrid/modelchecker.h +++ b/include/simgrid/modelchecker.h @@ -14,9 +14,9 @@ #ifdef HAVE_MC -extern int _surf_do_model_check; /* please don't use directly: we inline MC_is_active, but that's what you should use */ +extern int _sg_do_model_check; /* please don't use directly: we inline MC_is_active, but that's what you should use */ -#define MC_is_active() _surf_do_model_check +#define MC_is_active() _sg_do_model_check XBT_PUBLIC(void) MC_assert(int); XBT_PUBLIC(int) MC_random(int min, int max); diff --git a/src/include/simgrid/sg_config.h b/src/include/simgrid/sg_config.h new file mode 100644 index 0000000000..bd61488975 --- /dev/null +++ b/src/include/simgrid/sg_config.h @@ -0,0 +1,15 @@ + +#include "xbt/config.h" + +/*******************************************/ +/*** Config Globals **************************/ +/*******************************************/ +XBT_PUBLIC_DATA(xbt_cfg_t) _sg_cfg_set; +XBT_PUBLIC(int) sg_cfg_get_int(const char* name); +XBT_PUBLIC(double) sg_cfg_get_double(const char* name); +XBT_PUBLIC(char*) sg_cfg_get_string(const char* name); +XBT_PUBLIC(void) sg_cfg_get_peer(const char *name, char **peer, int *port); +XBT_PUBLIC(xbt_dynar_t) sg_cfg_get_dynar(const char* name); + +void sg_config_init(int *argc, char **argv); +void sg_config_finalize(void); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index f5de0740f2..26c43930d3 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -672,12 +672,6 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list; /*******************************************/ /*** SURF Globals **************************/ /*******************************************/ -XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set; -XBT_PUBLIC(int) surf_cfg_get_int(const char* name); -XBT_PUBLIC(double) surf_cfg_get_double(const char* name); -XBT_PUBLIC(char*) surf_cfg_get_string(const char* name); -XBT_PUBLIC(void) surf_cfg_get_peer(const char *name, char **peer, int *port); -XBT_PUBLIC(xbt_dynar_t) surf_cfg_get_dynar(const char* name); /** \ingroup SURF_simulation * \brief Initialize SURF diff --git a/src/instr/instr_config.c b/src/instr/instr_config.c index 06f2fb6ae5..9da8976b8b 100644 --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "instr/instr_private.h" +#include "simgrid/sg_config.h" #ifdef HAVE_TRACING @@ -49,19 +50,19 @@ static int trace_active = 0; static void TRACE_getopts(void) { - trace_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING); - trace_platform = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_PLATFORM); - trace_platform_topology = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_TOPOLOGY); - trace_smpi_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI); - trace_smpi_grouped = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI_GROUP); - trace_smpi_computing = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI_COMPUTING); - trace_categorized = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_CATEGORIZED); - trace_uncategorized = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_UNCATEGORIZED); - trace_msg_process_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_PROCESS); - trace_buffer = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_BUFFER); - trace_onelink_only = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_ONELINK_ONLY); - trace_disable_destroy = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_DISABLE_DESTROY); - trace_basic = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_BASIC); + trace_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING); + trace_platform = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_PLATFORM); + trace_platform_topology = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_TOPOLOGY); + trace_smpi_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI); + trace_smpi_grouped = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_GROUP); + trace_smpi_computing = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_COMPUTING); + trace_categorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_CATEGORIZED); + trace_uncategorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_UNCATEGORIZED); + trace_msg_process_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_PROCESS); + trace_buffer = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BUFFER); + trace_onelink_only = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_ONELINK_ONLY); + trace_disable_destroy = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY); + trace_basic = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BASIC); } int TRACE_start() @@ -214,153 +215,153 @@ int TRACE_basic (void) char *TRACE_get_comment (void) { - return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_COMMENT); + return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_COMMENT); } char *TRACE_get_comment_file (void) { - return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_COMMENT_FILE); + return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_COMMENT_FILE); } char *TRACE_get_filename(void) { - return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME); + return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_FILENAME); } char *TRACE_get_viva_uncat_conf (void) { - return xbt_cfg_get_string(_surf_cfg_set, OPT_VIVA_UNCAT_CONF); + return xbt_cfg_get_string(_sg_cfg_set, OPT_VIVA_UNCAT_CONF); } char *TRACE_get_viva_cat_conf (void) { - return xbt_cfg_get_string(_surf_cfg_set, OPT_VIVA_CAT_CONF); + return xbt_cfg_get_string(_sg_cfg_set, OPT_VIVA_CAT_CONF); } void TRACE_global_init(int *argc, char **argv) { /* name of the tracefile */ char *default_tracing_filename = xbt_strdup("simgrid.trace"); - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_FILENAME, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_FILENAME, "Trace file created by the instrumented SimGrid.", xbt_cfgelm_string, &default_tracing_filename, 1, 1, NULL, NULL); /* tracing */ int default_tracing = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING, "Enable Tracing.", xbt_cfgelm_int, &default_tracing, 0, 1, NULL, NULL); /* register platform in the trace */ int default_tracing_platform = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_PLATFORM, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_PLATFORM, "Register the platform in the trace as a hierarchy.", xbt_cfgelm_int, &default_tracing_platform, 0, 1, NULL, NULL); /* register platform in the trace */ int default_tracing_platform_topology = 1; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_TOPOLOGY, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_TOPOLOGY, "Register the platform topology in the trace as a graph.", xbt_cfgelm_int, &default_tracing_platform_topology, 0, 1, NULL, NULL); /* smpi */ int default_tracing_smpi = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_SMPI, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI, "Tracing of the SMPI interface.", xbt_cfgelm_int, &default_tracing_smpi, 0, 1, NULL, NULL); /* smpi grouped */ int default_tracing_smpi_grouped = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_SMPI_GROUP, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_GROUP, "Group MPI processes by host.", xbt_cfgelm_int, &default_tracing_smpi_grouped, 0, 1, NULL, NULL); /* smpi computing */ int default_tracing_smpi_computing = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_SMPI_COMPUTING, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_COMPUTING, "Generate states for timing out of SMPI parts of the application", xbt_cfgelm_int, &default_tracing_smpi_computing, 0, 1, NULL, NULL); /* tracing categorized resource utilization traces */ int default_tracing_categorized = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_CATEGORIZED, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_CATEGORIZED, "Tracing categorized resource utilization of hosts and links.", xbt_cfgelm_int, &default_tracing_categorized, 0, 1, NULL, NULL); /* tracing uncategorized resource utilization */ int default_tracing_uncategorized = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_UNCATEGORIZED, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_UNCATEGORIZED, "Tracing uncategorized resource utilization of hosts and links.", xbt_cfgelm_int, &default_tracing_uncategorized, 0, 1, NULL, NULL); /* msg process */ int default_tracing_msg_process = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_PROCESS, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_PROCESS, "Tracing of MSG process behavior.", xbt_cfgelm_int, &default_tracing_msg_process, 0, 1, NULL, NULL); /* tracing buffer */ int default_buffer = 1; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_BUFFER, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BUFFER, "Buffer trace events to put them in temporal order.", xbt_cfgelm_int, &default_buffer, 0, 1, NULL, NULL); /* tracing one link only */ int default_onelink_only = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_ONELINK_ONLY, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_ONELINK_ONLY, "Use only routes with one link to trace platform.", xbt_cfgelm_int, &default_onelink_only, 0, 1, NULL, NULL); /* disable destroy */ int default_disable_destroy = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_DISABLE_DESTROY, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY, "Disable platform containers destruction.", xbt_cfgelm_int, &default_disable_destroy, 0, 1, NULL, NULL); /* basic -- Avoid extended events (impoverished trace file) */ int default_basic = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_BASIC, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BASIC, "Avoid extended events (impoverished trace file).", xbt_cfgelm_int, &default_basic, 0, 1, NULL, NULL); /* comment */ char *default_tracing_comment = xbt_strdup (""); - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_COMMENT, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_COMMENT, "Comment to be added on the top of the trace file.", xbt_cfgelm_string, &default_tracing_comment, 1, 1, NULL, NULL); /* comment_file */ char *default_tracing_comment_file = xbt_strdup (""); - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_COMMENT_FILE, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_COMMENT_FILE, "The contents of the file are added to the top of the trace file as comment.", xbt_cfgelm_string, &default_tracing_comment_file, 1, 1, NULL, NULL); /* Viva graph configuration for uncategorized tracing */ char *default_viva_uncat_conf_file = xbt_strdup (""); - xbt_cfg_register(&_surf_cfg_set, OPT_VIVA_UNCAT_CONF, + xbt_cfg_register(&_sg_cfg_set, OPT_VIVA_UNCAT_CONF, "Viva Graph configuration file for uncategorized resource utilization traces.", xbt_cfgelm_string, &default_viva_uncat_conf_file, 1, 1, NULL, NULL); /* Viva graph configuration for uncategorized tracing */ char *default_viva_cat_conf_file = xbt_strdup (""); - xbt_cfg_register(&_surf_cfg_set, OPT_VIVA_CAT_CONF, + xbt_cfg_register(&_sg_cfg_set, OPT_VIVA_CAT_CONF, "Viva Graph configuration file for categorized resource utilization traces.", xbt_cfgelm_string, &default_viva_cat_conf_file, 1, 1, NULL, NULL); diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index 8289f35484..f3555063f0 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -24,12 +24,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc, e_mc_reduce_t mc_reduce_kind=e_mc_reduce_unset; -extern int _surf_init_status; +extern int _sg_init_status; void _mc_cfg_cb_reduce(const char *name, int pos) { - if (_surf_init_status && !_surf_do_model_check) { + if (_sg_init_status && !_sg_do_model_check) { xbt_die("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); } - char *val= xbt_cfg_get_string(_surf_cfg_set, name); + char *val= xbt_cfg_get_string(_sg_cfg_set, name); if (!strcasecmp(val,"none")) { mc_reduce_kind = e_mc_reduce_none; } else if (!strcasecmp(val,"dpor")) { @@ -40,37 +40,37 @@ void _mc_cfg_cb_reduce(const char *name, int pos) { } void _mc_cfg_cb_checkpoint(const char *name, int pos) { - if (_surf_init_status && !_surf_do_model_check) { + if (_sg_init_status && !_sg_do_model_check) { xbt_die("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); } - _surf_mc_checkpoint = xbt_cfg_get_int(_surf_cfg_set, name); + _surf_mc_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name); } void _mc_cfg_cb_property(const char *name, int pos) { - if (_surf_init_status && !_surf_do_model_check) { + if (_sg_init_status && !_sg_do_model_check) { xbt_die("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); } - _surf_mc_property_file= xbt_cfg_get_string(_surf_cfg_set, name); + _surf_mc_property_file= xbt_cfg_get_string(_sg_cfg_set, name); } void _mc_cfg_cb_timeout(const char *name, int pos) { - if (_surf_init_status && !_surf_do_model_check) { + if (_sg_init_status && !_sg_do_model_check) { xbt_die("You are specifying a value to enable/disable timeout for wait requests after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); } - _surf_mc_timeout= xbt_cfg_get_int(_surf_cfg_set, name); + _surf_mc_timeout= xbt_cfg_get_int(_sg_cfg_set, name); } void _mc_cfg_cb_max_depth(const char *name, int pos) { - if (_surf_init_status && !_surf_do_model_check) { + if (_sg_init_status && !_sg_do_model_check) { xbt_die("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); } - _surf_mc_max_depth= xbt_cfg_get_int(_surf_cfg_set, name); + _surf_mc_max_depth= xbt_cfg_get_int(_sg_cfg_set, name); } void _mc_cfg_cb_visited(const char *name, int pos) { - if (_surf_init_status && !_surf_do_model_check) { + if (_sg_init_status && !_sg_do_model_check) { xbt_die("You are specifying a number of stored visited states after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry."); } - _surf_mc_visited= xbt_cfg_get_int(_surf_cfg_set, name); + _surf_mc_visited= xbt_cfg_get_int(_sg_cfg_set, name); } diff --git a/src/msg/msg_config.c b/src/msg/msg_config.c index fbbafb0a1d..e45bb5f393 100644 --- a/src/msg/msg_config.c +++ b/src/msg/msg_config.c @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "msg_private.h" +#include "simgrid/sg_config.h" #include "xbt/sysdep.h" #include "xbt/log.h" @@ -25,7 +26,7 @@ void MSG_config(const char *name, ...) xbt_abort(); } va_start(pa, name); - xbt_cfg_set_vargs(_surf_cfg_set, name, pa); + xbt_cfg_set_vargs(_sg_cfg_set, name, pa); va_end(pa); return; } diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index 2294740e6c..d979db37be 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -8,6 +8,7 @@ #include "xbt/sysdep.h" #include "xbt/dynar.h" #include "surf/surf.h" +#include "simgrid/sg_config.h" #include "xbt/ex.h" #include "xbt/log.h" #include "xbt/str.h" @@ -80,7 +81,7 @@ void SD_init(int *argc, char **argv) surf_init(argc, argv); - xbt_cfg_setdefault_string(_surf_cfg_set, "workstation/model", + xbt_cfg_setdefault_string(_sg_cfg_set, "workstation/model", "ptask_L07"); #ifdef HAVE_TRACING diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c new file mode 100644 index 0000000000..c39e34efbf --- /dev/null +++ b/src/simgrid/sg_config.c @@ -0,0 +1,810 @@ +/* Copyright (c) 2009, 2010. 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. */ + +/* sg_config: configuration infrastructure for the simulation world */ + +#include "xbt/misc.h" +#include "xbt/config.h" +#include "xbt/log.h" +#include "xbt/mallocator.h" +#include "xbt/str.h" +#include "surf/surf_private.h" +#include "surf/surf_routing.h" /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */ +#include "simgrid/simix.h" +#include "simgrid/sg_config.h" +#include "mc/mc.h" + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, + "About the configuration of simgrid"); + +xbt_cfg_t _sg_cfg_set = NULL; + +int _sg_do_model_check = 0; +int _surf_mc_checkpoint=0; +char* _surf_mc_property_file=NULL; +int _surf_mc_timeout=0; +int _surf_mc_max_depth=1000; +int _surf_mc_visited=0; + +int _sg_init_status = 0; /* 0: beginning of time (config cannot be changed yet); + 1: initialized: cfg_set created (config can now be changed); + 2: configured: command line parsed and config part of platform file was integrated also, platform construction ongoing or done. + (Config cannot be changed anymore!) */ + +/* Parse the command line, looking for options */ +static void sg_config_cmd_line(int *argc, char **argv) +{ + int shall_exit = 0; + int i, j; + char *opt; + + for (j = i = 1; i < *argc; i++) { + if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) { + opt = strchr(argv[i], '='); + opt++; + + xbt_cfg_set_parse(_sg_cfg_set, opt); + XBT_DEBUG("Did apply '%s' as config setting", opt); + } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) { + printf + ("Description of the configuration accepted by this simulator:\n"); + xbt_cfg_help(_sg_cfg_set); + printf( +"\n" +"Each of these configurations can be used by adding\n" +" --cfg=