Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill link_set (use surf_network_model->resource_set instead)
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Jul 2009 07:58:52 +0000 (07:58 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Jul 2009 07:58:52 +0000 (07:58 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6434 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
src/include/surf/surf.h
src/simdag/sd_global.c
src/surf/cpu.c
src/surf/network.c
src/surf/network_gtnets.c
src/surf/surf_routing.c
src/surf/workstation_ptask_L07.c

index 9e64549..6b8bc06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ SimGrid (3.3.2-svn) unstable; urgency=low
      Allows to implement other ways of storing that info)
     => kill now useless network_card concept
     - Use dynar to represent routes (instead of void** + int*)
      Allows to implement other ways of storing that info)
     => kill now useless network_card concept
     - Use dynar to represent routes (instead of void** + int*)
+    - kill link_set (use surf_network_model->resource_set instead)
 
   * Simplify model declaration
     (less redirections, less function to write when defining a model)
 
   * Simplify model declaration
     (less redirections, less function to write when defining a model)
index 1cb37e5..3f17b78 100644 (file)
@@ -492,22 +492,6 @@ XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char *filename);
 XBT_PUBLIC_DATA(s_surf_model_description_t)
   surf_workstation_model_description[];
 
 XBT_PUBLIC_DATA(s_surf_model_description_t)
   surf_workstation_model_description[];
 
-/** \brief The network links
- *  \ingroup SURF_models
- *
- *  This dict contains all network links.
- *
- *  \see workstation_set
- */
-XBT_PUBLIC_DATA(xbt_dict_t) link_set;
-
-/** \brief The workstations
- *  \ingroup SURF_models
- *
- *  This dict contains all workstations.
- *
- *  \see link_set
- */
 /** \brief List of initialized models
  *  \ingroup SURF_models
  */
 /** \brief List of initialized models
  *  \ingroup SURF_models
  */
index c927951..c2817fc 100644 (file)
@@ -167,7 +167,7 @@ void SD_create_environment(const char *platform_file)
     __SD_workstation_create(surf_workstation, NULL);
   }
 
     __SD_workstation_create(surf_workstation, NULL);
   }
 
-  xbt_dict_foreach(link_set, cursor, name, surf_link) {
+  xbt_dict_foreach(surf_model_resource_set(surf_network_model), cursor, name, surf_link) {
     __SD_link_create(surf_link, NULL);
   }
 
     __SD_link_create(surf_link, NULL);
   }
 
