Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
adding modifications for 1 pass & for adding routes only when platform end tag reached
[simgrid.git] / src / surf / cpu.c
index 06bcaac..3d2bdc7 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
 surf_cpu_model_t surf_cpu_model = NULL;
 lmm_system_t cpu_maxmin_system = NULL;
 
-xbt_dict_t cpu_set;
+xbt_dict_t cpu_set = NULL;
 
 static void cpu_free(void *cpu)
 {
@@ -29,7 +29,9 @@ static cpu_Cas01_t cpu_new(char *name, double power_scale,
                           xbt_dict_t cpu_properties)
 {
   cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1);
-
+  xbt_assert1(!xbt_dict_get_or_null(cpu_set, name),
+             "Host '%s' declared several times in the platform file",name);
+   
   cpu->model = (surf_model_t) surf_cpu_model;
   cpu->name = name;
   cpu->power_scale = power_scale;
@@ -86,15 +88,11 @@ static void parse_cpu_init(void)
 
 }
 
-static void parse_file(const char *file)
+static void define_callbacks(const char *file)
 {
   surf_parse_reset_parser();
   surfxml_add_callback(STag_surfxml_host_cb_list, parse_cpu_init);
-  surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
-
-  surf_parse_open(file);
-  xbt_assert1((!surf_parse()), "Parse error in %s", file);
-  surf_parse_close();
+  surfxml_add_callback(STag_surfxml_prop_cb_list, parse_properties);
 }
 
 static void *name_service(const char *name)
@@ -452,6 +450,6 @@ void surf_cpu_model_init_Cas01(const char *filename)
   if (surf_cpu_model)
     return;
   surf_cpu_model_init_internal();
-  parse_file(filename);
+  define_callbacks(filename);
   xbt_dynar_push(model_list, &surf_cpu_model);
 }