Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in the parsing
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 26 Mar 2016 23:09:54 +0000 (00:09 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 26 Mar 2016 23:26:27 +0000 (00:26 +0100)
- no need for xml cbarg initializer as we memset(0) the cbargs
- prepare to factorize host name creation between cluster and cabinet

src/bindings/lua/lua_platf.cpp
src/simix/smx_deployment.cpp
src/surf/AsCluster.cpp
src/surf/AsClusterFatTree.cpp
src/surf/AsClusterTorus.cpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index c20e7c4..d180552 100644 (file)
@@ -530,10 +530,9 @@ int console_AS_open(lua_State *L) {
  else if(!strcmp(mode,"none")) mode_int = A_surfxml_AS_routing_None;
  else xbt_die("Don't have the model name '%s'",mode);
 
- s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ s_sg_platf_AS_cbarg_t AS;
  AS.id = id;
  AS.routing = mode_int;
-
  sg_platf_new_AS_begin(&AS);
 
  return 0;
index 08a8727..7ab2788 100644 (file)
@@ -114,7 +114,8 @@ void SIMIX_process_set_function(const char *process_host,
                                 double process_start_time,
                                 double process_kill_time)
 {
-  s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
+  s_sg_platf_process_cbarg_t process;
+  memset(&process,0,sizeof(process));
 
   sg_host_t host = sg_host_by_name(process_host);
   if (!host)
@@ -139,6 +140,7 @@ void SIMIX_process_set_function(const char *process_host,
   process.host = process_host;
   process.kill_time = process_kill_time;
   process.start_time = process_start_time;
+  process.on_failure = SURF_PROCESS_ON_FAILURE_DIE;
 
   sg_platf_new_process(&process);
 }
index b2b9c45..8fe7144 100644 (file)
@@ -137,10 +137,10 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 }
 
 void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int , int position){
-  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
   s_surf_parsing_link_up_down_t info;
   char* link_id = bprintf("%s_link_%d", cluster->id, id);
 
+  s_sg_platf_link_cbarg_t link;
   memset(&link, 0, sizeof(link));
   link.id = link_id;
   link.bandwidth = cluster->bw;
@@ -150,14 +150,13 @@ void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id,
 
   if (link.policy == SURF_LINK_FULLDUPLEX) {
     char *tmp_link = bprintf("%s_UP", link_id);
-    info.link_up = sg_link_by_name(tmp_link);
+    info.link_up = Link::byName(tmp_link);
     xbt_free(tmp_link);
     tmp_link = bprintf("%s_DOWN", link_id);
-    info.link_down = sg_link_by_name(tmp_link);
+    info.link_down = Link::byName(tmp_link);
     xbt_free(tmp_link);
   } else {
-    info.link_up = sg_link_by_name(link_id);
-    info.link_down = info.link_up;
+    info.link_up = info.link_down = Link::byName(link_id);
   }
   xbt_dynar_set(privateLinks_, position, &info);
   xbt_free(link_id);
index 7dc11a2..16f5787 100644 (file)
@@ -470,7 +470,7 @@ void AsClusterFatTree::generateDotFile(const std::string& filename) const {
 FatTreeNode::FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level,
                          int position) : id(id), level(level),
                                          position(position) {
-  s_sg_platf_link_cbarg_t linkTemplate = SG_PLATF_LINK_INITIALIZER;
+  s_sg_platf_link_cbarg_t linkTemplate;
   if(cluster->limiter_link) {
     memset(&linkTemplate, 0, sizeof(linkTemplate));
     linkTemplate.bandwidth = cluster->limiter_link;
@@ -498,13 +498,12 @@ FatTreeLink::FatTreeLink(sg_platf_cluster_cbarg_t cluster,
                          FatTreeNode *upNode) : upNode(upNode),
                                                 downNode(downNode) {
   static int uniqueId = 0;
-  s_sg_platf_link_cbarg_t linkTemplate = SG_PLATF_LINK_INITIALIZER;
+  s_sg_platf_link_cbarg_t linkTemplate;
   memset(&linkTemplate, 0, sizeof(linkTemplate));
   linkTemplate.bandwidth = cluster->bw;
   linkTemplate.latency = cluster->lat;
   linkTemplate.policy = cluster->sharing_policy; // sthg to do with that ?
-  linkTemplate.id = bprintf("link_from_%d_to_%d_%d", downNode->id, upNode->id,
-                            uniqueId);
+  linkTemplate.id = bprintf("link_from_%d_to_%d_%d", downNode->id, upNode->id, uniqueId);
   sg_platf_new_link(&linkTemplate);
   Link* link;
   std::string tmpID;
index be1b0c5..223c068 100644 (file)
@@ -34,7 +34,6 @@ namespace simgrid {
     }
 
     void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) {
-      s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
       char *link_id;
       unsigned int j = 0;
       /**
@@ -48,6 +47,7 @@ namespace simgrid {
           dim_product = 1;      // Needed to calculate the next neighbour_id
       for (j = 0; j < xbt_dynar_length(dimensions_); j++) {
 
+        s_sg_platf_link_cbarg_t link;
         memset(&link, 0, sizeof(link));
         current_dimension = xbt_dynar_get_as(dimensions_, j, int);
         neighbour_rank_id =
index ccdd457..3eb3105 100644 (file)
@@ -48,6 +48,43 @@ simgrid::xbt::signal<void(void)> on_postparse;
 
 static int surf_parse_models_setup_already_called = 0;
 
+/* Build the list of hostnames in a cluster or in a cabinet */
+static std::vector<char*> *makeHostnames(const char*prefix, const char*radicals, const char *suffix){
+  std::vector<char*> *hostnames = new std::vector<char*>();
+  char *groups;
+  unsigned int iter;
+
+  //Make all hosts
+  xbt_dynar_t radical_elements = xbt_str_split(radicals, ",");
+  xbt_dynar_foreach(radical_elements, iter, groups) {
+
+    xbt_dynar_t radical_ends = xbt_str_split(groups, "-");
+    int start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+    int end=0;
+
+    switch (xbt_dynar_length(radical_ends)) {
+    case 1:
+      end = start;
+      break;
+    case 2:
+      end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
+      break;
+    default:
+      surf_parse_error("Malformed radical: %s", groups);
+      break;
+    }
+
+    for (int i = start; i <= end; i++)
+      hostnames->push_back( bprintf("%s%d%s",prefix,i,suffix) );
+
+    xbt_dynar_free(&radical_ends);
+  }
+  xbt_dynar_free(&radical_elements);
+
+  return hostnames;
+}
+
+
 /** The current AS in the parsing */
 static simgrid::surf::AsImpl *current_routing = NULL;
 static simgrid::surf::AsImpl* routing_get_current()
@@ -197,8 +234,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
   xbt_dict_t patterns = NULL;
   int rankId=0;
 
-  s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
-  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+  s_sg_platf_link_cbarg_t link;
 
   unsigned int iter;
 
@@ -212,7 +248,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
 
   /* Parse the topology attributes.
    * Nothing to do in a vanilla cluster, but that's another story for torus and flat_trees */
-  s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+  s_sg_platf_AS_cbarg_t AS;
   AS.id = cluster->id;
 
   switch (cluster->topology) {
@@ -267,6 +303,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
 
       XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, cluster->speed);
 
+      s_sg_platf_host_cbarg_t host;
       memset(&host, 0, sizeof(host));
       host.id = host_id;
       if ((cluster->properties != NULL) && (!xbt_dict_is_empty(cluster->properties))) {
@@ -379,7 +416,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
   XBT_DEBUG(" ");
   XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id);
   char *newid = NULL;
-  s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+  s_sg_platf_router_cbarg_t router;
   memset(&router, 0, sizeof(router));
   router.id = cluster->router_id;
   router.coord = "";
@@ -426,71 +463,40 @@ void routing_cluster_add_backbone(simgrid::surf::Link* bb) {
 
 void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
 {
-  int start, end, i;
-  char *groups , *host_id , *link_id = NULL;
-  unsigned int iter;
-  xbt_dynar_t radical_elements;
-  xbt_dynar_t radical_ends;
-
-  //Make all hosts
-  radical_elements = xbt_str_split(cabinet->radical, ",");
-  xbt_dynar_foreach(radical_elements, iter, groups) {
+  std::vector<char*> *hostnames = makeHostnames(cabinet->prefix, cabinet->radical, cabinet->suffix);
 
-    radical_ends = xbt_str_split(groups, "-");
-    start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-
-    switch (xbt_dynar_length(radical_ends)) {
-    case 1:
-      end = start;
-      break;
-    case 2:
-      end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
-      break;
-    default:
-      surf_parse_error("Malformed radical");
-      break;
-    }
-    s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+  for (char* hostname : *hostnames) {
+    s_sg_platf_host_cbarg_t host;
     memset(&host, 0, sizeof(host));
-    host.pstate        = 0;
-    host.core_amount   = 1;
-
-    s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+    host.pstate           = 0;
+    host.core_amount      = 1;
+    host.id               = hostname;
+    host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL);
+    xbt_dynar_push(host.speed_per_pstate,&cabinet->speed);
+    sg_platf_new_host(&host);
+    xbt_dynar_free(&host.speed_per_pstate);
+
+    s_sg_platf_link_cbarg_t link;
     memset(&link, 0, sizeof(link));
     link.policy    = SURF_LINK_FULLDUPLEX;
     link.latency   = cabinet->lat;
     link.bandwidth = cabinet->bw;
+    link.id        = bprintf("link_%s",hostname);
+    sg_platf_new_link(&link);
+    free((char*)link.id);
 
-    s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+    s_sg_platf_host_link_cbarg_t host_link;
     memset(&host_link, 0, sizeof(host_link));
-
-    for (i = start; i <= end; i++) {
-      host_id                      = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
-      link_id                      = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
-      host.id                      = host_id;
-      link.id                      = link_id;
-      host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL);
-      xbt_dynar_push(host.speed_per_pstate,&cabinet->speed);
-      sg_platf_new_host(&host);
-      xbt_dynar_free(&host.speed_per_pstate);
-      sg_platf_new_link(&link);
-
-      char* link_up       = bprintf("%s_UP",link_id);
-      char* link_down     = bprintf("%s_DOWN",link_id);
-      host_link.id        = host_id;
-      host_link.link_up   = link_up;
-      host_link.link_down = link_down;
-      sg_platf_new_hostlink(&host_link);
-
-      free(host_id);
-      free(link_id);
-      free(link_up);
-      free(link_down);
-    }
-
-    xbt_dynar_free(&radical_ends);
+    host_link.id        = hostname;
+    host_link.link_up   = bprintf("link_%s_UP",hostname);
+    host_link.link_down = bprintf("link_%s_DOWN",hostname);
+    sg_platf_new_hostlink(&host_link);
+    free((char*)host_link.link_up);
+    free((char*)host_link.link_down);
+
+    free(hostname);
   }
-  xbt_dynar_free(&radical_elements);
+  delete(hostnames);
 }
 
 void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
@@ -700,13 +706,13 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   XBT_DEBUG(" ");
 
   XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", peer->id);
-  s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
-  AS.id                    = peer->id;
-  AS.routing               = A_surfxml_AS_routing_Cluster;
+  s_sg_platf_AS_cbarg_t AS;
+  AS.id      = peer->id;
+  AS.routing = A_surfxml_AS_routing_Cluster;
   sg_platf_new_AS_begin(&AS);
 
   XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
-  s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+  s_sg_platf_host_cbarg_t host;
   memset(&host, 0, sizeof(host));
   host.id = host_id;
 
@@ -719,7 +725,7 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   sg_platf_new_host(&host);
   xbt_dynar_free(&host.speed_per_pstate);
 
-  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+  s_sg_platf_link_cbarg_t link;
   memset(&link, 0, sizeof(link));
   link.policy  = SURF_LINK_SHARED;
   link.latency = peer->lat;
@@ -737,7 +743,7 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   sg_platf_new_link(&link);
 
   XBT_DEBUG("<host_link\tid=\"%s\"\tup=\"%s\"\tdown=\"%s\" />", host_id,link_up,link_down);
-  s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+  s_sg_platf_host_link_cbarg_t host_link;
   memset(&host_link, 0, sizeof(host_link));
   host_link.id        = host_id;
   host_link.link_up   = link_up;
@@ -747,7 +753,7 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   free(link_down);
 
   XBT_DEBUG("<router id=\"%s\"/>", router_id);
-  s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+  s_sg_platf_router_cbarg_t router;
   memset(&router, 0, sizeof(router));
   router.id = router_id;
   router.coord = peer->coord;
index ef48487..bd82243 100644 (file)
@@ -50,25 +50,17 @@ typedef struct {
   xbt_dict_t properties;
 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
 
-#define SG_PLATF_HOST_INITIALIZER { \
-    NULL, 0, 1, 1, NULL, NULL, NULL, NULL \
-}
-
 typedef struct {
   const char* id;
   const char* link_up;
   const char* link_down;
 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
 
-#define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
-
 typedef struct {
   const char* id;
   const char* coord;
 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
 
-#define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
-
 typedef struct {
   const char* id;
   double bandwidth;
@@ -80,10 +72,6 @@ typedef struct {
   xbt_dict_t properties;
 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
 
-#define SG_PLATF_LINK_INITIALIZER {\
-  NULL, 0., NULL, 0., NULL, NULL, SURF_LINK_SHARED, NULL \
-}
-
 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
 typedef struct s_sg_platf_peer_cbarg {
   const char* id;
@@ -96,8 +84,6 @@ typedef struct s_sg_platf_peer_cbarg {
   tmgr_trace_t state_trace;
 } s_sg_platf_peer_cbarg_t;
 
-#define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
-
 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
 typedef struct s_sg_platf_route_cbarg {
   bool symmetrical;
@@ -108,8 +94,6 @@ typedef struct s_sg_platf_route_cbarg {
   std::vector<Link*> *link_list;
 } s_sg_platf_route_cbarg_t;
 
-#define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
-
 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
 typedef struct s_sg_platf_cluster_cbarg {
   const char* id;
@@ -135,12 +119,6 @@ typedef struct s_sg_platf_cluster_cbarg {
   const char* state_trace;
 } s_sg_platf_cluster_cbarg_t;
 
-#define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \
-  ,1.,1.,0.,0.,0.,0.,0. \
-  ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \
-  SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \
-  ,NULL}
-
 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
 typedef struct s_sg_platf_cabinet_cbarg {
   const char* id;
@@ -152,8 +130,6 @@ typedef struct s_sg_platf_cabinet_cbarg {
   double lat;
 } s_sg_platf_cabinet_cbarg_t;
 
-#define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
-
 typedef struct {
   const char* id;
   const char* type_id;
@@ -163,8 +139,6 @@ typedef struct {
   const char* attach;
 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
 
-#define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
-
 typedef struct {
   const char* id;
   const char* model;
@@ -175,23 +149,17 @@ typedef struct {
   sg_size_t size;
 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
 
-#define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
-
 typedef struct {
   const char* storageId;
   const char* name;
 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
 
-#define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
-
 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
 typedef struct s_sg_platf_prop_cbarg {
   const char *id;
   const char *value;
 } s_sg_platf_prop_cbarg_t;
 
-#define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
-
 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
 typedef struct s_sg_platf_trace_cbarg {
   const char *id;
@@ -200,8 +168,6 @@ typedef struct s_sg_platf_trace_cbarg {
   const char *pc_data;
 } s_sg_platf_trace_cbarg_t;
 
-#define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
-
 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
 typedef struct s_sg_platf_trace_connect_cbarg {
   e_surf_trace_connect_kind_t kind;
@@ -209,8 +175,6 @@ typedef struct s_sg_platf_trace_connect_cbarg {
   const char *element;
 } s_sg_platf_trace_connect_cbarg_t;
 
-#define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
-
 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
 typedef struct s_sg_platf_process_cbarg {
   const char **argv;
@@ -223,8 +187,6 @@ typedef struct s_sg_platf_process_cbarg {
   e_surf_process_on_failure_t on_failure;
 } s_sg_platf_process_cbarg_t;
 
-#define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
-
 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
 typedef struct s_sg_platf_AS_cbarg {
   const char *id;
index be84da6..a0d39b4 100644 (file)
@@ -249,7 +249,7 @@ void STag_surfxml_storage(void)
 }
 void ETag_surfxml_storage(void)
 {
-  s_sg_platf_storage_cbarg_t storage = SG_PLATF_STORAGE_INITIALIZER;
+  s_sg_platf_storage_cbarg_t storage;
   memset(&storage,0,sizeof(storage));
 
   storage.id           = A_surfxml_storage_id;
@@ -270,7 +270,7 @@ void STag_surfxml_storage___type(void)
 }
 void ETag_surfxml_storage___type(void)
 {
-  s_sg_platf_storage_type_cbarg_t storage_type = SG_PLATF_STORAGE_TYPE_INITIALIZER;
+  s_sg_platf_storage_type_cbarg_t storage_type;
   memset(&storage_type,0,sizeof(storage_type));
 
   storage_type.content          = A_surfxml_storage___type_content;
@@ -291,7 +291,7 @@ void STag_surfxml_mount(void)
 }
 void ETag_surfxml_mount(void)
 {
-  s_sg_platf_mount_cbarg_t mount = SG_PLATF_MOUNT_INITIALIZER;
+  s_sg_platf_mount_cbarg_t mount;
   memset(&mount,0,sizeof(mount));
 
   mount.name      = A_surfxml_mount_name;
@@ -431,9 +431,9 @@ void STag_surfxml_prop(void)
 }
 
 void ETag_surfxml_host(void)    {
-  s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
-  char* buf;
+  s_sg_platf_host_cbarg_t host;
   memset(&host,0,sizeof(host));
+  char* buf;
 
 
   host.properties = current_property_set;
@@ -450,13 +450,10 @@ void ETag_surfxml_host(void)    {
   else {
     xbt_dynar_t pstate_list = xbt_str_split(buf, ",");
     unsigned int i;
-    for (i = 0; i < xbt_dynar_length(pstate_list); i++) {
-      double speed;
-      char* speed_str;
-
-      xbt_dynar_get_cpy(pstate_list, i, &speed_str);
+    char* speed_str;
+    xbt_dynar_foreach(pstate_list, i, speed_str) {
       xbt_str_trim(speed_str, nullptr);
-      speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
+      double speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
       xbt_dynar_push_as(host.speed_per_pstate, double, speed);
       XBT_DEBUG("Speed value: %f", speed);
     }
@@ -477,7 +474,7 @@ void ETag_surfxml_host(void)    {
 
 void STag_surfxml_host___link(void){
   XBT_DEBUG("Create a Host_link for %s",A_surfxml_host___link_id);
-  s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+  s_sg_platf_host_link_cbarg_t host_link;
   memset(&host_link,0,sizeof(host_link));
 
   host_link.id        = A_surfxml_host___link_id;
@@ -487,7 +484,7 @@ void STag_surfxml_host___link(void){
 }
 
 void STag_surfxml_router(void){
-  s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+  s_sg_platf_router_cbarg_t router;
   memset(&router, 0, sizeof(router));
 
   router.id    = A_surfxml_router_id;
@@ -497,7 +494,7 @@ void STag_surfxml_router(void){
 }
 
 void ETag_surfxml_cluster(void){
-  s_sg_platf_cluster_cbarg_t cluster = SG_PLATF_CLUSTER_INITIALIZER;
+  s_sg_platf_cluster_cbarg_t cluster;
   memset(&cluster,0,sizeof(cluster));
   cluster.properties = as_current_property_set;
 
@@ -580,7 +577,7 @@ void STag_surfxml_cluster(void){
 
 void STag_surfxml_cabinet(void){
   parse_after_config();
-  s_sg_platf_cabinet_cbarg_t cabinet = SG_PLATF_CABINET_INITIALIZER;
+  s_sg_platf_cabinet_cbarg_t cabinet;
   memset(&cabinet,0,sizeof(cabinet));
   cabinet.id      = A_surfxml_cabinet_id;
   cabinet.prefix  = A_surfxml_cabinet_prefix;
@@ -595,7 +592,7 @@ void STag_surfxml_cabinet(void){
 
 void STag_surfxml_peer(void){
   parse_after_config();
-  s_sg_platf_peer_cbarg_t peer = SG_PLATF_PEER_INITIALIZER;
+  s_sg_platf_peer_cbarg_t peer;
   memset(&peer,0,sizeof(peer));
   peer.id                 = A_surfxml_peer_id;
   peer.speed              = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
@@ -615,7 +612,7 @@ void STag_surfxml_link(void){
 }
 
 void ETag_surfxml_link(void){
-  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+  s_sg_platf_link_cbarg_t link;
   memset(&link,0,sizeof(link));
 
   link.properties          = current_property_set;
@@ -668,11 +665,10 @@ void STag_surfxml_link___ctn(void){
 }
 
 void ETag_surfxml_backbone(void){
-  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+  s_sg_platf_link_cbarg_t link;
   memset(&link,0,sizeof(link));
 
   link.properties = nullptr;
-
   link.id = A_surfxml_backbone_id;
   link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id);
   link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id);
@@ -833,7 +829,7 @@ void ETag_surfxml_bypassASroute(void){
 }
 
 void ETag_surfxml_trace(void){
-  s_sg_platf_trace_cbarg_t trace = SG_PLATF_TRACE_INITIALIZER;
+  s_sg_platf_trace_cbarg_t trace;
   memset(&trace,0,sizeof(trace));
 
   trace.id = A_surfxml_trace_id;
@@ -846,7 +842,7 @@ void ETag_surfxml_trace(void){
 
 void STag_surfxml_trace___connect(void){
   parse_after_config();
-  s_sg_platf_trace_connect_cbarg_t trace_connect = SG_PLATF_TRACE_CONNECT_INITIALIZER;
+  s_sg_platf_trace_connect_cbarg_t trace_connect;
   memset(&trace_connect,0,sizeof(trace_connect));
 
   trace_connect.element = A_surfxml_trace___connect_element;
@@ -876,9 +872,7 @@ void STag_surfxml_trace___connect(void){
 void STag_surfxml_AS(void){
   parse_after_config();
   AS_TAG                   = 1;
-  s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
-  AS.id                    = A_surfxml_AS_id;
-  AS.routing               = (int)A_surfxml_AS_routing;
+  s_sg_platf_AS_cbarg_t AS = { A_surfxml_AS_id, (int)A_surfxml_AS_routing};
 
   as_current_property_set = nullptr;
 
@@ -938,7 +932,7 @@ void STag_surfxml_process(void){
 }
 
 void ETag_surfxml_process(void){
-  s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
+  s_sg_platf_process_cbarg_t process;
   memset(&process,0,sizeof(process));
 
   process.argc       = argc;