Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean callbacks for the host parsing.
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 4 Nov 2011 20:33:29 +0000 (21:33 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 4 Nov 2011 20:33:29 +0000 (21:33 +0100)
- do not rely on global field, but pass the parameter to the callbacks
- do not show the dynar containing the callbacks to the public, but
  provide a specific function to add a callback not needing to see the
  dynar

This breaks some tests, but I need to split my changes to see when I
improve the situation, and revert stuff when I degrade the situation.
I start to fix the tests right away.

12 files changed:
include/surf/surfxml_parse.h
src/include/surf/surfxml_parse_values.h
src/instr/instr_routing.c
src/surf/cpu.c
src/surf/cpu_im.c
src/surf/cpu_ti.c
src/surf/network_constant.c
src/surf/surf_routing.c
src/surf/surf_routing_cluster.c
src/surf/surfxml_parse.c
src/surf/surfxml_parseplatf.c
src/surf/workstation_ptask_L07.c

index ef751eb..63bdca1 100644 (file)
@@ -17,7 +17,6 @@ SG_BEGIN_DECL()
 /* Hook for the different tags. All the functions which pointer to are push into here are run when the tag is encountered */
 XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_platform_cb_list;
 XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_platform_cb_list;
-XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_host_cb_list;
 XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_host_cb_list;
 XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_router_cb_list;
 XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_router_cb_list;
index 8a25ca1..70cbc24 100644 (file)
@@ -59,29 +59,32 @@ typedef struct s_surf_parsing_router_arg {
 
 typedef struct s_surf_parsing_host_arg *surf_parsing_host_arg_t;
 typedef struct s_surf_parsing_host_arg {
-       char* V_host_id;                                                                                                        //id
-       double V_host_power_peak;                                                                                       //power
-       int V_host_core;                                                                                                        //core
-       double V_host_power_scale;                                                                                      //availability
-       tmgr_trace_t V_host_power_trace;                                                                        //availability file
-       e_surf_resource_state_t V_host_state_initial;                                           //state
-       tmgr_trace_t V_host_state_trace;                                                                        //state file
+       char* V_host_id;                          //id
+       double V_host_power_peak;                     //power
+       int V_host_core;                          //core
+       double V_host_power_scale;                      //availability
+       tmgr_trace_t V_host_power_trace;                  //availability file
+       e_surf_resource_state_t V_host_state_initial;           //state
+       tmgr_trace_t V_host_state_trace;                  //state file
        const char* V_host_coord;
 } s_surf_parsing_host_arg_t;
 
-extern surf_parsing_host_arg_t struct_host;
-extern surf_parsing_router_arg_t struct_router;
-extern surf_parsing_cluster_arg_t struct_cluster;
-extern surf_parsing_peer_arg_t struct_peer;
-extern surf_parsing_link_arg_t struct_lnk;
-
 typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t;
 typedef struct s_surf_parsing_link_up_down {
        void* link_up;
        void* link_down;
 } s_surf_parsing_link_up_down_t;
 
-void surf_parse_host(void);
+
+typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
+void surf_parse_host_add_cb(surf_parse_host_fct_t);
+
+extern surf_parsing_router_arg_t struct_router;
+extern surf_parsing_cluster_arg_t struct_cluster;
+extern surf_parsing_peer_arg_t struct_peer;
+extern surf_parsing_link_arg_t struct_lnk;
+
+void surf_parse_host(surf_parsing_host_arg_t h);
 void surf_parse_link(void);
 
 #endif /* SURFXML_PARSE_VALUES_H_ */
index ae3ea4b..9d7488c 100644 (file)
@@ -225,14 +225,14 @@ static void instr_routing_parse_start_link ()
   xbt_dynar_free (&links_to_create);
 }
 
-static void instr_routing_parse_start_host ()
+static void instr_routing_parse_start_host (surf_parsing_host_arg_t host)
 {
   container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
-  container_t new = newContainer (struct_host->V_host_id, INSTR_HOST, father);
+  container_t new = newContainer (host->V_host_id, INSTR_HOST, father);
 
   if (TRACE_categorized() || TRACE_uncategorized()) {
     type_t power = getVariableType ("power", NULL, new->type);
-    new_pajeSetVariable (0, new, power, struct_host->V_host_power_peak);
+    new_pajeSetVariable (0, new, power, host->V_host_power_peak);
   }
   if (TRACE_uncategorized()){
     getVariableType ("power_used", "0.5 0.5 0.5", new->type);
@@ -292,7 +292,7 @@ void instr_routing_define_callbacks ()
   surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS);
   if (!TRACE_needs_platform()) return;
   surfxml_add_callback(STag_surfxml_link_cb_list, &instr_routing_parse_start_link);
-  surfxml_add_callback(STag_surfxml_host_cb_list, &instr_routing_parse_start_host);
+  surf_parse_host_add_cb(instr_routing_parse_start_host);
   surfxml_add_callback(STag_surfxml_router_cb_list, &instr_routing_parse_start_router);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform);
 }
