Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Integrate properties into surf_resource_t
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Jul 2009 07:59:18 +0000 (07:59 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Jul 2009 07:59:18 +0000 (07:59 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6436 48e7efb5-ca39-0410-a469-dd3cf9ba447f

13 files changed:
ChangeLog
src/include/surf/surf.h
src/simdag/sd_link.c
src/simdag/sd_workstation.c
src/simix/smx_host.c
src/surf/cpu.c
src/surf/network.c
src/surf/network_constant.c
src/surf/network_gtnets_private.h
src/surf/network_private.h
src/surf/surf_resource.c
src/surf/workstation.c
src/surf/workstation_ptask_L07.c

index 6b8bc06..78a962d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,7 +30,9 @@ SimGrid (3.3.2-svn) unstable; urgency=low
       
   * Implement a generic resource; use it as ancestor to specific ones
     (allows to kill duplicated code in models)
-    TODO: integrate the properties into that ancestor
+    Drawback: timer command don't need no name nor properties;
+              workstation_CLM03 don't need no properties
+    (but I guess we can live with those few bytes wasted)
     
  XBT:
   * Add xbt_set_get_by_name_or_null() [Silas De Munck]
index 3f17b78..2790d9b 100644 (file)
@@ -230,7 +230,6 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
        void (*set_max_duration) (surf_action_t action, double duration);/**< Set the max duration of an action*/
        void (*set_priority) (surf_action_t action, double priority);/**< Set the priority of an action */
 
-       xbt_dict_t(*get_properties) (void *resource_id);/**< Return the properties dictionary */
        xbt_dict_t resource_set;
 
 
@@ -256,9 +255,11 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
      typedef struct surf_resource {
        surf_model_t model;
        char *name;
+       xbt_dict_t properties;
      } s_surf_resource_t, *surf_resource_t;
 
-XBT_PUBLIC(const char*) surf_resource_name(const void *resource);
+     XBT_PUBLIC(const char*) surf_resource_name(const void *resource);
+     XBT_PUBLIC(xbt_dict_t) surf_resource_properties(const void *resource);
 XBT_PUBLIC(void) surf_resource_free(void* resource);
 /**************************************/
 /* Implementations of model object */
index 27b2d8b..5cc896b 100644 (file)
@@ -153,7 +153,7 @@ xbt_dict_t SD_link_get_properties(SD_link_t link)
   SD_CHECK_INIT_DONE();
   xbt_assert0((link != NULL), "Invalid parameters");
 
-  return (surf_workstation_model->get_properties(link->surf_link));
+  return surf_resource_properties(link->surf_link);
 
 }
 
index f8bf3c0..cad1f73 100644 (file)
@@ -162,8 +162,7 @@ xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
   SD_CHECK_INIT_DONE();
   xbt_assert0((workstation != NULL), "Invalid parameters");
 
-  return (surf_workstation_model->get_properties
-          (workstation->surf_workstation));
+  return surf_resource_properties(workstation->surf_workstation);
 
 }
 
index cfb76cf..73f4cfb 100644 (file)
@@ -233,7 +233,7 @@ xbt_dict_t SIMIX_host_get_properties(smx_host_t host)
 {
   xbt_assert0((host != NULL), "Invalid parameters");
 
-  return (surf_workstation_model->get_properties(host->simdata->host));
+  return surf_resource_properties(host->simdata->host);
 
 }
 
index ba3fa0c..ca63f90 100644 (file)
@@ -21,8 +21,6 @@ typedef struct cpu_Cas01 {
   e_surf_cpu_state_t state_current;
   tmgr_trace_event_t state_event;
   lmm_constraint_t constraint;
-  /*Handles the properties that can be added to cpu's */
-  xbt_dict_t properties;
 } s_cpu_Cas01_t, *cpu_Cas01_t;
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
@@ -36,12 +34,6 @@ lmm_system_t cpu_maxmin_system = NULL;
 
 static xbt_swag_t running_action_set_that_does_not_need_being_checked = NULL;
 
-static void cpu_free(void *cpu)
-{
-  xbt_dict_free(&(((cpu_Cas01_t) cpu)->properties));
-  surf_resource_free(cpu);
-}
-
 static cpu_Cas01_t cpu_new(char *name, double power_scale,
                            double power_initial,
                            tmgr_trace_t power_trace,
@@ -54,6 +46,7 @@ static cpu_Cas01_t cpu_new(char *name, double power_scale,
               "Host '%s' declared several times in the platform file", name);
   cpu->generic_resource.model = surf_cpu_model;
   cpu->generic_resource.name = name;
+  current_property_set = cpu->generic_resource.properties = cpu_properties;
   cpu->power_scale = power_scale;
   xbt_assert0(cpu->power_scale > 0, "Power has to be >0");
   cpu->power_current = power_initial;
@@ -70,12 +63,7 @@ static cpu_Cas01_t cpu_new(char *name, double power_scale,
     lmm_constraint_new(cpu_maxmin_system, cpu,
                        cpu->power_current * cpu->power_scale);
 
-  /*add the property set */
-  cpu->properties = cpu_properties;
-
-  current_property_set = cpu_properties;
-
-  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, cpu_free);
+  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, surf_resource_free);
 
   return cpu;
 }
