Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the surf_*_model_description_size constants. They were hard to compute when...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 10 Jun 2008 07:31:22 +0000 (07:31 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 10 Jun 2008 07:31:22 +0000 (07:31 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5585 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/surf/surf.h
src/simdag/sd_global.c
src/simix/smx_config.c
src/simix/smx_environment.c
src/surf/network.c
src/surf/network_constant.c
src/surf/surf.c
src/surf/workstation.c
src/surf/workstation_ptask_L07.c

index 7805461..ca9a272 100644 (file)
@@ -48,13 +48,11 @@ typedef struct surf_model_description {
 } s_surf_model_description_t, *surf_model_description_t;
 
 XBT_PUBLIC(void) update_model_description(s_surf_model_description_t *table,
-                                            int table_size,
-                                            const char* name, 
-                                            surf_model_t model
-                                            );
+                                         const char* name, 
+                                         surf_model_t model
+                                         );
 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t *table,
-                                         int table_size,
-                                         const char* name);
+                                      const char* name);
 
 /** \brief Action structure
  * \ingroup SURF_actions
@@ -245,11 +243,10 @@ XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model;
  */
 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(const char *filename);
 
-#define surf_cpu_model_description_size 1
 /** \brief The list of all available cpu model models
  *  \ingroup SURF_models
  */
-XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[surf_cpu_model_description_size];
+XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
 
 /* Network model */
 
@@ -394,23 +391,10 @@ XBT_PUBLIC(void) surf_network_model_init_Vegas(const char *filename);
 XBT_PUBLIC(void) surf_network_model_init_SDP(const char *filename);
 #endif
 
-#if (HAVE_GTNETS)
-# define inc_GT 1
-#else 
-# define inc_GT 0
-#endif
-#if (HAVE_SDP)
-# define inc_SDP 1
-#else
-# define inc_SDP 0
-#endif
-
-#define surf_network_model_description_size  5+inc_SDP+inc_GT
-
 /** \brief The list of all available network model models
  *  \ingroup SURF_models
  */
-XBT_PUBLIC_DATA(s_surf_model_description_t) surf_network_model_description[surf_network_model_description_size];
+XBT_PUBLIC_DATA(s_surf_model_description_t) surf_network_model_description[];
 
 /** \brief Workstation model extension public
  *  \ingroup SURF_models
@@ -510,11 +494,10 @@ XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(const char *filename);
  */
 XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char *filename);
 
-#define surf_workstation_model_description_size 4
 /** \brief The list of all available workstation model models
  *  \ingroup SURF_models
  */
-XBT_PUBLIC_DATA(s_surf_model_description_t) surf_workstation_model_description[surf_workstation_model_description_size];
+XBT_PUBLIC_DATA(s_surf_model_description_t) surf_workstation_model_description[];
 
 /** \brief The network links
  *  \ingroup SURF_models
index 08da5f0..2341fc0 100644 (file)
@@ -35,9 +35,7 @@ static void _sd_cfg_cb__workstation_model(const char *name, int pos)
              "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sd_cfg_set, name);
-  find_model_description(surf_workstation_model_description,
-                           surf_workstation_model_description_size,
-                           val);
+  find_model_description(surf_workstation_model_description, val);
 }
 
 /* callback of the cpu_model variable */
@@ -49,8 +47,7 @@ static void _sd_cfg_cb__cpu_model(const char *name, int pos)
              "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sd_cfg_set, name);
-  find_model_description(surf_cpu_model_description,
-                           surf_cpu_model_description_size, val);
+  find_model_description(surf_cpu_model_description, val);
 }
 
 /* callback of the workstation_model variable */
@@ -62,8 +59,7 @@ static void _sd_cfg_cb__network_model(const char *name, int pos)
              "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sd_cfg_set, name);
-  find_model_description(surf_network_model_description,
-                           surf_network_model_description_size, val);
+  find_model_description(surf_network_model_description, val);
 }
 
 XBT_LOG_EXTERNAL_CATEGORY(sd_kernel);
@@ -317,8 +313,7 @@ void SD_create_environment(const char *platform_file) {
   DEBUG1("Model : %s", workstation_model_name);
   workstation_id =
       find_model_description(surf_workstation_model_description,
-                               surf_workstation_model_description_size,
-                               workstation_model_name);
+                            workstation_model_name);
   if (!strcmp(workstation_model_name, "compound")) {
     xbt_ex_t e;
     char *network_model_name = NULL;
@@ -354,12 +349,10 @@ void SD_create_environment(const char *platform_file) {
 
     network_id =
        find_model_description(surf_network_model_description,
-                                 surf_network_model_description_size,
-                                 network_model_name);
+                              network_model_name);
     cpu_id =
        find_model_description(surf_cpu_model_description,
-                                 surf_cpu_model_description_size,
-                                 cpu_model_name);
+                              cpu_model_name);
 
     surf_cpu_model_description[cpu_id].model_init(platform_file);
     surf_network_model_description[network_id].model_init(platform_file);
