Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Set level COORD_HOST_LEVEL and COORD_ASR_LEVEL if there are used.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:36:09 +0000 (10:36 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:36:09 +0000 (10:36 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9838 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/msg/masterslave/masterslave_vivaldi.tesh
examples/platforms/vivaldi.xml
src/surf/surf.c
src/surf/surf_routing.c
src/surf/surfxml_parse.c
src/xbt/config.c

index bbca154..a3c5364 100644 (file)
@@ -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"
index 78b8e75..ef563ff 100644 (file)
@@ -1,6 +1,10 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
+       
+<config id="General">
+       <prop id="coordinates" value="yes"></prop>
+</config>      
  <AS  id="AS0"  routing="Vivaldi">
        <host id="100030591" coordinates="25.5 9.4 1.4" power="1500000000.0" />
        <host id="100036570" coordinates="-12.7 -9.9 2.1" power="730000000.0" />
index 8b25bef..4b43146 100644 (file)
@@ -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);
index a9f5a37..fd3d3e1 100644 (file)
@@ -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);
index 4941414..a15bd37 100644 (file)
@@ -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 */
index 5a4d0d5..fc93278 100644 (file)
@@ -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);