Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I think I now better understand the surf internals: each resource can be *either...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 27 Oct 2007 07:34:39 +0000 (07:34 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 27 Oct 2007 07:34:39 +0000 (07:34 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4895 48e7efb5-ca39-0410-a469-dd3cf9ba447f

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_gtnets.c
src/surf/workstation.c
src/surf/workstation_KCCFLN05.c
src/surf/workstation_ptask_L07.c

index db89c27..5c7e563 100644 (file)
@@ -142,11 +142,7 @@ typedef struct surf_model_public {
   void (*set_priority) (surf_action_t action, double priority); /**< Set the priority of an action */
   const char *name; /**< Name of this model */
 
-  /*for the properties of the link*/
-  xbt_dict_t (*get_link_properties) (void* link);
-
-  /*for the properties of the cpu*/
-  xbt_dict_t (*get_cpu_properties) (void* cpu);
+  xbt_dict_t (*get_properties) (void* link); /**< Return the properties dictionary */
 
 } s_surf_model_public_t, *surf_model_public_t;
 
index c7a30c2..e9637b5 100644 (file)
@@ -140,7 +140,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->common_public->get_link_properties(link->surf_link));
+  return (surf_workstation_model->common_public->get_properties(link->surf_link));
 
 }
 
index b7e97e8..fab8673 100644 (file)
@@ -153,7 +153,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->common_public->get_cpu_properties(workstation->surf_workstation));
+  return (surf_workstation_model->common_public->get_properties(workstation->surf_workstation));
 
 }
 
index c00faa5..e26ffb6 100644 (file)
@@ -221,7 +221,7 @@ xbt_dict_t SIMIX_host_get_properties(smx_host_t host)
   xbt_assert0((host != NULL), "Invalid parameters");
 
   return (surf_workstation_model->
-         common_public->get_cpu_properties(host->simdata->host));
+         common_public->get_properties(host->simdata->host));
 
 }
 
index eb6ca05..06bcaac 100644 (file)
@@ -31,7 +31,7 @@ static cpu_Cas01_t cpu_new(char *name, double power_scale,
   cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1);
 
   cpu->model = (surf_model_t) surf_cpu_model;
-  cpu->name = xbt_strdup(name);
+  cpu->name = name;
   cpu->power_scale = power_scale;
   xbt_assert0(cpu->power_scale > 0, "Power has to be >0");
   cpu->power_current = power_initial;
@@ -81,8 +81,8 @@ static void parse_cpu_init(void)
   surf_parse_get_trace(&state_trace, A_surfxml_host_state_file); 
 
   current_property_set = xbt_dict_new();
-  cpu_new(A_surfxml_host_id, power_scale, power_initial, power_trace, state_initial,
-         state_trace, /*add the properties*/ current_property_set);
+  cpu_new(xbt_strdup(A_surfxml_host_id), power_scale, power_initial, power_trace, state_initial,
+         state_trace,  current_property_set);
 
 }
 
@@ -426,7 +426,7 @@ static void surf_cpu_model_init_internal(void)
   surf_cpu_model->extension_public->get_available_speed =
       get_available_speed;
   /*manage the properties of the cpu*/
-  surf_cpu_model->common_public->get_cpu_properties = get_properties;
+  surf_cpu_model->common_public->get_properties = get_properties;
 
   if(!cpu_set) cpu_set = xbt_dict_new();
   if (!cpu_maxmin_system) cpu_maxmin_system = lmm_system_new();
index 9fb8024..771ca0d 100644 (file)
@@ -544,7 +544,7 @@ static double get_link_latency(const void *link)
   return ((link_CM02_t) link)->lat_current;
 }
 
-static xbt_dict_t get_link_property_list(void *link)
+static xbt_dict_t get_properties(void *link)
 {
  return ((link_CM02_t) link)->properties;
 }
@@ -674,8 +674,8 @@ static void surf_network_model_init_internal(void)
       get_link_bandwidth;
   surf_network_model->extension_public->get_link_latency =
       get_link_latency;
-  /*for the props of the link*/
-  surf_network_model->common_public->get_link_properties =  get_link_property_list;
+
+  surf_network_model->common_public->get_properties =  get_properties;
 
   link_set = xbt_dict_new();
   network_card_set = xbt_dict_new();
index 758ef59..ea7a810 100644 (file)
@@ -299,7 +299,7 @@ static const char *get_resource_name(void *resource_id)
   return ((network_card_GTNETS_t) resource_id)->name;
 }
 
-static xbt_dict_t get_link_property_list(void *link)
+static xbt_dict_t get_properties(void *link)
 {
   return ((network_card_GTNETS_t) link)->properties;
 }