index ee3ab22..ba3fa0c 100644 (file)
@@ -15,7 +15,6 @@ typedef struct surf_action_cpu_Cas01 {
 
 typedef struct cpu_Cas01 {
   s_surf_resource_t generic_resource;
 
 typedef struct cpu_Cas01 {
   s_surf_resource_t generic_resource;
-  char *name;
   double power_scale;
   double power_current;
   tmgr_trace_event_t power_event;
   double power_scale;
   double power_current;
   tmgr_trace_event_t power_event;
@@ -270,7 +269,7 @@ static surf_action_t execute(void *cpu, double size)
   surf_action_cpu_Cas01_t action = NULL;
   cpu_Cas01_t CPU = cpu;
 
   surf_action_cpu_Cas01_t action = NULL;
   cpu_Cas01_t CPU = cpu;
 
-  XBT_IN2("(%s,%g)", CPU->name, size);
+  XBT_IN2("(%s,%g)", CPU->generic_resource.name, size);
   action = xbt_new0(s_surf_action_cpu_Cas01_t, 1);
 
   action->generic_action.refcount = 1;
   action = xbt_new0(s_surf_action_cpu_Cas01_t, 1);
 
   action->generic_action.refcount = 1;
@@ -308,7 +307,7 @@ static surf_action_t action_sleep(void *cpu, double duration)
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
-  XBT_IN2("(%s,%g)", ((cpu_Cas01_t) cpu)->name, duration);
+  XBT_IN2("(%s,%g)", ((cpu_Cas01_t) cpu)->generic_resource.name, duration);
   action = (surf_action_cpu_Cas01_t) execute(cpu, 1.0);
   action->generic_action.max_duration = duration;
   action->suspended = 2;
   action = (surf_action_cpu_Cas01_t) execute(cpu, 1.0);
   action->generic_action.max_duration = duration;
   action->suspended = 2;
index 4b828ca..a5edbe0 100644 (file)
@@ -15,7 +15,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
 surf_model_t surf_network_model = NULL;
 static lmm_system_t network_maxmin_system = NULL;
 static void (*network_solve) (lmm_system_t) = NULL;
 surf_model_t surf_network_model = NULL;
 static lmm_system_t network_maxmin_system = NULL;
 static void (*network_solve) (lmm_system_t) = NULL;
-xbt_dict_t link_set = NULL;
 
 double latency_factor = 1.0;    /* default value */
 double bandwidth_factor = 1.0;  /* default value */
 
 double latency_factor = 1.0;    /* default value */
 double bandwidth_factor = 1.0;  /* default value */
@@ -44,7 +43,7 @@ static link_CM02_t link_new(char *name,
                             policy, xbt_dict_t properties)
 {
   link_CM02_t nw_link = xbt_new0(s_link_CM02_t, 1);
                             policy, xbt_dict_t properties)
 {
   link_CM02_t nw_link = xbt_new0(s_link_CM02_t, 1);
-  xbt_assert1(!xbt_dict_get_or_null(link_set, name),
+  xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name),
               "Link '%s' declared several times in the platform file.", name);
 
   nw_link->generic_resource.model = surf_network_model;
               "Link '%s' declared several times in the platform file.", name);
 
   nw_link->generic_resource.model = surf_network_model;
@@ -73,7 +72,7 @@ static link_CM02_t link_new(char *name,
 
   current_property_set = properties;
 
 
   current_property_set = properties;
 
-  xbt_dict_set(link_set, name, nw_link, link_free);
+  xbt_dict_set(surf_network_model->resource_set, name, nw_link, link_free);
 
   return nw_link;
 }
 
   return nw_link;
 }
@@ -130,7 +129,7 @@ static void add_traces(void)
   /* connect all traces relative to network */
   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
   /* connect all traces relative to network */
   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    link_CM02_t link = xbt_dict_get_or_null(link_set, elm);
+    link_CM02_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm);
 
     xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
 
     xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
@@ -142,7 +141,7 @@ static void add_traces(void)
 
   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    link_CM02_t link = xbt_dict_get_or_null(link_set, elm);
+    link_CM02_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm);
 
     xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
 
     xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
@@ -154,7 +153,7 @@ static void add_traces(void)
 
   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    link_CM02_t link = xbt_dict_get_or_null(link_set, elm);
+    link_CM02_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm);
 
     xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
 
     xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
