From: mquinson Date: Mon, 13 Jul 2009 15:26:05 +0000 (+0000) Subject: Kill surf_parse_get_trace() which were a useless wrapper to tmgr_trace_new X-Git-Tag: SVN~1177 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2d5b327d0b5304bc0beaff6aae611dda6dac1b03 Kill surf_parse_get_trace() which were a useless wrapper to tmgr_trace_new git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6471 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/include/surf/surfxml_parse_private.h b/src/include/surf/surfxml_parse_private.h index 74193b4481..57becf454b 100644 --- a/src/include/surf/surfxml_parse_private.h +++ b/src/include/surf/surfxml_parse_private.h @@ -14,6 +14,5 @@ #include "surf/surfxml_parse.h" #include "surf/trace_mgr.h" -void surf_parse_get_trace(tmgr_trace_t * trace, const char *string); #endif diff --git a/src/surf/cpu.c b/src/surf/cpu.c index a6cfe86d8e..e331a456fa 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -75,7 +75,7 @@ static void parse_cpu_init(void) power_scale = get_cpu_power(A_surfxml_host_power); surf_parse_get_double(&power_initial, A_surfxml_host_availability); - surf_parse_get_trace(&power_trace, A_surfxml_host_availability_file); + power_trace = tmgr_trace_new(A_surfxml_host_availability_file); xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) || (A_surfxml_host_state == A_surfxml_host_state_OFF), @@ -84,7 +84,7 @@ static void parse_cpu_init(void) state_initial = SURF_RESOURCE_ON; if (A_surfxml_host_state == A_surfxml_host_state_OFF) state_initial = SURF_RESOURCE_OFF; - surf_parse_get_trace(&state_trace, A_surfxml_host_state_file); + state_trace = tmgr_trace_new(A_surfxml_host_state_file); current_property_set = xbt_dict_new(); cpu_new(xbt_strdup(A_surfxml_host_id), power_scale, power_initial, diff --git a/src/surf/network.c b/src/surf/network.c index bb035a8e29..225a7e73d7 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -74,9 +74,9 @@ static void parse_link_init(void) name_link = xbt_strdup(A_surfxml_link_id); surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth); - surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file); + bw_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file); surf_parse_get_double(&lat_initial, A_surfxml_link_latency); - surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file); + lat_trace = tmgr_trace_new(A_surfxml_link_latency_file); xbt_assert0((A_surfxml_link_state == A_surfxml_link_state_ON) || (A_surfxml_link_state == @@ -92,7 +92,7 @@ static void parse_link_init(void) A_surfxml_link_sharing_policy_FATPIPE) policy_initial_link = SURF_LINK_FATPIPE; - surf_parse_get_trace(&state_trace, A_surfxml_link_state_file); + state_trace = tmgr_trace_new(A_surfxml_link_state_file); link_new(name_link, bw_initial, bw_trace, lat_initial, lat_trace, state_initial_link, state_trace, diff --git a/src/surf/surf.c b/src/surf/surf.c index 0ac05fb90e..7ac373fcd4 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -235,6 +235,7 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_lagrange); XBT_LOG_EXTERNAL_CATEGORY(surf_lagrange_dichotomy); XBT_LOG_EXTERNAL_CATEGORY(surf_maxmin); XBT_LOG_EXTERNAL_CATEGORY(surf_network); +XBT_LOG_EXTERNAL_CATEGORY(surf_trace); XBT_LOG_EXTERNAL_CATEGORY(surf_parse); XBT_LOG_EXTERNAL_CATEGORY(surf_timer); XBT_LOG_EXTERNAL_CATEGORY(surf_workstation); @@ -258,6 +259,7 @@ void surf_init(int *argc, char **argv) XBT_LOG_CONNECT(surf_lagrange_dichotomy, surf_lagrange); XBT_LOG_CONNECT(surf_maxmin, surf); XBT_LOG_CONNECT(surf_network, surf); + XBT_LOG_CONNECT(surf_trace, surf); XBT_LOG_CONNECT(surf_parse, surf); XBT_LOG_CONNECT(surf_timer, surf); XBT_LOG_CONNECT(surf_workstation, surf); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index e4a04e7c14..be1a261d50 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -506,14 +506,6 @@ void surf_parse_get_int(int *value, const char *string) surf_parse_error(bprintf("%s is not an integer", string)); } -void surf_parse_get_trace(tmgr_trace_t * trace, const char *string) -{ - if ((!string) || (strcmp(string, "") == 0)) - *trace = NULL; - else - *trace = tmgr_trace_new(string); -} - void parse_properties(void) { char *value = NULL; @@ -1222,7 +1214,7 @@ static void parse_trace_finalize(void) { tmgr_trace_t trace; if (!trace_file || strcmp(trace_file, "") != 0) { - surf_parse_get_trace(&trace, trace_file); + trace = tmgr_trace_new(trace_file); } else { if (strcmp(surfxml_pcdata, "") == 0) trace = NULL; diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index 6442cb3c31..57d4daea72 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -12,6 +12,8 @@ #include "trace_mgr_private.h" #include "surf_private.h" +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_trace, surf,"Surf trace management"); + static xbt_dict_t trace_list = NULL; static void _tmgr_trace_free(void *trace) { @@ -107,15 +109,19 @@ tmgr_trace_t tmgr_trace_new(const char *filename) s_tmgr_event_t event; tmgr_event_t last_event = NULL; + if ((!filename) || (strcmp(filename, "") == 0)) + return NULL; + if (trace_list) { trace = xbt_dict_get_or_null(trace_list, filename); - if (trace) + if (trace) { + WARN1("Ignoring redefinition of trace %s",filename); return trace; + } } - if ((f = surf_fopen(filename, "r")) == NULL) { - xbt_assert1(0, "Cannot open file '%s'", filename); - } + f = surf_fopen(filename, "r"); + xbt_assert1(f!=NULL, "Cannot open file '%s'", filename); trace = xbt_new0(s_tmgr_trace_t, 1); trace->event_list = xbt_dynar_new(sizeof(s_tmgr_event_t), NULL); diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index ac34f93154..ba86059c93 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -629,7 +629,7 @@ static void parse_cpu_init(void) power_scale = get_cpu_power(A_surfxml_host_power); surf_parse_get_double(&power_initial, A_surfxml_host_availability); - surf_parse_get_trace(&power_trace, A_surfxml_host_availability_file); + power_trace = tmgr_trace_new(A_surfxml_host_availability_file); xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) || (A_surfxml_host_state == A_surfxml_host_state_OFF), @@ -638,7 +638,7 @@ static void parse_cpu_init(void) state_initial = SURF_RESOURCE_ON; if (A_surfxml_host_state == A_surfxml_host_state_OFF) state_initial = SURF_RESOURCE_OFF; - surf_parse_get_trace(&state_trace, A_surfxml_host_state_file); + state_trace = tmgr_trace_new(A_surfxml_host_state_file); current_property_set = xbt_dict_new(); cpu_new(A_surfxml_host_id, power_scale, power_initial, power_trace, @@ -702,9 +702,9 @@ static void parse_link_init(void) name_link = xbt_strdup(A_surfxml_link_id); surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth); - surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file); + bw_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file); surf_parse_get_double(&lat_initial, A_surfxml_link_latency); - surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file); + lat_trace = tmgr_trace_new(A_surfxml_link_latency_file); xbt_assert0((A_surfxml_link_state == A_surfxml_link_state_ON) || (A_surfxml_link_state == @@ -720,7 +720,7 @@ static void parse_link_init(void) A_surfxml_link_sharing_policy_FATPIPE) policy_initial_link = SURF_LINK_FATPIPE; - surf_parse_get_trace(&state_trace, A_surfxml_link_state_file); + state_trace = tmgr_trace_new(A_surfxml_link_state_file); current_property_set = xbt_dict_new(); link_new(name_link, bw_initial, bw_trace, lat_initial, lat_trace,