@@ -388,11 +376,6 @@ static double get_available_speed(void *cpu)
   return ((cpu_Cas01_t) cpu)->power_current;
 }
 
-static xbt_dict_t get_properties(void *cpu)
-{
-  return ((cpu_Cas01_t) cpu)->properties;
-}
-
 static void finalize(void)
 {
   lmm_system_free(cpu_maxmin_system);
@@ -438,8 +421,6 @@ static void surf_cpu_model_init_internal(void)
   surf_cpu_model->extension.cpu.get_state = get_state;
   surf_cpu_model->extension.cpu.get_speed = get_speed;
   surf_cpu_model->extension.cpu.get_available_speed = get_available_speed;
-  /*manage the properties of the cpu */
-  surf_cpu_model->get_properties = get_properties;
 
   if (!cpu_maxmin_system)
     cpu_maxmin_system = lmm_system_new();
index a5edbe0..d55e71b 100644 (file)
@@ -25,11 +25,6 @@ int host_count = 0;
 double sg_tcp_gamma = 0.0;
 
 
-static void link_free(void *nw_link)
-{
-  xbt_dict_free(&(((link_CM02_t) nw_link)->properties));
-  surf_resource_free(nw_link);
-}
 
 static link_CM02_t link_new(char *name,
                             double bw_initial,
@@ -48,6 +43,7 @@ static link_CM02_t link_new(char *name,
 
   nw_link->generic_resource.model = surf_network_model;
   nw_link->generic_resource.name = name;
+  current_property_set = nw_link->generic_resource.properties = properties;
   nw_link->bw_current = bw_initial;
   if (bw_trace)
     nw_link->bw_event =
@@ -68,11 +64,7 @@ static link_CM02_t link_new(char *name,
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(nw_link->constraint);
 
-  nw_link->properties = properties;
-
-  current_property_set = properties;
-
-  xbt_dict_set(surf_network_model->resource_set, name, nw_link, link_free);
+  xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free);
 
   return nw_link;
 }
@@ -464,11 +456,6 @@ static int link_shared(const void *link)
   return lmm_constraint_is_shared(((link_CM02_t) link)->constraint);
 }
 
-static xbt_dict_t get_properties(void *link)
-{
-  return ((link_CM02_t) link)->properties;
-}
-
 static void action_suspend(surf_action_t action)
 {
   ((surf_action_network_CM02_t) action)->suspended = 1;
@@ -537,8 +524,6 @@ static void surf_network_model_init_internal(void)
   surf_network_model->extension.network.get_link_latency = get_link_latency;
   surf_network_model->extension.network.link_shared = link_shared;
 
-  surf_network_model->get_properties = get_properties;
-
   if (!network_maxmin_system)
     network_maxmin_system = lmm_system_new();
 
index c75fb23..7ed8284 100644 (file)
@@ -175,11 +175,6 @@ static int link_shared(const void *link)
   DIE_IMPOSSIBLE;
 }
 
-static xbt_dict_t get_properties(void *link)
-{
-  DIE_IMPOSSIBLE;
-}
-
 static void action_suspend(surf_action_t action)
 {
   ((surf_action_network_Constant_t) action)->suspended = 1;
@@ -237,8 +232,6 @@ static void surf_network_model_init_internal(void)
   surf_network_model->extension.network.get_link_latency = get_link_latency;
   surf_network_model->extension.network.link_shared = link_shared;
 
-  surf_network_model->get_properties = get_properties;
-
   if (!random_latency)
     random_latency = random_new(RAND, 100, 0.0, 1.0, .125, .034);
 }
index 0687521..c7375f1 100644 (file)
@@ -18,16 +18,12 @@ typedef struct network_link_GTNETS {
   double bw_current;
   double lat_current;
   int id;
-  /*holds the properties associated with the link */
-  xbt_dict_t properties;
 } s_network_link_GTNETS_t, *network_link_GTNETS_t;
 
 
 typedef struct network_card_GTNETS {
   char *name;
   int id;
-  /*holds the properties associated with the card */
-  xbt_dict_t properties;
 } s_network_card_GTNETS_t, *network_card_GTNETS_t;
 
 typedef struct surf_action_network_GTNETS {
index eeac6d0..98f984d 100644 (file)
@@ -15,7 +15,6 @@
 typedef struct network_link_CM02 {
   s_surf_resource_t generic_resource; /* must remain first to be added to a trace */
 
-  xbt_dict_t properties;
   /* Using this object with the public part of
      model does not make sense */
   double bw_current;
index 111408b..4c2e821 100644 (file)
@@ -11,6 +11,8 @@ void surf_resource_free(void* r) {
   surf_resource_t resource = r;
   if (resource->name)
     free(resource->name);
+  if (resource->properties)
+    xbt_dict_free(&resource->properties);
   free(resource);
 }
 
index ce87967..92e8a9d 100644 (file)
@@ -216,12 +216,6 @@ static double get_available_speed(void *workstation)
                              workstation)->cpu);
 }
 