index 2124426..1bbeb9f 100644 (file)
@@ -71,17 +71,17 @@ static void* cpu_create_resource(const char *name, double power_peak,
 }
 
 
-static void parse_cpu_init(void)
+static void parse_cpu_init(surf_parsing_host_arg_t host)
 {
-  if(strcmp(struct_host->V_host_coord,"")) xbt_die("Coordinates not implemented yet!");
-
-  cpu_create_resource(struct_host->V_host_id,
-                 struct_host->V_host_power_peak,
-                 struct_host->V_host_power_scale,
-                 struct_host->V_host_power_trace,
-                 struct_host->V_host_core,
-                 struct_host->V_host_state_initial,
-                 struct_host->V_host_state_trace,
+  if(strcmp(host->V_host_coord,"")) xbt_die("Coordinates not implemented yet!");
+
+  cpu_create_resource(host->V_host_id,
+                 host->V_host_power_peak,
+                 host->V_host_power_scale,
+                 host->V_host_power_trace,
+                 host->V_host_core,
+                 host->V_host_state_initial,
+                 host->V_host_state_trace,
                  current_property_set);
   current_property_set = NULL;
 }
@@ -124,7 +124,7 @@ static void add_traces_cpu(void)
 
 static void cpu_define_callbacks(void)
 {
-  surfxml_add_callback(ETag_surfxml_host_cb_list, parse_cpu_init);
+  surf_parse_host_add_cb(parse_cpu_init);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu);
 }
 
index caa3a9d..14c9cfb 100644 (file)
@@ -88,15 +88,15 @@ static void* cpu_im_create_resource(const char *name, double power_peak,
 }
 
 
