Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove xbt_dict_t workstations from SD_global.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:35:49 +0000 (10:35 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:35:49 +0000 (10:35 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9833 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simdag/private.h
src/simdag/sd_dotloader.c
src/simdag/sd_global.c
src/simdag/sd_workstation.c
src/simix/smx_environment.c
src/surf/cpu.c
src/surf/cpu_im.c
src/surf/cpu_ti.c
src/surf/workstation.c
src/surf/workstation_ptask_L07.c

index 27cef90..dce5fd6 100644 (file)
 /* Global variables */
 
 typedef struct SD_global {
 /* Global variables */
 
 typedef struct SD_global {
-  xbt_dict_t workstations;      /* workstation dictionary */
-  int workstation_count;        /* number of workstations */
   SD_workstation_t *workstation_list;   /* array of workstations, created only if
                                            necessary in SD_workstation_get_list */
   SD_workstation_t *workstation_list;   /* array of workstations, created only if
                                            necessary in SD_workstation_get_list */
-
   SD_link_t *link_list;         /* array of links, created only if
                                    necessary in SD_link_get_list */
   SD_link_t *recyclable_route;  /* array returned by SD_route_get_list
   SD_link_t *link_list;         /* array of links, created only if
                                    necessary in SD_link_get_list */
   SD_link_t *recyclable_route;  /* array returned by SD_route_get_list
index 9da658e..f2ee1a6 100644 (file)
@@ -309,7 +309,7 @@ void dot_add_task(Agnode_t * dag_node)
         computer = xbt_dynar_new(sizeof(SD_task_t), NULL);
         xbt_dict_set(computers, char_performer, computer, NULL);
       }
         computer = xbt_dynar_new(sizeof(SD_task_t), NULL);
         xbt_dict_set(computers, char_performer, computer, NULL);
       }
-      if(performer < sd_global->workstation_count){
+      if(performer < host_lib->count){
         // the  wanted computer is available
         SD_task_t *task_test = NULL;
         if(order < computer->used)
         // the  wanted computer is available
         SD_task_t *task_test = NULL;
         if(order < computer->used)
index 5378f89..30f5d47 100644 (file)
@@ -61,8 +61,6 @@ void SD_init(int *argc, char **argv)
 
 
   sd_global = xbt_new(s_SD_global_t, 1);
 
 
   sd_global = xbt_new(s_SD_global_t, 1);
-  sd_global->workstations = xbt_dict_new();
-  sd_global->workstation_count = 0;
   sd_global->workstation_list = NULL;
   sd_global->link_list = NULL;
   sd_global->recyclable_route = NULL;
   sd_global->workstation_list = NULL;
   sd_global->link_list = NULL;
   sd_global->recyclable_route = NULL;
@@ -182,10 +180,10 @@ void SD_application_reinit(void)
  */
 void SD_create_environment(const char *platform_file)
 {
  */
 void SD_create_environment(const char *platform_file)
 {
-  xbt_dict_cursor_t cursor = NULL;
+  xbt_lib_cursor_t cursor = NULL;
   char *name = NULL;
   char *name = NULL;
-  void *surf_workstation = NULL;
-  void *surf_link = NULL;
+  void **surf_workstation = NULL;
+  void **surf_link = NULL;
 
   platform_filename = bprintf("%s",platform_file);
 
 
   platform_filename = bprintf("%s",platform_file);
 
@@ -198,14 +196,13 @@ void SD_create_environment(const char *platform_file)
   surf_config_models_create_elms();
 
   /* now let's create the SD wrappers for workstations and links */
   surf_config_models_create_elms();
 
   /* now let's create the SD wrappers for workstations and links */
-  xbt_dict_foreach(surf_model_resource_set(surf_workstation_model), cursor,
-                   name, surf_workstation) {
-    __SD_workstation_create(surf_workstation, NULL);
+  xbt_lib_foreach(host_lib, cursor, name, surf_workstation){
+         if(surf_workstation[SURF_WKS_LEVEL])
+                 __SD_workstation_create(surf_workstation[SURF_WKS_LEVEL], NULL);
   }
 
   }
 
-  xbt_dict_foreach(surf_model_resource_set(surf_network_model), cursor,
-                   name, surf_link) {
-    __SD_link_create(surf_link, NULL);
+  xbt_lib_foreach(link_lib, cursor, name, surf_link) {
+    __SD_link_create(surf_link[SURF_LINK_LEVEL], NULL);
   }
 
   XBT_DEBUG("Workstation number: %d, link number: %d",
   }
 
   XBT_DEBUG("Workstation number: %d, link number: %d",
@@ -402,7 +399,6 @@ void SD_exit(void)
 #endif
   if (SD_INITIALISED()) {
     XBT_DEBUG("Destroying workstation and link dictionaries...");
 #endif
   if (SD_INITIALISED()) {
     XBT_DEBUG("Destroying workstation and link dictionaries...");
-    xbt_dict_free(&sd_global->workstations);
 
     XBT_DEBUG("Destroying workstation and link arrays if necessary...");
     if (sd_global->workstation_list != NULL)
 
     XBT_DEBUG("Destroying workstation and link arrays if necessary...");
     if (sd_global->workstation_list != NULL)
index 0a8c3ee..1044c91 100644 (file)
@@ -32,9 +32,7 @@ SD_workstation_t __SD_workstation_create(void *surf_workstation,
   workstation->current_task = NULL;
 
   name = SD_workstation_get_name(workstation);
   workstation->current_task = NULL;
 
   name = SD_workstation_get_name(workstation);
-  xbt_dict_set(sd_global->workstations, name, workstation, __SD_workstation_destroy);   /* add the workstation to the dictionary */
-  sd_global->workstation_count++;
-
+  xbt_lib_set(host_lib,name,SD_HOST_LEVEL,workstation);
   return workstation;
 }
 
   return workstation;
 }
 
@@ -52,7 +50,7 @@ SD_workstation_t SD_workstation_get_by_name(const char *name)
 
   xbt_assert0(name != NULL, "Invalid parameter");
 
 
   xbt_assert0(name != NULL, "Invalid parameter");
 
-  return xbt_dict_get_or_null(sd_global->workstations, name);
+  return xbt_lib_get_or_null(host_lib, name, SD_HOST_LEVEL);
 }
 
 /**
 }
 
 /**
@@ -66,9 +64,9 @@ SD_workstation_t SD_workstation_get_by_name(const char *name)
 const SD_workstation_t *SD_workstation_get_list(void)
 {
 
 const SD_workstation_t *SD_workstation_get_list(void)
 {
 
-  xbt_dict_cursor_t cursor;
+  xbt_lib_cursor_t cursor;
   char *key;
   char *key;
-  void *data;
+  void **data;
   int i;
 
   SD_CHECK_INIT_DONE();
   int i;
 
   SD_CHECK_INIT_DONE();
@@ -76,11 +74,12 @@ const SD_workstation_t *SD_workstation_get_list(void)
 
   if (sd_global->workstation_list == NULL) {    /* this is the first time the function is called */
     sd_global->workstation_list =
 
   if (sd_global->workstation_list == NULL) {    /* this is the first time the function is called */
     sd_global->workstation_list =
-        xbt_new(SD_workstation_t, sd_global->workstation_count);
+        xbt_new(SD_workstation_t, host_lib->count);
 
     i = 0;
 
     i = 0;
-    xbt_dict_foreach(sd_global->workstations, cursor, key, data) {
-      sd_global->workstation_list[i++] = (SD_workstation_t) data;
+    xbt_lib_foreach(host_lib, cursor, key, data) {
+      if(data[SD_HOST_LEVEL])
+         sd_global->workstation_list[i++] = (SD_workstation_t) data[SD_HOST_LEVEL];
     }
   }
   return sd_global->workstation_list;
     }
   }
   return sd_global->workstation_list;
@@ -95,7 +94,7 @@ const SD_workstation_t *SD_workstation_get_list(void)
 int SD_workstation_get_number(void)
 {
   SD_CHECK_INIT_DONE();
 int SD_workstation_get_number(void)
 {
   SD_CHECK_INIT_DONE();
-  return sd_global->workstation_count;
+  return host_lib->count;
 }
 
 /**
 }
 
 /**
index ba8f2e2..600d6da 100644 (file)
@@ -33,9 +33,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix,
  */
 void SIMIX_create_environment(const char *file)
 {
  */
 void SIMIX_create_environment(const char *file)
 {
-  xbt_dict_cursor_t cursor = NULL;
+  xbt_lib_cursor_t cursor = NULL;
   char *name = NULL;
   char *name = NULL;
-  void *workstation = NULL;
+  void **workstation = NULL;
 
   double start, end;
 
 
   double start, end;
 
@@ -54,9 +54,9 @@ void SIMIX_create_environment(const char *file)
   end = xbt_os_time();
   XBT_DEBUG("PARSE TIME: %lg", (end - start));
 
   end = xbt_os_time();
   XBT_DEBUG("PARSE TIME: %lg", (end - start));
 
-  xbt_dict_foreach(surf_model_resource_set(surf_workstation_model), cursor,
-                   name, workstation) {
-    SIMIX_host_create(name, workstation, NULL);
+  xbt_lib_foreach(host_lib, cursor, name, workstation) {
+         if(workstation[SURF_WKS_LEVEL])
+                 SIMIX_host_create(name, workstation[SURF_WKS_LEVEL], NULL);
   }
   surf_presolve();
 }
   }
   surf_presolve();
 }
index d25b8ba..2b7f602 100644 (file)
@@ -65,8 +65,7 @@ static cpu_Cas01_t cpu_new(char *name, double power_peak,
       lmm_constraint_new(cpu_maxmin_system, cpu,
                          cpu->core * cpu->power_scale * cpu->power_peak);
 
       lmm_constraint_new(cpu_maxmin_system, cpu,
                          cpu->core * cpu->power_scale * cpu->power_peak);
 
-  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
-               surf_resource_free);
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
   return cpu;
 }
 
   return cpu;
 }
index 42d7988..492191b 100644 (file)
@@ -83,8 +83,7 @@ static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
       lmm_constraint_new(cpu_im_maxmin_system, cpu,
                          cpu->core * cpu->power_scale * cpu->power_peak);
 
       lmm_constraint_new(cpu_im_maxmin_system, cpu,
                          cpu->core * cpu->power_scale * cpu->power_peak);
 
-  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
-               surf_resource_free);
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
   cpu->action_set = xbt_swag_new(xbt_swag_offset(action, cpu_list_hookup));
 
   return cpu;
   cpu->action_set = xbt_swag_new(xbt_swag_offset(action, cpu_list_hookup));
 
   return cpu;
@@ -344,19 +343,23 @@ static void cpu_im_update_actions_state(double now, double delta)
   {
     //defining the last timestamp that we can safely dump to trace file
     //without losing the event ascending order (considering all CPU's)
   {
     //defining the last timestamp that we can safely dump to trace file
     //without losing the event ascending order (considering all CPU's)
+       void **data;
     cpu_Cas01_im_t cpu;
     xbt_dict_cursor_t cursor;
     char *key;
     double smaller = -1;
     cpu_Cas01_im_t cpu;
     xbt_dict_cursor_t cursor;
     char *key;
     double smaller = -1;
-    xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key, cpu){
-      if (smaller < 0){
-        smaller = cpu->last_update;
-        continue;
-      }
-      if (cpu->last_update < smaller){
-        smaller = cpu->last_update;
-      }
-    }
+    xbt_lib_foreach(host_lib, cursor, key, data){
+       if(data[SURF_CPU_LEVEL]){
+         cpu = data[SURF_CPU_LEVEL];
+                 if (smaller < 0){
+                       smaller = cpu->last_update;
+                       continue;
+                 }
+                 if (cpu->last_update < smaller){
+                       smaller = cpu->last_update;
+                 }
+       }
+   }
     if (smaller > 0) {
       TRACE_last_timestamp_to_dump = smaller;
     }
     if (smaller > 0) {
       TRACE_last_timestamp_to_dump = smaller;
     }
@@ -589,13 +592,16 @@ static void cpu_im_create_resource(char *name, double power_peak,
 
 static void cpu_im_finalize(void)
 {
 
 static void cpu_im_finalize(void)
 {
-  void *cpu;
-  xbt_dict_cursor_t cursor;
+  void **cpu;
+  xbt_lib_cursor_t cursor;
   char *key;
   char *key;
-  xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key,
-                   cpu) {
-    cpu_Cas01_im_t CPU = cpu;
-    xbt_swag_free(CPU->action_set);
+
+  xbt_lib_foreach(host_lib, cursor, key, cpu){
+         if(cpu[SURF_CPU_LEVEL])
+         {
+                   cpu_Cas01_im_t CPU = cpu[SURF_CPU_LEVEL];
+                   xbt_swag_free(CPU->action_set);
+         }
   }
 
   lmm_system_free(cpu_im_maxmin_system);
   }
 
   lmm_system_free(cpu_im_maxmin_system);
index 5714ff0..dd16979 100644 (file)
@@ -185,8 +185,7 @@ static cpu_ti_t cpu_ti_new(char *name, double power_peak,
                                  cpu->avail_trace->last_time, 0, cpu);
     }
   }
                                  cpu->avail_trace->last_time, 0, cpu);
     }
   }
-  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
-               surf_resource_free);
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
   return cpu;
 }
 
   return cpu;
 }