index 51837d1..83252ab 100644 (file)
@@ -26,9 +26,7 @@ static void _simix_cfg_cb__workstation_model(const char *name, int pos)
   val = xbt_cfg_get_string(_simix_cfg_set, name);
   /* New Module missing */
 
-  find_model_description(surf_workstation_model_description,
-                           surf_workstation_model_description_size,
-                           val);
+  find_model_description(surf_workstation_model_description,val);
 }
 
 /* callback of the cpu_model variable */
@@ -41,8 +39,7 @@ static void _simix_cfg_cb__cpu_model(const char *name, int pos)
 
   val = xbt_cfg_get_string(_simix_cfg_set, name);
   /* New Module missing */
-  find_model_description(surf_cpu_model_description,
-                           surf_cpu_model_description_size, val);
+  find_model_description(surf_cpu_model_description, val);
 }
 
 /* callback of the workstation_model variable */
@@ -55,8 +52,7 @@ static void _simix_cfg_cb__network_model(const char *name, int pos)
 
   val = xbt_cfg_get_string(_simix_cfg_set, name);
   /* New Module missing */
-  find_model_description(surf_network_model_description,
-                           surf_network_model_description_size, val);
+  find_model_description(surf_network_model_description, val);
 }
 
 XBT_LOG_EXTERNAL_CATEGORY(simix);
index 1198f5a..953e021 100644 (file)
@@ -50,8 +50,7 @@ void SIMIX_create_environment(const char *file)
   DEBUG1("Model : %s", workstation_model_name);
   workstation_id =
       find_model_description(surf_workstation_model_description,
-                               surf_workstation_model_description_size,
-                               workstation_model_name);
+                            workstation_model_name);
   if (!strcmp(workstation_model_name, "compound")) {
     xbt_ex_t e;
     char *network_model_name = NULL;
@@ -87,12 +86,10 @@ void SIMIX_create_environment(const char *file)
 
     network_id =
        find_model_description(surf_network_model_description,
-                                 surf_network_model_description_size,
-                                 network_model_name);
+                              network_model_name);
     cpu_id =
        find_model_description(surf_cpu_model_description,
-                                 surf_cpu_model_description_size,
-                                 cpu_model_name);
+                              cpu_model_name);
 
     surf_cpu_model_description[cpu_id].model_init(file);
     surf_network_model_description[network_id].model_init(file);
index 82cdde8..d3d95e1 100644 (file)
@@ -801,9 +801,8 @@ void surf_network_model_init_CM02(const char *filename)
   network_solve = lmm_solve;
 
   update_model_description(surf_network_model_description,
-                             surf_network_model_description_size,
-                             "CM02",
-                             (surf_model_t) surf_network_model);
+                          "CM02",
+                          (surf_model_t) surf_network_model);
 }
 
 void surf_network_model_init_Reno(const char *filename)
@@ -819,9 +818,8 @@ void surf_network_model_init_Reno(const char *filename)
   network_solve = lagrange_solve;
 
   update_model_description(surf_network_model_description,
-                             surf_network_model_description_size,
-                             "Reno",
-                             (surf_model_t) surf_network_model);
+                          "Reno",
+                          (surf_model_t) surf_network_model);
 }
 
 
@@ -838,9 +836,8 @@ void surf_network_model_init_Reno2(const char *filename)
   network_solve = lagrange_solve;
 
   update_model_description(surf_network_model_description,
-                             surf_network_model_description_size,
-                             "Reno2",
-                             (surf_model_t) surf_network_model);
+                          "Reno2",
+                          (surf_model_t) surf_network_model);
 }
 
 void surf_network_model_init_Vegas(const char *filename)
@@ -856,9 +853,8 @@ void surf_network_model_init_Vegas(const char *filename)
   network_solve = lagrange_solve;
 
   update_model_description(surf_network_model_description,
-                             surf_network_model_description_size,
-                             "Vegas",
-                             (surf_model_t) surf_network_model);
+                          "Vegas",
+                          (surf_model_t) surf_network_model);
 }
 
 #ifdef HAVE_SDP
@@ -873,9 +869,8 @@ void surf_network_model_init_SDP(const char *filename)
   network_solve = sdp_solve;
 
   update_model_description(surf_network_model_description,
-                             surf_network_model_description_size,
-                             "SDP",
-                             (surf_model_t) surf_network_model);
+                          "SDP",
+                          (surf_model_t) surf_network_model);
 }
 #endif
 
@@ -889,8 +884,7 @@ void surf_network_model_init_GTNETS(const char *filename)
   xbt_dynar_push(model_list, &surf_network_model);
 
   update_model_description(surf_network_model_description,
-                              surf_network_model_description_size,
-                              "GTNets",
-                              (surf_model_t) surf_network_model);
+                          "GTNets",
+                          (surf_model_t) surf_network_model);
 }
 #endif