@@ -587,7 +587,7 @@ static void surf_network_model_init_internal(void)
   surf_network_model->extension_public->communicate = communicate;
 
   /*for the props of the link*/
-  surf_network_model->common_public->get_link_properties =  get_link_property_list;
+  surf_network_model->common_public->get_properties =  get_properties;
 
   link_set = xbt_dict_new();
   network_card_set = xbt_dict_new();
index f4cac36..4afd973 100644 (file)
@@ -254,7 +254,7 @@ static double get_available_speed(void *workstation)
 static xbt_dict_t get_properties(void *workstation)
 {
   return surf_cpu_model->common_public->
-      get_cpu_properties(((workstation_CLM03_t) workstation)->cpu);
+      get_properties(((workstation_CLM03_t) workstation)->cpu);
 }
 
 static surf_action_t execute_parallel_task(int workstation_nb,
@@ -391,7 +391,7 @@ static void surf_workstation_model_init_internal(void)
       get_available_speed;
 
   /*manage the properties of the workstation*/
-  surf_workstation_model->common_public->get_cpu_properties = get_properties;
+  surf_workstation_model->common_public->get_properties = get_properties;
 
   surf_workstation_model->extension_public->communicate = communicate;
   surf_workstation_model->extension_public->execute_parallel_task =
index 5695942..fc56baf 100644 (file)
@@ -31,10 +31,10 @@ typedef struct router_KCCFLN05 {
 /********* cpu object *****************/
 /**************************************/
 typedef struct cpu_KCCFLN05 {
-  surf_model_t model;
-  xbt_dict_t properties;                /* Do not move this field */
-  e_surf_workstation_model_type_t type;        /* Do not move this field */
-  char *name;                          /* Do not move this field */
+  surf_model_t model;                   /* Do not move this field: must match model_obj_t */
+  xbt_dict_t properties;                /* Do not move this field: must match link_KCCFLN05_t */
+  e_surf_workstation_model_type_t type;        /* Do not move this field: must match link_KCCFLN05_t */
+  char *name;                          /* Do not move this field: must match link_KCCFLN05_t */
   lmm_constraint_t constraint;
   lmm_constraint_t bus;
   double power_scale;
@@ -55,10 +55,10 @@ typedef struct cpu_KCCFLN05 {
 /**************************************/
 
 typedef struct link_KCCFLN05 {
-  surf_model_t model;
-  xbt_dict_t properties;                /* Do not move this field */
-  e_surf_workstation_model_type_t type;        /* Do not move this field */
-  char *name;                          /* Do not move this field */
+  surf_model_t model;                   /* Do not move this field: must match model_obj_t */
+  xbt_dict_t properties;                /* Do not move this field: must match cpu_KCCFLN05_t */
+  e_surf_workstation_model_type_t type;        /* Do not move this field: must match cpu_KCCFLN05_t */
+  char *name;                          /* Do not move this field: must match cpu_KCCFLN05_t */
   lmm_constraint_t constraint;
   double lat_current;
   tmgr_trace_event_t lat_event;
@@ -103,7 +103,6 @@ static xbt_dict_t parallel_task_link_set = NULL;
 //added to work with GTNETS
 static xbt_dict_t router_set = NULL;
 static lmm_system_t maxmin_system = NULL;
-/*xbt_dict_t link_set = NULL;*/
 
 
 /* convenient function */
@@ -192,6 +191,13 @@ static const char *get_resource_name(void *resource_id)
   return ((cpu_KCCFLN05_t) resource_id)->name;
 }
 
+static xbt_dict_t get_properties(void *resource)
+{
+  /* We can freely cast as a cpu_KCCFLN05_t because it has the same
+     prefix as link_KCCFLN05_t. */
+  return ((cpu_KCCFLN05_t) resource)->properties;
+}
+
 /* action_get_state is inherited from the surf module */
 
 static void action_use(surf_action_t action)
@@ -633,11 +639,6 @@ static double get_available_speed(void *cpu)
   return ((cpu_KCCFLN05_t) cpu)->power_current;
 }
 
-static xbt_dict_t get_cpu_properties(void *cpu)
-{
-  return ((cpu_KCCFLN05_t) cpu)->properties;
-}
-
 static surf_action_t communicate(void *src, void *dst, double size,
                                 double rate)
 {
@@ -858,12 +859,6 @@ static double get_link_latency(const void *link)
   return ((link_KCCFLN05_t) link)->lat_current;
 }
 
-static xbt_dict_t get_link_properties(void *link)
-{
- return ((link_KCCFLN05_t) link)->properties;
-}
-
-
 /**************************************/
 /*** Resource Creation & Destruction **/
 /**************************************/
@@ -997,7 +992,7 @@ static void parse_cpu_init(void)
   current_property_set = xbt_dict_new();
   cpu_new(A_surfxml_host_id, power_scale, power_initial, power_trace,
          state_initial, state_trace, interference_send, interference_recv,
-         interference_send_recv, max_outgoing_rate,/*add the properties*/current_property_set);
+         interference_send_recv, max_outgoing_rate,current_property_set);
 }
 
 static void link_free(void *nw_link)
@@ -1297,8 +1292,7 @@ static void model_init_internal(void)
   surf_workstation_model->extension_public->get_available_speed =
       get_available_speed;
 
-  surf_workstation_model->common_public->get_cpu_properties = get_cpu_properties;
-  surf_workstation_model->common_public->get_link_properties = get_link_properties;
+  surf_workstation_model->common_public->get_properties = get_properties;
 
   surf_workstation_model->extension_public->communicate = communicate;
   surf_workstation_model->extension_public->execute_parallel_task =
index 1d2c49e..1a21049 100644 (file)
@@ -19,17 +19,17 @@ typedef enum {
 /********* cpu object *****************/
 /**************************************/
 typedef struct cpu_L07 {
-  surf_model_t model;  /* Do not move this field */
-  e_surf_workstation_model_type_t type;        /* Do not move this field */
-  char *name;                  /* Do not move this field */
-  lmm_constraint_t constraint; /* Do not move this field */
+  surf_model_t model;  /* Do not move this field: must match model_obj_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 */
+  char *name;                          /* 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;
   double power_current;
   tmgr_trace_event_t power_event;
   e_surf_cpu_state_t state_current;
   tmgr_trace_event_t state_event;
   int id;                      /* cpu and network card are a single object... */
-  xbt_dict_t properties;
 } s_cpu_L07_t, *cpu_L07_t;
 
 /**************************************/
@@ -37,18 +37,17 @@ typedef struct cpu_L07 {
 /**************************************/
 
 typedef struct link_L07 {
-  surf_model_t model;  /* Do not move this field */
-  e_surf_workstation_model_type_t type;        /* Do not move this field */
-  char *name;                  /* Do not move this field */
-  lmm_constraint_t constraint; /* Do not move this field */
+  surf_model_t model;  /* Do not move this field: must match model_obj_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 */
+  char *name;                          /* 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;
   tmgr_trace_event_t lat_event;
   double bw_current;
   tmgr_trace_event_t bw_event;
   e_surf_link_state_t state_current;
   tmgr_trace_event_t state_event;
-  /*holds the property list that can be associated with the link*/
-  xbt_dict_t properties;
 } s_link_L07_t, *link_L07_t;
 
 
@@ -135,6 +134,10 @@ static const char *get_resource_name(void *resource_id)
 
   return ((cpu_L07_t) resource_id)->name;
 }
+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;
+}
 
 /* action_get_state is inherited from the surf module */
 
@@ -470,12 +473,6 @@ static double get_available_speed(void *cpu)
   return ((cpu_L07_t) cpu)->power_current;
 }
 
