From 702ac78afa738128143f0b2a03bad8484001407c Mon Sep 17 00:00:00 2001 From: navarrop Date: Thu, 24 Mar 2011 10:36:09 +0000 Subject: [PATCH] Set level COORD_HOST_LEVEL and COORD_ASR_LEVEL if there are used. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9838 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- .../msg/masterslave/masterslave_vivaldi.tesh | 1 + examples/platforms/vivaldi.xml | 4 ++++ src/surf/surf.c | 4 ---- src/surf/surf_routing.c | 9 ++++++--- src/surf/surfxml_parse.c | 16 ++++++++++++++-- src/xbt/config.c | 13 +++++++++++++ 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/examples/msg/masterslave/masterslave_vivaldi.tesh b/examples/msg/masterslave/masterslave_vivaldi.tesh index bbca1545aa..a3c53640f8 100644 --- a/examples/msg/masterslave/masterslave_vivaldi.tesh +++ b/examples/msg/masterslave/masterslave_vivaldi.tesh @@ -5,6 +5,7 @@ p Testing a simple master/slave example application $ $SG_TEST_EXENV ./masterslave/masterslave_mailbox ${srcdir:=.}/../platforms/vivaldi.xml ${srcdir:=.}/masterslave/deployment_masterslave_vivaldi.xml --cfg=network/latency_factor:1.0 --cfg=network/bandwidth_factor:1.0 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/latency_factor' to '1.0' > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/bandwidth_factor' to '1.0' +> [0.000000] [surf_parse/INFO] Configuration change: Set 'coordinates' to 'yes' > [100030591:master:(1) 0.000000] [msg_test/INFO] Got 39 slaves and 20 tasks to process > [100030591:master:(1) 0.000000] [msg_test/INFO] Sending "Task_0" (of 20) to mailbox "slave-0" > [100030591:master:(1) 46.298715] [msg_test/INFO] Sending "Task_1" (of 20) to mailbox "slave-1" diff --git a/examples/platforms/vivaldi.xml b/examples/platforms/vivaldi.xml index 78b8e756f5..ef563ff7d8 100644 --- a/examples/platforms/vivaldi.xml +++ b/examples/platforms/vivaldi.xml @@ -1,6 +1,10 @@ + + + + diff --git a/src/surf/surf.c b/src/surf/surf.c index 8b25befd78..4b431467ee 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -298,10 +298,6 @@ void surf_init(int *argc, char **argv) SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free); - XBT_DEBUG("ADD COORD LEVEL"); - COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp); - COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp); - /* Connect our log channels: that must be done manually under windows */ XBT_LOG_CONNECT(surf_cpu, surf); XBT_LOG_CONNECT(surf_kernel, surf); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index a9f5a370cf..fd3d3e18e8 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -235,6 +235,7 @@ static void parse_S_host(const char *host_id, const char* coord) info->rc_type = SURF_NETWORK_ELEMENT_HOST; xbt_lib_set(host_lib,host_id,ROUTING_HOST_LEVEL,(void *) info); if (strcmp(coord,"")) { + if(!COORD_HOST_LEVEL) xbt_die("To use coordinates, you must set configuration 'coordinates' to 'yes'"); xbt_dynar_t ctn = xbt_str_split_str(coord, " "); xbt_dynar_shrink(ctn, 0); xbt_lib_set(host_lib,host_id,COORD_HOST_LEVEL,(void *) ctn); @@ -296,9 +297,10 @@ static void parse_S_router(const char *router_id) xbt_lib_set(as_router_lib,router_id,ROUTING_ASR_LEVEL,(void *) info); if (strcmp(A_surfxml_router_coordinates,"")) { - xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_router_coordinates, " "); - xbt_dynar_shrink(ctn, 0); - xbt_lib_set(as_router_lib,router_id,COORD_ASR_LEVEL,(void *) ctn); + if(!COORD_ASR_LEVEL) xbt_die("To use coordinates, you must set configuration 'coordinates' to 'yes'"); + xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_router_coordinates, " "); + xbt_dynar_shrink(ctn, 0); + xbt_lib_set(as_router_lib,router_id,COORD_ASR_LEVEL,(void *) ctn); } } @@ -564,6 +566,7 @@ static void parse_S_AS_XML(void) parse_S_AS(A_surfxml_AS_id, A_surfxml_AS_routing); if (strcmp(A_surfxml_AS_coordinates,"")) { + if(!COORD_ASR_LEVEL) xbt_die("To use coordinates, you must set configuration 'coordinates' to 'yes'"); XBT_DEBUG("%s coordinates : %s", A_surfxml_AS_id, A_surfxml_AS_coordinates); xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_AS_coordinates, " "); xbt_dynar_shrink(ctn, 0); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 49414140e6..a15bd377cf 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -483,8 +483,20 @@ void parse_properties(void) char *value = NULL; if (!current_property_set) current_property_set = xbt_dict_new(); // Maybe, it should be make a error - value = xbt_strdup(A_surfxml_prop_value); - xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free); + if(!strcmp(A_surfxml_prop_id,"coordinates")){ + if(!strcmp(A_surfxml_prop_value,"yes") && !COORD_HOST_LEVEL) + { + XBT_INFO("Configuration change: Set '%s' to '%s'", A_surfxml_prop_id, A_surfxml_prop_value); + COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp); + COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp); + } + if(strcmp(A_surfxml_prop_value,"yes")) + xbt_die("Setting XML prop coordinates must be \"yes\""); + } + else{ + value = xbt_strdup(A_surfxml_prop_value); + xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free); + } } /* Trace management functions */ diff --git a/src/xbt/config.c b/src/xbt/config.c index 5a4d0d5064..fc93278e78 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -18,6 +18,7 @@ #include "xbt/peer.h" #include "xbt/config.h" /* prototypes of this module */ +#include "surf/surf.h" /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support"); @@ -650,6 +651,18 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) } *(val++) = '\0'; + if (!strcmp(name,"coordinates")){ + if(!strcmp(val,"yes") && !COORD_HOST_LEVEL){ + XBT_INFO("Configuration change: Set '%s' to '%s'", name, val); + COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp); + COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp); + free(optionlist_cpy); + return; + } + if(strcmp(val,"yes")) + xbt_die("Setting CMD prop coordinates must be \"yes\""); + } + if (strcmp(name,"contexts/factory")) XBT_INFO("Configuration change: Set '%s' to '%s'", name, val); -- 2.20.1