Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove old function surf_model_resource_by_name.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:35:18 +0000 (10:35 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:35:18 +0000 (10:35 +0000)
Add surf_cpu_resource_by_name, surf_workstation_resource_by_name and
surf_network_resource_by_name.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9826 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/surf/surf.h
src/surf/cpu.c
src/surf/cpu_im.c
src/surf/cpu_ti.c
src/surf/surf_model.c
src/surf/workstation_ptask_L07.c
testsuite/surf/surf_usage.c
testsuite/surf/surf_usage2.c

index a1a2837..2eac72d 100644 (file)
@@ -297,12 +297,8 @@ typedef struct surf_model {
   int (*get_latency_limited) (surf_action_t action);     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
 
-  xbt_dict_t resource_set;
-
-
   surf_model_private_t model_private;
 
-
   union extension {
     s_surf_model_extension_cpu_t cpu;
     s_surf_model_extension_network_t network;
@@ -313,8 +309,15 @@ typedef struct surf_model {
 surf_model_t surf_model_init(void);
 void surf_model_exit(surf_model_t model);
 
-void *surf_model_resource_by_name(surf_model_t model, const char *name);
-#define surf_model_resource_set(model) (model)->resource_set
+static inline void *surf_cpu_resource_by_name(const char *name) {
+       return xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL);
+}
+static inline void *surf_workstation_resource_by_name(const char *name){
+       return xbt_lib_get_or_null(host_lib, name, SURF_WKS_LEVEL);
+}
+static inline void *surf_network_resource_by_name(const char *name){
+       return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL);
+}
 
 typedef struct surf_resource {
   surf_model_t model;
index a9ae72a..d25b8ba 100644 (file)
@@ -41,7 +41,7 @@ static cpu_Cas01_t cpu_new(char *name, double power_peak,
                            xbt_dict_t cpu_properties)
 {
   cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1);
-  xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
+  xbt_assert1(!surf_cpu_resource_by_name(name),
               "Host '%s' declared several times in the platform file",
               name);
   cpu->generic_resource.model = surf_cpu_model;
@@ -115,7 +115,7 @@ static void add_traces_cpu(void)
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_Cas01_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+    cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
 
     xbt_assert1(host, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -126,7 +126,7 @@ static void add_traces_cpu(void)
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_Cas01_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+    cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
 
     xbt_assert1(host, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
index da69fc5..42d7988 100644 (file)
@@ -59,7 +59,7 @@ static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
   s_surf_action_cpu_Cas01_im_t action;
   cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
 
-  xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
+  xbt_assert1(!surf_cpu_resource_by_name(name),
               "Host '%s' declared several times in the platform file",
               name);
   cpu->generic_resource.model = surf_cpu_model;
@@ -133,7 +133,7 @@ static void cpu_im_add_traces_cpu(void)
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_Cas01_im_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+    cpu_Cas01_im_t host = surf_cpu_resource_by_name(elm);
 
     xbt_assert1(host, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -144,7 +144,7 @@ static void cpu_im_add_traces_cpu(void)
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_Cas01_im_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+    cpu_Cas01_im_t host = surf_cpu_resource_by_name(elm);
 
     xbt_assert1(host, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
index a67b445..5714ff0 100644 (file)
@@ -156,7 +156,7 @@ static cpu_ti_t cpu_ti_new(char *name, double power_peak,
   s_tmgr_event_t val;
   cpu_ti_t cpu = xbt_new0(s_cpu_ti_t, 1);
   s_surf_action_cpu_ti_t ti_action;
-  xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
+  xbt_assert1(!surf_cpu_resource_by_name(name),
               "Host '%s' declared several times in the platform file",
               name);
   xbt_assert0(core==1,"Multi-core not handled with this model yet");
@@ -236,7 +236,7 @@ static void add_traces_cpu_ti(void)
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_ti_t cpu = surf_model_resource_by_name(surf_cpu_model, elm);
+    cpu_ti_t cpu = surf_cpu_resource_by_name(elm);
 
     xbt_assert1(cpu, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -252,7 +252,7 @@ static void add_traces_cpu_ti(void)
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_ti_t cpu = surf_model_resource_by_name(surf_cpu_model, elm);
+    cpu_ti_t cpu = surf_cpu_resource_by_name(elm);
 
     xbt_assert1(cpu, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
index cfe7d57..8800f71 100644 (file)
@@ -57,12 +57,6 @@ void surf_model_exit(surf_model_t model)
   xbt_swag_free(model->states.running_action_set);
   xbt_swag_free(model->states.failed_action_set);
   xbt_swag_free(model->states.done_action_set);
-  xbt_dict_free(&model->resource_set);
   free(model->model_private);
   free(model);
 }
-
-void *surf_model_resource_by_name(surf_model_t model, const char *name)
-{
-  return xbt_dict_get_or_null(model->resource_set, name);
-}
index 093256a..f5d3f52 100644 (file)
@@ -622,7 +622,7 @@ static cpu_L07_t ptask_cpu_new(const char *name, double power_scale,
                                xbt_dict_t cpu_properties)
 {
   cpu_L07_t cpu = xbt_new0(s_cpu_L07_t, 1);
-  xbt_assert1(!surf_model_resource_by_name(surf_workstation_model, name),
+  xbt_assert1(!surf_workstation_resource_by_name(name),
               "Host '%s' declared several times in the platform file.",
               name);
 
@@ -829,8 +829,7 @@ static void ptask_add_traces(void)
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_L07_t host =
-        surf_model_resource_by_name(surf_workstation_model, elm);
+    cpu_L07_t host = surf_workstation_resource_by_name(elm);
 
     xbt_assert1(host, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
@@ -841,8 +840,7 @@ static void ptask_add_traces(void)
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_L07_t host =
-        surf_model_resource_by_name(surf_workstation_model, elm);
+    cpu_L07_t host = surf_workstation_resource_by_name(elm);
 
     xbt_assert1(host, "Host %s undefined", elm);
     xbt_assert1(trace, "Trace %s undefined", trace_name);
index f69a9cf..2d88528 100644 (file)
@@ -59,8 +59,8 @@ void test(char *platform)
 
   /*********************** CPU ***********************************/
   XBT_DEBUG("%p", surf_cpu_model);
-  cpuA = surf_model_resource_by_name(surf_cpu_model, "Cpu A");
-  cpuB = surf_model_resource_by_name(surf_cpu_model, "Cpu B");
+  cpuA = surf_cpu_resource_by_name("Cpu A");
+  cpuB = surf_cpu_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
   XBT_DEBUG("%s : %p", surf_resource_name(cpuA), cpuA);
@@ -83,8 +83,8 @@ void test(char *platform)
 
   /*********************** Network *******************************/
   XBT_DEBUG("%p", surf_network_model);
-  cardA = surf_model_resource_by_name(surf_network_model, "Cpu A");
-  cardB = surf_model_resource_by_name(surf_network_model, "Cpu B");
+  cardA = surf_network_resource_by_name("Cpu A");
+  cardB = surf_network_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
   XBT_DEBUG("%s : %p", surf_resource_name(cardA), cardA);
index 7c308ad..5c10de0 100644 (file)
@@ -62,9 +62,9 @@ void test(char *platform)
 
   /*********************** WORKSTATION ***********************************/
   workstationA =
-      surf_model_resource_by_name(surf_workstation_model, "Cpu A");
+      surf_workstation_resource_by_name("Cpu A");
   workstationB =
-      surf_model_resource_by_name(surf_workstation_model, "Cpu B");
+      surf_workstation_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
   XBT_DEBUG("%s : %p", surf_resource_name(workstationA), workstationA);