-static xbt_dict_t get_properties(void *workstation)
-{
-  return surf_cpu_model->get_properties(((workstation_CLM03_t) workstation)->
-                                        cpu);
-}
-
 static surf_action_t execute_parallel_task(int workstation_nb,
                                            void **workstation_list,
                                            double *computation_amount,
@@ -292,9 +286,6 @@ static void surf_workstation_model_init_internal(void)
   surf_workstation_model->extension.workstation.get_available_speed =
     get_available_speed;
 
-  /*manage the properties of the workstation */
-  surf_workstation_model->get_properties = get_properties;
-
   surf_workstation_model->extension.workstation.communicate = communicate;
   surf_workstation_model->extension.workstation.get_route = get_route;
   surf_workstation_model->extension.workstation.execute_parallel_task =
index 5d98c7b..7793af2 100644 (file)
@@ -20,7 +20,6 @@ typedef enum {
 /**************************************/
 typedef struct cpu_L07 {
   s_surf_resource_t generic_resource;  /* Do not move this field: must match surf_resource_t */
-  xbt_dict_t properties;        /* Do not move this field: must match link_L07_t */
   e_surf_workstation_model_type_t type; /* Do not move this field: must match link_L07_t */
   lmm_constraint_t constraint;  /* Do not move this field: must match link_L07_t */
   double power_scale;
@@ -37,7 +36,6 @@ typedef struct cpu_L07 {
 
 typedef struct link_L07 {
   s_surf_resource_t generic_resource;  /* Do not move this field: must match surf_resource_t */
-  xbt_dict_t properties;        /* Do not move this field: must match link_L07_t */
   e_surf_workstation_model_type_t type; /* Do not move this field: must match cpu_L07_t */
   lmm_constraint_t constraint;  /* Do not move this field: must match cpu_L07_t */
   double lat_current;
@@ -113,12 +111,6 @@ static void update_action_bound(surf_action_workstation_L07_t action)
 /******* Resource Public     **********/
 /**************************************/
 
-static xbt_dict_t get_properties(void *r)
-{
-  /* We can freely cast as a cpu_L07_t since it has the same prefix than link_L07_t */
-  return ((cpu_L07_t) r)->properties;
-}
-
 static int action_unref(surf_action_t action)
 {
   action->refcount--;
@@ -599,12 +591,6 @@ static int link_shared(const void *link)
 /*** Resource Creation & Destruction **/
 /**************************************/
 
-static void cpu_free(void *cpu)
-{
-  xbt_dict_free(&(((cpu_L07_t) cpu)->properties));
-  surf_resource_free(cpu);
-}
-
 static cpu_L07_t cpu_new(const char *name, double power_scale,
                          double power_initial,
                          tmgr_trace_t power_trace,
@@ -618,6 +604,7 @@ static cpu_L07_t cpu_new(const char *name, double power_scale,
   cpu->generic_resource.model = surf_workstation_model;
   cpu->type = SURF_WORKSTATION_RESOURCE_CPU;
   cpu->generic_resource.name = xbt_strdup(name);
+  cpu->generic_resource.properties = current_property_set;
   cpu->id = host_count++;
 
   cpu->power_scale = power_scale;
@@ -637,11 +624,8 @@ static cpu_L07_t cpu_new(const char *name, double power_scale,
     lmm_constraint_new(ptask_maxmin_system, cpu,
                        cpu->power_current * cpu->power_scale);
 
-  /*add the property set */
-  cpu->properties = current_property_set;
-
   xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu,
-               cpu_free);
+               surf_resource_free);
 
   return cpu;
 }
@@ -672,12 +656,6 @@ static void parse_cpu_init(void)
           state_initial, state_trace, current_property_set);
 }
 
-static void link_free(void *nw_link)
-{
-  xbt_dict_free(&(((link_L07_t) nw_link)->properties));
-  surf_resource_free(nw_link);
-}
-
 static link_L07_t link_new(char *name,
                            double bw_initial,
                            tmgr_trace_t bw_trace,
@@ -694,8 +672,9 @@ static link_L07_t link_new(char *name,
               "Link '%s' declared several times in the platform file.", name);
 
   nw_link->generic_resource.model = surf_workstation_model;
-  nw_link->type = SURF_WORKSTATION_RESOURCE_LINK;
+  nw_link->generic_resource.properties = properties;
   nw_link->generic_resource.name = name;
+  nw_link->type = SURF_WORKSTATION_RESOURCE_LINK;
   nw_link->bw_current = bw_initial;
   if (bw_trace)
     nw_link->bw_event =
@@ -715,9 +694,8 @@ static link_L07_t link_new(char *name,
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(nw_link->constraint);
 
-  nw_link->properties = properties;
 
-  xbt_dict_set(surf_network_model->resource_set, name, nw_link, link_free);
+  xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free);
 
   return nw_link;
 }
@@ -875,8 +853,6 @@ static void model_init_internal(void)
     get_link_latency;
   surf_workstation_model->extension.workstation.link_shared = link_shared;
 
-  surf_workstation_model->get_properties = get_properties;
-
   if (!ptask_maxmin_system)
     ptask_maxmin_system = lmm_system_new();