@@ -501,8 +500,6 @@ static void action_set_max_duration(surf_action_t action, double duration)
 
 static void finalize(void)
 {
 
 static void finalize(void)
 {
-  xbt_dict_free(&link_set);
-
   surf_model_exit(surf_network_model);
   surf_network_model = NULL;
 
   surf_model_exit(surf_network_model);
   surf_network_model = NULL;
 
@@ -514,7 +511,6 @@ static void finalize(void)
 
 static void surf_network_model_init_internal(void)
 {
 
 static void surf_network_model_init_internal(void)
 {
-  link_set = xbt_dict_new();
   surf_network_model = surf_model_init();
 
   surf_network_model->name = "network";
   surf_network_model = surf_model_init();
 
   surf_network_model->name = "network";
index c00a72e..232fc7e 100644 (file)
@@ -45,7 +45,7 @@ static void link_new(char *name, double bw, double lat, xbt_dict_t props)
   network_link_GTNETS_t gtnets_link;
 
   /* If link already exists, nothing to do (FIXME: check that multiple definition match?) */
   network_link_GTNETS_t gtnets_link;
 
   /* If link already exists, nothing to do (FIXME: check that multiple definition match?) */
-  if (xbt_dict_get_or_null(link_set, name)) {
+  if (xbt_dict_get_or_null(surf_network_model->resource_set, name)) {
     return;
   }
 
     return;
   }
 
@@ -83,7 +83,7 @@ static void link_new(char *name, double bw, double lat, xbt_dict_t props)
   /* Add the properties */
   gtnets_link->properties = props;
 
   /* Add the properties */
   gtnets_link->properties = props;
 
-  xbt_dict_set(link_set, name, gtnets_link, link_free);
+  xbt_dict_set(surf_network_model->resource_set, name, gtnets_link, link_free);
 
   return;
 }
 
   return;
 }
@@ -250,7 +250,7 @@ static void add_route()
 
     xbt_dynar_foreach(links, cpt, link) {
       TRY {
 
     xbt_dynar_foreach(links, cpt, link) {
       TRY {
-        link_list[nb_link++] = xbt_dict_get(link_set, link);
+        link_list[nb_link++] = xbt_dict_get(surf_network_model->resource_set, link);
       }
       CATCH(e) {
         RETHROW1("Link %s not found (dict raised this exception: %s)", link);
       }
       CATCH(e) {
         RETHROW1("Link %s not found (dict raised this exception: %s)", link);
@@ -275,7 +275,7 @@ static void add_route()
 
     xbt_dynar_foreach(links, cpt, link) {
       TRY {
 
     xbt_dynar_foreach(links, cpt, link) {
       TRY {
-        link_list[nb_link++] = xbt_dict_get(link_set, link);
+        link_list[nb_link++] = xbt_dict_get(surf_network_model->resource_set, link);
       }
       CATCH(e) {
         RETHROW1("Link %s not found (dict raised this exception: %s)", link);
       }
       CATCH(e) {
         RETHROW1("Link %s not found (dict raised this exception: %s)", link);
@@ -508,7 +508,7 @@ static int action_is_suspended(surf_action_t action)
 
 static void finalize(void)
 {
 
 static void finalize(void)
 {
-  xbt_dict_free(&link_set);
+  xbt_dict_free(&surf_network_model->resource_set);
 
   surf_model_exit(surf_network_model);
 
 
   surf_model_exit(surf_network_model);
 
@@ -547,8 +547,6 @@ static void surf_network_model_init_internal(void)
   /*for the props of the link */
   surf_network_model->get_properties = get_properties;
 
   /*for the props of the link */
   surf_network_model->get_properties = get_properties;
 
-  link_set = xbt_dict_new();
-
   /* KF: Added the initialization for GTNetS interface */
   if (gtnets_initialize()) {
     xbt_assert0(0, "impossible to initialize GTNetS interface");
   /* KF: Added the initialization for GTNetS interface */
   if (gtnets_initialize()) {
     xbt_assert0(0, "impossible to initialize GTNetS interface");
index 077027a..c46d312 100644 (file)
@@ -83,7 +83,7 @@ static void routing_full_parse_end(void) {
     DEBUG4("Handle %d %d (from %d hosts): %ld links",
         src_id,dst_id,routing->generic_routing.host_count,xbt_dynar_length(links));
     xbt_dynar_foreach(links, cpt, link_name) {
     DEBUG4("Handle %d %d (from %d hosts): %ld links",
         src_id,dst_id,routing->generic_routing.host_count,xbt_dynar_length(links));
     xbt_dynar_foreach(links, cpt, link_name) {
-      void* link = xbt_dict_get_or_null(link_set, link_name);
+      void* link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
       if (link)
         xbt_dynar_push(ROUTE_FULL(src_id,dst_id),&link);
       else
       if (link)
         xbt_dynar_push(ROUTE_FULL(src_id,dst_id),&link);
       else
index 214f033..5d98c7b 100644 (file)
@@ -383,13 +383,13 @@ static void update_resource_state(void *id,
 
 static void finalize(void)
 {
 
 static void finalize(void)
 {
-  xbt_dict_free(&link_set);
-  if (parallel_task_link_set != NULL) {
+  if (parallel_task_link_set != NULL)
     xbt_dict_free(&parallel_task_link_set);
     xbt_dict_free(&parallel_task_link_set);
-  }
 
   surf_model_exit(surf_workstation_model);
   surf_workstation_model = NULL;
 
   surf_model_exit(surf_workstation_model);
   surf_workstation_model = NULL;
+  surf_model_exit(surf_network_model);
+  surf_network_model = NULL;
   used_routing->finalize();
 
   host_count = 0; // FIXME: KILLME?
   used_routing->finalize();
 
   host_count = 0; // FIXME: KILLME?
@@ -690,7 +690,7 @@ static link_L07_t link_new(char *name,
                            policy, xbt_dict_t properties)
 {
   link_L07_t nw_link = xbt_new0(s_link_L07_t, 1);
                            policy, xbt_dict_t properties)
 {
   link_L07_t nw_link = xbt_new0(s_link_L07_t, 1);
-  xbt_assert1(!xbt_dict_get_or_null(link_set, name),
+  xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name),
               "Link '%s' declared several times in the platform file.", name);
 
   nw_link->generic_resource.model = surf_workstation_model;
               "Link '%s' declared several times in the platform file.", name);
 
   nw_link->generic_resource.model = surf_workstation_model;
@@ -717,7 +717,7 @@ static link_L07_t link_new(char *name,
 
   nw_link->properties = properties;
 
 
   nw_link->properties = properties;
 
-  xbt_dict_set(link_set, name, nw_link, link_free);
+  xbt_dict_set(surf_network_model->resource_set, name, nw_link, link_free);
 
   return nw_link;
 }
 
   return nw_link;
 }
@@ -793,7 +793,7 @@ static void add_traces(void)
   /* Connect traces relative to network */
   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
   /* Connect traces relative to network */
   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    link_L07_t link = xbt_dict_get_or_null(link_set, elm);
+    link_L07_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm);
 
     xbt_assert1(link, "Link %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
 
     xbt_assert1(link, "Link %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -803,7 +803,7 @@ static void add_traces(void)
 
   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    link_L07_t link = xbt_dict_get_or_null(link_set, elm);
+    link_L07_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm);
 
     xbt_assert1(link, "Link %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
 
     xbt_assert1(link, "Link %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -813,7 +813,7 @@ static void add_traces(void)
 
   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    link_L07_t link = xbt_dict_get_or_null(link_set, elm);
+    link_L07_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm);
 
     xbt_assert1(link, "Link %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
 
     xbt_assert1(link, "Link %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -877,8 +877,6 @@ static void model_init_internal(void)
 
   surf_workstation_model->get_properties = get_properties;
 
 
   surf_workstation_model->get_properties = get_properties;
 
-  link_set = xbt_dict_new();
-
   if (!ptask_maxmin_system)
     ptask_maxmin_system = lmm_system_new();
 
   if (!ptask_maxmin_system)
     ptask_maxmin_system = lmm_system_new();
 
@@ -896,6 +894,7 @@ void surf_workstation_model_init_ptask_L07(const char *filename)
 {
   xbt_assert0(!surf_cpu_model, "CPU model type already defined");
   xbt_assert0(!surf_network_model, "network model type already defined");
 {
   xbt_assert0(!surf_cpu_model, "CPU model type already defined");
   xbt_assert0(!surf_network_model, "network model type already defined");
+  surf_network_model = surf_model_init();
   define_callbacks(filename);
   model_init_internal();
 
   define_callbacks(filename);
   model_init_internal();