From 70fe1bef83c75e436e2085c8cbb32ee401a1e273 Mon Sep 17 00:00:00 2001 From: mquinson Date: Thu, 2 Jul 2009 07:58:52 +0000 Subject: [PATCH] kill link_set (use surf_network_model->resource_set instead) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6434 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- ChangeLog | 1 + src/include/surf/surf.h | 16 ---------------- src/simdag/sd_global.c | 2 +- src/surf/cpu.c | 5 ++--- src/surf/network.c | 14 +++++--------- src/surf/network_gtnets.c | 12 +++++------- src/surf/surf_routing.c | 2 +- src/surf/workstation_ptask_L07.c | 19 +++++++++---------- 8 files changed, 24 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e64549c22..6b8bc0689f 100644 --- 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*) + - kill link_set (use surf_network_model->resource_set instead) * Simplify model declaration (less redirections, less function to write when defining a model) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 1cb37e5b50..3f17b78073 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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[]; -/** \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 */ diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index c927951112..c2817fceef 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -167,7 +167,7 @@ void SD_create_environment(const char *platform_file) __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); } diff --git a/src/surf/cpu.c b/src/surf/cpu.c index ee3ab22c52..ba3fa0cf5f 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -15,7 +15,6 @@ typedef struct surf_action_cpu_Cas01 { typedef struct cpu_Cas01 { s_surf_resource_t generic_resource; - char *name; 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; - 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; @@ -308,7 +307,7 @@ static surf_action_t action_sleep(void *cpu, double duration) 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; diff --git a/src/surf/network.c b/src/surf/network.c index 4b828cab84..a5edbe0512 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -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; -xbt_dict_t link_set = NULL; 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); - 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; @@ -73,7 +72,7 @@ static link_CM02_t link_new(char *name, 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; } @@ -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); - 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); @@ -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); - 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); @@ -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); - 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); @@ -501,8 +500,6 @@ static void action_set_max_duration(surf_action_t action, double duration) static void finalize(void) { - xbt_dict_free(&link_set); - 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) { - link_set = xbt_dict_new(); surf_network_model = surf_model_init(); surf_network_model->name = "network"; diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index c00a72e75c..232fc7ed51 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -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?) */ - if (xbt_dict_get_or_null(link_set, name)) { + if (xbt_dict_get_or_null(surf_network_model->resource_set, name)) { 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; - xbt_dict_set(link_set, name, gtnets_link, link_free); + xbt_dict_set(surf_network_model->resource_set, name, gtnets_link, link_free); return; } @@ -250,7 +250,7 @@ static void add_route() 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); @@ -275,7 +275,7 @@ static void add_route() 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); @@ -508,7 +508,7 @@ static int action_is_suspended(surf_action_t action) static void finalize(void) { - xbt_dict_free(&link_set); + xbt_dict_free(&surf_network_model->resource_set); 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; - link_set = xbt_dict_new(); - /* KF: Added the initialization for GTNetS interface */ if (gtnets_initialize()) { xbt_assert0(0, "impossible to initialize GTNetS interface"); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 077027ad08..c46d31213c 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -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) { - 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 diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 214f0333d6..5d98c7bbaf 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -383,13 +383,13 @@ static void update_resource_state(void *id, static void finalize(void) { - xbt_dict_free(&link_set); - if (parallel_task_link_set != NULL) { + if (parallel_task_link_set != NULL) xbt_dict_free(¶llel_task_link_set); - } 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? @@ -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); - 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; @@ -717,7 +717,7 @@ static link_L07_t link_new(char *name, 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; } @@ -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); - 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); @@ -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); - 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); @@ -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); - 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); @@ -877,8 +877,6 @@ static void model_init_internal(void) surf_workstation_model->get_properties = get_properties; - link_set = xbt_dict_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"); + surf_network_model = surf_model_init(); define_callbacks(filename); model_init_internal(); -- 2.20.1