-static xbt_dict_t get_properties(void *cpu)
-{
- return ((cpu_L07_t) cpu)->properties;
-}
-
-
 static surf_action_t execute_parallel_task(int workstation_nb,
                                           void **workstation_list,
                                           double *computation_amount,
@@ -669,12 +666,6 @@ static double get_link_latency(const void *link)
 }
 
 
-static xbt_dict_t get_link_properties(void *link)
-{
- return ((link_L07_t) link)->properties;
-}
-
-
 /**************************************/
 /*** Resource Creation & Destruction **/
 /**************************************/
@@ -751,7 +742,7 @@ static void parse_cpu_init(void)
 
   current_property_set = xbt_dict_new();
   cpu_new(A_surfxml_host_id, power_scale, power_initial, power_trace,
-         state_initial, state_trace,/*add the properties*/current_property_set);
+         state_initial, state_trace,current_property_set);
 }
 
 static void link_free(void *nw_link)
@@ -1026,8 +1017,7 @@ static void model_init_internal(void)
   surf_workstation_model->extension_public->get_link_latency =
       get_link_latency;
 
-  surf_workstation_model->common_public->get_link_properties = get_link_properties;
-  surf_workstation_model->common_public->get_cpu_properties = get_properties;
+  surf_workstation_model->common_public->get_properties = get_properties;
 
   workstation_set = xbt_dict_new();
   link_set = xbt_dict_new();