@@ -762,14 +761,17 @@ static void cpu_ti_create_resource(char *name, double power_peak,
 
 static void cpu_ti_finalize(void)
 {
 
 static void cpu_ti_finalize(void)
 {
-  void *cpu;
-  xbt_dict_cursor_t cursor;
+  void **cpu;
+  xbt_lib_cursor_t cursor;
   char *key;
   char *key;
-  xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key,
-                   cpu) {
-    cpu_ti_t CPU = cpu;
-    xbt_swag_free(CPU->action_set);
-    surf_cpu_ti_free_tmgr(CPU->avail_trace);
+
+  xbt_lib_foreach(host_lib, cursor, key, cpu){
+         if(cpu[SURF_CPU_LEVEL])
+         {
+                   cpu_ti_t CPU = cpu[SURF_CPU_LEVEL];
+                   xbt_swag_free(CPU->action_set);
+                   surf_cpu_ti_free_tmgr(CPU->avail_trace);
+         }
   }
 
   surf_model_exit(surf_cpu_model);
   }
 
   surf_model_exit(surf_cpu_model);
index 457cfe3..5e49482 100644 (file)
@@ -27,21 +27,20 @@ static workstation_CLM03_t workstation_new(const char *name, void *cpu)
   workstation->generic_resource.name = xbt_strdup(name);
   workstation->cpu = cpu;
 
   workstation->generic_resource.name = xbt_strdup(name);
   workstation->cpu = cpu;
 
-  xbt_dict_set(surf_model_resource_set(surf_workstation_model), name,
-               workstation, surf_resource_free);
+  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, workstation);
 
   return workstation;
 }
 
 void create_workstations(void)
 {
 
   return workstation;
 }
 
 void create_workstations(void)
 {
-  xbt_dict_cursor_t cursor = NULL;
+  xbt_lib_cursor_t cursor = NULL;
   char *name = NULL;
   char *name = NULL;
-  void *cpu = NULL;
+  void **cpu = NULL;
 
 
-  xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, name,
-                   cpu) {
-    workstation_new(name, cpu);
+  xbt_lib_foreach(host_lib, cursor, name, cpu) {
+         if(cpu[SURF_CPU_LEVEL])
+                 workstation_new(name, cpu[SURF_CPU_LEVEL]);
   }
 }
 
   }
 }
 
index 595001e..315dc66 100644 (file)
@@ -649,8 +649,7 @@ static cpu_L07_t ptask_cpu_new(const char *name, double power_scale,
       lmm_constraint_new(ptask_maxmin_system, cpu,
                          cpu->power_current * cpu->power_scale);
 
       lmm_constraint_new(ptask_maxmin_system, cpu,
                          cpu->power_current * cpu->power_scale);
 
-  xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu,
-               surf_resource_free);
+  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, cpu);
 
   return cpu;
 }
 
   return cpu;
 }