-static void parse_cpu_im_init(void)
+static void parse_cpu_im_init(surf_parsing_host_arg_t host)
 {
-       cpu_im_create_resource(struct_host->V_host_id,
-                         struct_host->V_host_power_peak,
-                         struct_host->V_host_power_scale,
-                         struct_host->V_host_power_trace,
-                         struct_host->V_host_core,
-                         struct_host->V_host_state_initial,
-                         struct_host->V_host_state_trace,
+       cpu_im_create_resource(host->V_host_id,
+                         host->V_host_power_peak,
+                         host->V_host_power_scale,
+                         host->V_host_power_trace,
+                         host->V_host_core,
+                         host->V_host_state_initial,
+                         host->V_host_state_trace,
                          current_property_set);
        current_property_set = NULL;
 }
@@ -136,7 +136,7 @@ static void cpu_im_add_traces_cpu(void)
 
 static void cpu_im_define_callbacks()
 {
-  surfxml_add_callback(ETag_surfxml_host_cb_list, parse_cpu_im_init);
+  surf_parse_host_add_cb(parse_cpu_im_init);
   surfxml_add_callback(ETag_surfxml_platform_cb_list,
                        &cpu_im_add_traces_cpu);
 }
index b18b735..fe6e4f4 100644 (file)
@@ -190,15 +190,15 @@ static void* cpu_ti_create_resource(const char *name, double power_peak,
 }
 
 
-static void parse_cpu_ti_init(void)
+static void parse_cpu_ti_init(surf_parsing_host_arg_t host)
 {
-  cpu_ti_create_resource(struct_host->V_host_id,
-                         struct_host->V_host_power_peak,
-                         struct_host->V_host_power_scale,
-                         struct_host->V_host_power_trace,
-                         struct_host->V_host_core,
-                         struct_host->V_host_state_initial,
-                         struct_host->V_host_state_trace,
+  cpu_ti_create_resource(host->V_host_id,
+                         host->V_host_power_peak,
+                         host->V_host_power_scale,
+                         host->V_host_power_trace,
+                         host->V_host_core,
+                         host->V_host_state_initial,
+                         host->V_host_state_trace,
                          current_property_set);
   current_property_set = NULL;
 
@@ -263,7 +263,7 @@ static void add_traces_cpu_ti(void)
 
 static void cpu_ti_define_callbacks()
 {
-  surfxml_add_callback(ETag_surfxml_host_cb_list, parse_cpu_ti_init);
+  surf_parse_host_add_cb(parse_cpu_ti_init);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu_ti);
 }
 
index 4c9db11..f4251f0 100644 (file)
@@ -21,14 +21,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
 static random_data_t random_latency = NULL;
 static int host_number_int = 0;
 
-static void netcste_count_hosts(void)
+static void netcste_count_hosts(surf_parsing_host_arg_t h)
 {
   host_number_int++;
 }
 
 static void netcste_define_callbacks(void)
 {
-  surfxml_add_callback(STag_surfxml_host_cb_list, &netcste_count_hosts);
+  surf_parse_host_add_cb(netcste_count_hosts);
 }
 
 static int netcste_resource_used(void *resource_id)
index c9fb2c5..e5e66a0 100644 (file)
@@ -186,11 +186,9 @@ static void parse_E_host(void)
 /*
  * \brief Add a host to the network element list from XML
  */
-static void parse_S_host_XML(void)
+static void parse_S_host_XML(surf_parsing_host_arg_t h)
 {
-//     XBT_INFO("parse_S_host_XML");
-//     XBT_INFO("'%s'  '%s'",struct_host->V_host_id, struct_host->V_host_coord);
-       parse_S_host(struct_host->V_host_id, struct_host->V_host_coord);
+       parse_S_host(h->V_host_id, h->V_host_coord);
 }
 static void parse_E_host_XML(void)
 {
@@ -972,7 +970,7 @@ void routing_model_create(size_t size_of_links, void *loopback, double_f_cpvoid_
   current_routing = NULL;
 
   /* parse generic elements */
-  surfxml_add_callback(STag_surfxml_host_cb_list, &parse_S_host_XML);
+  surf_parse_host_add_cb(parse_S_host_XML);
   surfxml_add_callback(ETag_surfxml_host_cb_list, &parse_E_host_XML);
   surfxml_add_callback(STag_surfxml_router_cb_list, &parse_S_router_XML);
 
@@ -1504,6 +1502,8 @@ static void routing_parse_Econfig(void)
 static void parse_create_host_link(int i)
 {
        char *host_id, *link_id = NULL;
+       s_surf_parsing_host_arg_t host;
+       memset(&host,0,sizeof(host));
 
        host_id = bprintf("%s%d%s", struct_cluster->V_cluster_prefix, i, struct_cluster->V_cluster_suffix);
        link_id = bprintf("%s_link_%d", struct_cluster->V_cluster_id, i);
@@ -1511,14 +1511,13 @@ static void parse_create_host_link(int i)
        A_surfxml_host_state = A_surfxml_host_state_ON;
 
        XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
-       struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
-       struct_host->V_host_id = xbt_strdup(host_id);
+       host.V_host_id = xbt_strdup(host_id);
        if(strcmp(struct_cluster->V_cluster_availability_file,"")){
          xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
          char* tmp_availability_file = xbt_strdup(struct_cluster->V_cluster_availability_file);
          xbt_str_varsubst(tmp_availability_file,patterns);
          XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
-         struct_host->V_host_power_trace = tmgr_trace_new(tmp_availability_file);
+         host.V_host_power_trace = tmgr_trace_new(tmp_availability_file);
          xbt_free(tmp_availability_file);
        }
        else
@@ -1529,7 +1528,7 @@ static void parse_create_host_link(int i)
          char *tmp_state_file = xbt_strdup(struct_cluster->V_cluster_state_file);
          xbt_str_varsubst(tmp_state_file,patterns);
          XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file);
-         struct_host->V_host_state_trace = tmgr_trace_new(tmp_state_file);
+         host.V_host_state_trace = tmgr_trace_new(tmp_state_file);
          xbt_free(tmp_state_file);
        }
        else
@@ -1537,12 +1536,12 @@ static void parse_create_host_link(int i)
          XBT_DEBUG("\tstate_file=\"\"");
        }
 
-       struct_host->V_host_power_peak = struct_cluster->S_cluster_power;
-       struct_host->V_host_power_scale = 1.0;
-       struct_host->V_host_core = struct_cluster->S_cluster_core;
-       struct_host->V_host_state_initial = SURF_RESOURCE_ON;
-       struct_host->V_host_coord = "";
-       surf_parse_host();
+       host.V_host_power_peak = struct_cluster->S_cluster_power;
+       host.V_host_power_scale = 1.0;
+       host.V_host_core = struct_cluster->S_cluster_core;
+       host.V_host_state_initial = SURF_RESOURCE_ON;
+       host.V_host_coord = "";
+       surf_parse_host(&host);
        XBT_DEBUG("</host>");
 
        A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
@@ -1604,6 +1603,8 @@ void routing_parse_Scluster(void)
   static int AX_ptr = 0;
   char *host_id, *groups, *link_id = NULL;
 
+  s_surf_parsing_host_arg_t host;
+
   if( strcmp(struct_cluster->V_cluster_availability_file,"")
          || strcmp(struct_cluster->V_cluster_state_file,"") )
   {
@@ -1633,6 +1634,8 @@ void routing_parse_Scluster(void)
   //Make all hosts
   radical_elements = xbt_str_split(struct_cluster->V_cluster_radical, ",");
   xbt_dynar_foreach(radical_elements, iter, groups) {
+    memset(&host,0,sizeof(host));
+
     radical_ends = xbt_str_split(groups, "-");
     switch (xbt_dynar_length(radical_ends)) {
     case 1:
@@ -1641,14 +1644,13 @@ void routing_parse_Scluster(void)
                link_id = bprintf("%s_link_%d", struct_cluster->V_cluster_id, start);
 
                XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
-               struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
-               struct_host->V_host_id = host_id;
+               host.V_host_id = host_id;
                if(strcmp(struct_cluster->V_cluster_availability_file,"")){
                  xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free);
                  char* tmp_availability_file = xbt_strdup(struct_cluster->V_cluster_availability_file);
                  xbt_str_varsubst(tmp_availability_file,patterns);
                  XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
-                 struct_host->V_host_power_trace = tmgr_trace_new(tmp_availability_file);
+                 host.V_host_power_trace = tmgr_trace_new(tmp_availability_file);
                  xbt_free(tmp_availability_file);
                }
                else
@@ -1659,7 +1661,7 @@ void routing_parse_Scluster(void)
                  char *tmp_state_file = xbt_strdup(struct_cluster->V_cluster_state_file);
                  xbt_str_varsubst(tmp_state_file,patterns);
                  XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file);
-                 struct_host->V_host_state_trace = tmgr_trace_new(tmp_state_file);
+                 host.V_host_state_trace = tmgr_trace_new(tmp_state_file);
                  xbt_free(tmp_state_file);
                }
                else
@@ -1667,12 +1669,12 @@ void routing_parse_Scluster(void)
                  XBT_DEBUG("\tstate_file=\"\"");
                }
 
-               struct_host->V_host_power_peak = struct_cluster->S_cluster_power;
-               struct_host->V_host_power_scale = 1.0;
-               struct_host->V_host_core = struct_cluster->S_cluster_core;
-               struct_host->V_host_state_initial = SURF_RESOURCE_ON;
-               struct_host->V_host_coord = "";
-               surf_parse_host();
+               host.V_host_power_peak = struct_cluster->S_cluster_power;
+               host.V_host_power_scale = 1.0;
+               host.V_host_core = struct_cluster->S_cluster_core;
+               host.V_host_state_initial = SURF_RESOURCE_ON;
+               host.V_host_coord = "";
+               surf_parse_host(&host);
                XBT_DEBUG("</host>");
 
                A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
@@ -1723,14 +1725,13 @@ void routing_parse_Scluster(void)
                A_surfxml_host_state = A_surfxml_host_state_ON;
 
                XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
-               struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
-               struct_host->V_host_id = host_id;
+               host.V_host_id = host_id;
                if(strcmp(struct_cluster->V_cluster_availability_file,"")){
                  xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
                  char* tmp_availability_file = xbt_strdup(struct_cluster->V_cluster_availability_file);
                  xbt_str_varsubst(tmp_availability_file,patterns);
                  XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
-                 struct_host->V_host_power_trace = tmgr_trace_new(tmp_availability_file);
+                 host.V_host_power_trace = tmgr_trace_new(tmp_availability_file);
                  xbt_free(tmp_availability_file);
                }
                else
@@ -1741,7 +1742,7 @@ void routing_parse_Scluster(void)
                  char *tmp_state_file = xbt_strdup(struct_cluster->V_cluster_state_file);
                  xbt_str_varsubst(tmp_state_file,patterns);
                  XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file);
