Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use a sane way to declare postparse callbacks, now that this way exists
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 9 Nov 2011 17:06:57 +0000 (18:06 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 9 Nov 2011 17:06:57 +0000 (18:06 +0100)
src/include/surf/surf.h
src/surf/surf.c
src/surf/surf_config.c
src/surf/surfxml_parseplatf.c
src/surf/workstation.c

index e733d69..6627be7 100644 (file)
@@ -49,7 +49,6 @@ typedef struct surf_model_description {
   const char *name;
   const char *description;
   void (*model_init_preparse) (void);
-  void (*model_init_postparse) (void);
 } s_surf_model_description_t, *surf_model_description_t;
 
 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
@@ -635,12 +634,6 @@ XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set;
  */
 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
 
-/** \brief create the elements of the models
- *
- * Must be called after parsing the platform file and before using any elements
- */
-XBT_PUBLIC(void) surf_config_models_create_elms(void);
-
 /** \brief Finish simulation initialization
  *  \ingroup SURF_simulation
  *
index 786b76c..764671f 100644 (file)
@@ -149,7 +149,7 @@ s_surf_model_description_t surf_network_model_description[] = {
   {"Vegas",
    "Model using lagrange_solve instead of lmm_solve (experts only)",
    surf_network_model_init_Vegas},
-  {NULL, NULL, NULL, NULL}      /* this array must be NULL terminated */
+  {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
 s_surf_model_description_t surf_cpu_model_description[] = {
@@ -161,18 +161,18 @@ s_surf_model_description_t surf_cpu_model_description[] = {
   {"CpuTI",
    "Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces",
    surf_cpu_model_init_ti},
-  {NULL, NULL, NULL, NULL}      /* this array must be NULL terminated */
+  {NULL, NULL,  NULL}      /* this array must be NULL terminated */
 };
 
 s_surf_model_description_t surf_workstation_model_description[] = {
   {"CLM03",
    "Default workstation model, using LV08 and CM02 as network and CPU",
-   surf_workstation_model_init_CLM03, create_workstations},
+   surf_workstation_model_init_CLM03},
   {"compound",
    "Workstation model allowing you to use other network and CPU models",
-   surf_workstation_model_init_compound, create_workstations},
+   surf_workstation_model_init_compound},
   {"ptask_L07", "Workstation model with better parallel task modeling",
-   surf_workstation_model_init_ptask_L07, NULL},
+   surf_workstation_model_init_ptask_L07},
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
index c6797af..23de181 100644 (file)
@@ -525,16 +525,3 @@ void surf_config_models_setup()
   XBT_DEBUG("Call workstation_model_init");
   surf_workstation_model_description[workstation_id].model_init_preparse();
 }
-
-void surf_config_models_create_elms(void)
-{
-  char *workstation_model_name =
-      xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
-  int workstation_id =
-      find_model_description(surf_workstation_model_description,
-                             workstation_model_name);
-  if (surf_workstation_model_description
-      [workstation_id].model_init_postparse != NULL)
-    surf_workstation_model_description[workstation_id].model_init_postparse
-        ();
-}
index 45db0f3..9f2e6de 100644 (file)
@@ -193,7 +193,5 @@ void parse_platform_file(const char *file)
   surf_parse_close();
   if (parse_status)
     xbt_die("Parse error in %s", file);
-
-  surf_config_models_create_elms();
 }
 
index 3f8276f..0a8c322 100644 (file)
@@ -356,6 +356,7 @@ void surf_workstation_model_init_CLM03(void)
   surf_cpu_model_init_Cas01_im();
   surf_network_model_init_LegrandVelho();
   xbt_dynar_push(model_list, &surf_workstation_model);
+  sg_platf_postparse_add_cb(create_workstations);
 }
 
 void surf_workstation_model_init_compound()
@@ -365,4 +366,5 @@ void surf_workstation_model_init_compound()
   xbt_assert(surf_network_model, "No network model defined yet!");
   surf_workstation_model_init_internal();
   xbt_dynar_push(model_list, &surf_workstation_model);
+  sg_platf_postparse_add_cb(create_workstations);
 }