From 436361a4e22fc3964761df7db5948b009060cfb8 Mon Sep 17 00:00:00 2001 From: navarrop Date: Thu, 24 Mar 2011 10:35:18 +0000 Subject: [PATCH] Remove old function surf_model_resource_by_name. 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 | 15 +++++++++------ src/surf/cpu.c | 6 +++--- src/surf/cpu_im.c | 6 +++--- src/surf/cpu_ti.c | 6 +++--- src/surf/surf_model.c | 6 ------ src/surf/workstation_ptask_L07.c | 8 +++----- testsuite/surf/surf_usage.c | 8 ++++---- testsuite/surf/surf_usage2.c | 4 ++-- 8 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index a1a2837ebd..2eac72d9ce 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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; diff --git a/src/surf/cpu.c b/src/surf/cpu.c index a9ae72a66b..d25b8bacdf 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -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); diff --git a/src/surf/cpu_im.c b/src/surf/cpu_im.c index da69fc5cf8..42d7988d18 100644 --- a/src/surf/cpu_im.c +++ b/src/surf/cpu_im.c @@ -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); diff --git a/src/surf/cpu_ti.c b/src/surf/cpu_ti.c index a67b44536f..5714ff051e 100644 --- a/src/surf/cpu_ti.c +++ b/src/surf/cpu_ti.c @@ -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); diff --git a/src/surf/surf_model.c b/src/surf/surf_model.c index cfe7d57ace..8800f71c34 100644 --- a/src/surf/surf_model.c +++ b/src/surf/surf_model.c @@ -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); -} diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 093256acab..f5d3f528fc 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -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); diff --git a/testsuite/surf/surf_usage.c b/testsuite/surf/surf_usage.c index f69a9cf047..2d88528ac8 100644 --- a/testsuite/surf/surf_usage.c +++ b/testsuite/surf/surf_usage.c @@ -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); diff --git a/testsuite/surf/surf_usage2.c b/testsuite/surf/surf_usage2.c index 7c308ad92b..5c10de061c 100644 --- a/testsuite/surf/surf_usage2.c +++ b/testsuite/surf/surf_usage2.c @@ -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); -- 2.20.1