-                 struct_host->V_host_state_trace = tmgr_trace_new(tmp_state_file);
+                 host.V_host_state_trace = tmgr_trace_new(tmp_state_file);
                  xbt_free(tmp_state_file);
                }
                else
@@ -1749,12 +1750,12 @@ void routing_parse_Scluster(void)
                  XBT_DEBUG("\tstate_file=\"\"");
                }
 
-               struct_host->V_host_power_peak = struct_cluster->S_cluster_power;
-               struct_host->V_host_power_scale = 1.0;
-               struct_host->V_host_core = struct_cluster->S_cluster_core;
-               struct_host->V_host_state_initial = SURF_RESOURCE_ON;
-               struct_host->V_host_coord = "";
-               surf_parse_host();
+               host.V_host_power_peak = struct_cluster->S_cluster_power;
+               host.V_host_power_scale = 1.0;
+               host.V_host_core = struct_cluster->S_cluster_core;
+               host.V_host_state_initial = SURF_RESOURCE_ON;
+               host.V_host_coord = "";
+               surf_parse_host(&host);
                XBT_DEBUG("</host>");
 
                A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
index f5d0d0d..5236ef7 100644 (file)
@@ -41,7 +41,6 @@ static route_extended_t cluster_get_route(routing_component_t rc,
 
          xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL);
 