index f961845..0cb800c 100644 (file)
@@ -400,7 +400,6 @@ void surf_network_model_init_Constant(const char *filename)
   xbt_dynar_push(model_list, &surf_network_model);
 
   update_model_description(surf_network_model_description,
-                             surf_network_model_description_size,
-                             "Constant",
-                             (surf_model_t) surf_network_model);
+                          "Constant",
+                          (surf_model_t) surf_network_model);
 }
index 0d56e1b..8a2a893 100644 (file)
@@ -126,7 +126,7 @@ const char *surf_action_state_names[6] = {
 };
 
 
-s_surf_model_description_t surf_network_model_description[surf_network_model_description_size] = {
+s_surf_model_description_t surf_network_model_description[] = {
   {"Constant", NULL, surf_network_model_init_Constant},
   {"CM02", NULL, surf_network_model_init_CM02},
 #ifdef HAVE_GTNETS
@@ -137,40 +137,42 @@ s_surf_model_description_t surf_network_model_description[surf_network_model_des
 #endif
   {"Reno", NULL, surf_network_model_init_Reno},
   {"Reno2", NULL, surf_network_model_init_Reno2},
-  {"Vegas", NULL, surf_network_model_init_Vegas}
+  {"Vegas", NULL, surf_network_model_init_Vegas},
+  { NULL,NULL,NULL} /* this array must be NULL terminated */
 };
 
-s_surf_model_description_t surf_cpu_model_description[surf_cpu_model_description_size] = {
+s_surf_model_description_t surf_cpu_model_description[] = {
   {"Cas01", NULL, surf_cpu_model_init_Cas01},
+  { NULL,NULL,NULL} /* this array must be NULL terminated */
 };
 
-s_surf_model_description_t surf_workstation_model_description[surf_workstation_model_description_size] = {
+s_surf_model_description_t surf_workstation_model_description[] = {
   {"CLM03", NULL, surf_workstation_model_init_CLM03, create_workstations},
   {"compound", NULL, surf_workstation_model_init_compound, create_workstations},
-  {"ptask_L07", NULL, surf_workstation_model_init_ptask_L07, NULL}
+  {"ptask_L07", NULL, surf_workstation_model_init_ptask_L07, NULL},
+  { NULL,NULL,NULL} /* this array must be NULL terminated */
 };
 
 void update_model_description(s_surf_model_description_t * table,
-                                int table_size,
-                                const char *name,
-                                surf_model_t model)
+                             const char *name,
+                             surf_model_t model)
 {
-  int i = find_model_description(table, table_size, name);
+  int i = find_model_description(table, name);
   table[i].model = model;
 }
 
 int find_model_description(s_surf_model_description_t * table,
-                             int table_size, const char *name)
+                          const char *name)
 {
   int i;
   char *name_list = NULL;
 
-  for (i = 0; i < table_size; i++)
+  for (i = 0; table[i].name; i++)
     if (!strcmp(name, table[i].name)) {
       return i;
     }
   name_list = strdup(table[0].name);
-  for (i = 1; i < table_size; i++) {
+  for (i = 1; table[i].name; i++) {
     name_list =
        xbt_realloc(name_list,
                    strlen(name_list) + strlen(table[i].name) + 2);
index 56650d5..177145b 100644 (file)
@@ -428,9 +428,8 @@ void surf_workstation_model_init_CLM03(const char *filename)
   surf_cpu_model_init_Cas01(filename);
   surf_network_model_init_CM02(filename);
   update_model_description(surf_workstation_model_description,
-                             surf_workstation_model_description_size,
-                             "CLM03",
-                             (surf_model_t) surf_workstation_model);
+                          "CLM03",
+                          (surf_model_t) surf_workstation_model);
   xbt_dynar_push(model_list, &surf_workstation_model);
 }
 
@@ -442,9 +441,8 @@ void surf_workstation_model_init_compound(const char *filename)
   surf_workstation_model_init_internal();
 
   update_model_description(surf_workstation_model_description,
-                             surf_workstation_model_description_size,
-                             "compound",
-                             (surf_model_t) surf_workstation_model);
+                          "compound",
+                          (surf_model_t) surf_workstation_model);
 
   xbt_dynar_push(model_list, &surf_workstation_model);
 }
index ec0c05e..4866f77 100644 (file)
@@ -1167,8 +1167,7 @@ void surf_workstation_model_init_ptask_L07(const char *filename)
   define_callbacks(filename);
 
   update_model_description(surf_workstation_model_description,
-                             surf_workstation_model_description_size,
-                             "ptask_L07",
-                             (surf_model_t) surf_workstation_model);
+                          "ptask_L07",
+                          (surf_model_t) surf_workstation_model);
   xbt_dynar_push(model_list, &surf_workstation_model);
 }