-         char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down;
          surf_parsing_link_up_down_t info;
 
          info = xbt_dict_get_or_null(cluster_host_link,src);
index b6a745f..4db9fcc 100644 (file)
@@ -44,9 +44,10 @@ void surf_parse_get_int(int *value, const char *string) {
  */
 
 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
+//xbt_dynar_t STag_surfxml_host_cb_list = NULL;
+xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void
 xbt_dynar_t STag_surfxml_platform_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_platform_cb_list = NULL;
-xbt_dynar_t STag_surfxml_host_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_host_cb_list = NULL;
 xbt_dynar_t STag_surfxml_router_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_router_cb_list = NULL;
@@ -158,7 +159,9 @@ void surf_parse_init_callbacks(void)
              xbt_dynar_new(sizeof(void_f_void_t), NULL);
          ETag_surfxml_platform_cb_list =
              xbt_dynar_new(sizeof(void_f_void_t), NULL);
-         STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+
+         surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
+
          ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
          STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
          ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
@@ -224,9 +227,10 @@ void surf_parse_reset_callbacks(void)
 
 void surf_parse_free_callbacks(void)
 {
+  xbt_dynar_free(&surf_parse_host_cb_list);
+
   xbt_dynar_free(&STag_surfxml_platform_cb_list);
   xbt_dynar_free(&ETag_surfxml_platform_cb_list);
-  xbt_dynar_free(&STag_surfxml_host_cb_list);
   xbt_dynar_free(&ETag_surfxml_host_cb_list);
   xbt_dynar_free(&STag_surfxml_router_cb_list);
   xbt_dynar_free(&ETag_surfxml_router_cb_list);
@@ -297,32 +301,40 @@ void STag_surfxml_platform(void)
 
 void STag_surfxml_host(void){
 //     XBT_INFO("STag_surfxml_host [%s]",A_surfxml_host_id);
-       struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
-       struct_host->V_host_id = xbt_strdup(A_surfxml_host_id);
-       struct_host->V_host_power_peak = get_cpu_power(A_surfxml_host_power);
-       surf_parse_get_double(&(struct_host->V_host_power_scale), A_surfxml_host_availability);
-       surf_parse_get_int(&(struct_host->V_host_core),A_surfxml_host_core);
-       struct_host->V_host_power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
-       struct_host->V_host_state_trace = tmgr_trace_new(A_surfxml_host_state_file);
+  s_surf_parsing_host_arg_t host;
+  memset(&host,0,sizeof(host));
+
+       host.V_host_id = xbt_strdup(A_surfxml_host_id);
+       host.V_host_power_peak = get_cpu_power(A_surfxml_host_power);
+       surf_parse_get_double(&(host.V_host_power_scale), A_surfxml_host_availability);
+       surf_parse_get_int(&(host.V_host_core),A_surfxml_host_core);
+       host.V_host_power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+       host.V_host_state_trace = tmgr_trace_new(A_surfxml_host_state_file);
        xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) ||
                          (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state");
        if (A_surfxml_host_state == A_surfxml_host_state_ON)
-               struct_host->V_host_state_initial = SURF_RESOURCE_ON;
+               host.V_host_state_initial = SURF_RESOURCE_ON;
        if (A_surfxml_host_state == A_surfxml_host_state_OFF)
-               struct_host->V_host_state_initial = SURF_RESOURCE_OFF;
-       struct_host->V_host_coord = xbt_strdup(A_surfxml_host_coordinates);
+               host.V_host_state_initial = SURF_RESOURCE_OFF;
+       host.V_host_coord = xbt_strdup(A_surfxml_host_coordinates);
 
-       surf_parse_host();
+       surf_parse_host(&host);
 }
-void surf_parse_host(void){
-       surfxml_call_cb_functions(STag_surfxml_host_cb_list);
+void surf_parse_host(surf_parsing_host_arg_t h){
+  unsigned int iterator;
+  surf_parse_host_fct_t fun;
+  xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
+    if (fun) (*fun) (h);
+  }
+}
+void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
+  xbt_dynar_push(surf_parse_host_cb_list, &fct);
 }
 void ETag_surfxml_host(void){
        surfxml_call_cb_functions(ETag_surfxml_host_cb_list);
-       xbt_free(struct_host->V_host_id);
-       xbt_free(struct_host);
 }
 
+
 void STag_surfxml_router(void){
        struct_router = xbt_new0(s_surf_parsing_router_arg_t, 1);
        struct_router->V_router_id = xbt_strdup(A_surfxml_router_id);
index 202fbe1..d37459a 100644 (file)
@@ -52,7 +52,6 @@ void surfxml_bufferstack_pop(int new)
  * Pass arguments to parsing callback as structures to save some time (and allow callbacks to ignore some)
  */
 
-surf_parsing_host_arg_t struct_host = NULL;
 surf_parsing_router_arg_t struct_router = NULL;
 surf_parsing_cluster_arg_t struct_cluster = NULL;
 surf_parsing_peer_arg_t struct_peer = NULL;
index 1878ea4..726ecb5 100644 (file)
@@ -654,16 +654,16 @@ static void* ptask_cpu_create_resource(const char *name, double power_scale,
   return cpu;
 }
 
-static void ptask_parse_cpu_init(void)
+static void ptask_parse_cpu_init(surf_parsing_host_arg_t host)
 {
   ptask_cpu_create_resource(
-                 struct_host->V_host_id,
-                 struct_host->V_host_power_peak,
-                 struct_host->V_host_power_scale,
-                 struct_host->V_host_power_trace,
-                 struct_host->V_host_state_initial,
-                 struct_host->V_host_state_trace,
-          current_property_set);
+                 host->V_host_id,
+                 host->V_host_power_peak,
+                 host->V_host_power_scale,
+                 host->V_host_power_trace,
+                 host->V_host_state_initial,
+                 host->V_host_state_trace,
+                 current_property_set);
   current_property_set=NULL;
 }
 
@@ -802,7 +802,7 @@ static void ptask_add_traces(void)
 static void ptask_define_callbacks()
 {
   /* Adding callback functions */
-  surfxml_add_callback(ETag_surfxml_host_cb_list, &ptask_parse_cpu_init);
+  surf_parse_host_add_cb(ptask_parse_cpu_init);
   surfxml_add_callback(ETag_surfxml_link_cb_list, &ptask_parse_link_init);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &ptask_add_traces);
 }