X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/242fde5e8077f8193db4df5f262a9672085c8d8a..23a00833ef66ff4383394e3cac558a5232d4bd62:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index e10788b48b..6a81309178 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2014. The SimGrid Team. +/* Copyright (c) 2006-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -7,14 +7,14 @@ #include #include #include /* va_arg */ -#include #include "xbt/misc.h" #include "xbt/log.h" #include "xbt/str.h" +#include "xbt/file.h" #include "xbt/dict.h" #include "surf/surfxml_parse.h" -#include "surf/surf_private.h" +#include "src/surf/surf_private.h" #include "surf/random_mgr.h" #include "simgrid/sg_config.h" @@ -168,7 +168,7 @@ double surf_parse_get_bandwidth(const char *string) return surf_parse_get_value_with_unit(string, units); } -double surf_parse_get_power(const char *string) +double surf_parse_get_speed(const char *string) { const struct unit_scale units[] = { { "yottaflops", 1e24 }, @@ -324,7 +324,7 @@ void ETag_surfxml_include(void) { /** @brief When reaching EOF, check whether we are in an include tag, and behave accordingly if yes * - * This function is called automatically by sedding the parser in buildtools/Cmake/MaintainerMode.cmake + * This function is called automatically by sedding the parser in tools/cmake/MaintainerMode.cmake * Every FAIL on "Premature EOF" is preceded by a call to this function, which role is to restore the * previous buffer if we reached the EOF /of an include file/. Its return code is used to avoid the * error message in that case. @@ -374,7 +374,7 @@ void surf_parse_free_callbacks(void) /* Stag and Etag parse functions */ void STag_surfxml_platform(void) { - _XBT_GNUC_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version); + XBT_ATTRIB_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version); xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n " "You're using an ancient XML file.\n" @@ -441,32 +441,31 @@ void ETag_surfxml_host(void) { buf = A_surfxml_host_power; XBT_DEBUG("Buffer: %s", buf); - host.power_peak = xbt_dynar_new(sizeof(double), NULL); + host.speed_peak = xbt_dynar_new(sizeof(double), NULL); if (strchr(buf, ',') == NULL){ - double power_value = get_cpu_power(A_surfxml_host_power); - xbt_dynar_push_as(host.power_peak,double, power_value); + double speed = get_cpu_speed(A_surfxml_host_power); + xbt_dynar_push_as(host.speed_peak,double, speed); } else { xbt_dynar_t pstate_list = xbt_str_split(buf, ","); int i; for (i = 0; i < xbt_dynar_length(pstate_list); i++) { - double power_value; - char* power_value_str; - - xbt_dynar_get_cpy(pstate_list, i, &power_value_str); - xbt_str_trim(power_value_str, NULL); - power_value = get_cpu_power(power_value_str); - xbt_dynar_push_as(host.power_peak, double, power_value); - XBT_DEBUG("Power value: %f", power_value); + double speed; + char* speed_str; + + xbt_dynar_get_cpy(pstate_list, i, &speed_str); + xbt_str_trim(speed_str, NULL); + speed = get_cpu_speed(speed_str); + xbt_dynar_push_as(host.speed_peak, double, speed); + XBT_DEBUG("Speed value: %f", speed); } xbt_dynar_free(&pstate_list); } XBT_DEBUG("pstate: %s", A_surfxml_host_pstate); - //host.power_peak = get_cpu_power(A_surfxml_host_power); - host.power_scale = surf_parse_get_double( A_surfxml_host_availability); + host.speed_scale = surf_parse_get_double( A_surfxml_host_availability); host.core_amount = surf_parse_get_int(A_surfxml_host_core); - host.power_trace = tmgr_trace_new_from_file(A_surfxml_host_availability___file); + host.speed_trace = tmgr_trace_new_from_file(A_surfxml_host_availability___file); host.state_trace = tmgr_trace_new_from_file(A_surfxml_host_state___file); host.pstate = surf_parse_get_int(A_surfxml_host_pstate); @@ -479,6 +478,7 @@ void ETag_surfxml_host(void) { host.coord = A_surfxml_host_coordinates; sg_platf_new_host(&host); + xbt_dynar_free(&host.speed_peak); current_property_set = NULL; } @@ -490,7 +490,7 @@ void STag_surfxml_host___link(void){ host_link.id = A_surfxml_host___link_id; host_link.link_up = A_surfxml_host___link_up; host_link.link_down = A_surfxml_host___link_down; - sg_platf_new_host_link(&host_link); + sg_platf_new_netcard(&host_link); } void STag_surfxml_router(void){ @@ -512,7 +512,7 @@ void ETag_surfxml_cluster(void){ cluster.prefix = A_surfxml_cluster_prefix; cluster.suffix = A_surfxml_cluster_suffix; cluster.radical = A_surfxml_cluster_radical; - cluster.power = surf_parse_get_power(A_surfxml_cluster_power); + cluster.speed = surf_parse_get_speed(A_surfxml_cluster_power); cluster.core_amount = surf_parse_get_int(A_surfxml_cluster_core); cluster.bw = surf_parse_get_bandwidth(A_surfxml_cluster_bw); cluster.lat = surf_parse_get_time(A_surfxml_cluster_lat); @@ -592,7 +592,7 @@ void STag_surfxml_cabinet(void){ cabinet.id = A_surfxml_cabinet_id; cabinet.prefix = A_surfxml_cabinet_prefix; cabinet.suffix = A_surfxml_cabinet_suffix; - cabinet.power = surf_parse_get_power(A_surfxml_cabinet_power); + cabinet.speed = surf_parse_get_speed(A_surfxml_cabinet_power); cabinet.bw = surf_parse_get_bandwidth(A_surfxml_cabinet_bw); cabinet.lat = surf_parse_get_time(A_surfxml_cabinet_lat); cabinet.radical = A_surfxml_cabinet_radical; @@ -605,7 +605,7 @@ void STag_surfxml_peer(void){ s_sg_platf_peer_cbarg_t peer = SG_PLATF_PEER_INITIALIZER; memset(&peer,0,sizeof(peer)); peer.id = A_surfxml_peer_id; - peer.power = surf_parse_get_power(A_surfxml_peer_power); + peer.speed = surf_parse_get_speed(A_surfxml_peer_power); peer.bw_in = surf_parse_get_bandwidth(A_surfxml_peer_bw___in); peer.bw_out = surf_parse_get_bandwidth(A_surfxml_peer_bw___out); peer.lat = surf_parse_get_time(A_surfxml_peer_lat); @@ -773,8 +773,8 @@ void ETag_surfxml_ASroute(void){ ASroute.src = A_surfxml_ASroute_src; ASroute.dst = A_surfxml_ASroute_dst; - ASroute.gw_src = sg_routing_edge_by_name_or_null(A_surfxml_ASroute_gw___src); - ASroute.gw_dst = sg_routing_edge_by_name_or_null(A_surfxml_ASroute_gw___dst); + ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___src); + ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___dst); if (A_surfxml_ASroute_gw___src && !ASroute.gw_src) surf_parse_error("gw_src=\"%s\" not found for ASroute from \"%s\" to \"%s\"", @@ -823,8 +823,8 @@ void ETag_surfxml_bypassASroute(void){ ASroute.link_list = parsed_link_list; ASroute.symmetrical = FALSE; - ASroute.gw_src = sg_routing_edge_by_name_or_null(A_surfxml_bypassASroute_gw___src); - ASroute.gw_dst = sg_routing_edge_by_name_or_null(A_surfxml_bypassASroute_gw___dst); + ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_gw___src); + ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_gw___dst); sg_platf_new_bypassASroute(&ASroute); parsed_link_list = NULL; @@ -974,22 +974,8 @@ void STag_surfxml_model___prop(void){ xbt_dict_set(current_model_property_set, A_surfxml_model___prop_id, xbt_strdup(A_surfxml_model___prop_value), NULL); } -/* ***************************************** */ -/* TUTORIAL: New TAG */ -void STag_surfxml_gpu(void) -{ - XBT_DEBUG("STag_surfxml_gpu"); -} -void ETag_surfxml_gpu(void) -{ - s_sg_platf_gpu_cbarg_t gpu = SG_PLATF_GPU_INITIALIZER; - memset(&gpu,0,sizeof(gpu)); - - gpu.name = A_surfxml_gpu_name; - - sg_platf_new_gpu(&gpu); -} -/* ***************************************** */ +void STag_surfxml_gpu(void) {} +void ETag_surfxml_gpu(void) {} /* nothing to do in those functions */ void ETag_surfxml_prop(void){} @@ -1028,8 +1014,9 @@ void surf_parse_open(const char *file) if (!surf_parsed_filename_stack) surf_parsed_filename_stack = xbt_dynar_new(sizeof(char *), &xbt_free_ref); + surf_parsed_filename = xbt_strdup(file); - char *dir = dirname(surf_parsed_filename); + char *dir = xbt_dirname(file); xbt_dynar_push(surf_path, &dir); surf_file_to_parse = surf_fopen(file, "r"); @@ -1074,27 +1061,27 @@ int_f_void_t surf_parse = _surf_parse; * With XML parser */ -double get_cpu_power(const char *power) +double get_cpu_speed(const char *str_speed) { - double power_scale = 0.0; + double speed = 0.0; const char *p, *q; char *generator; random_data_t random = NULL; /* randomness is inserted like this: power="$rand(my_random)" */ - if (((p = strstr(power, "$rand(")) != NULL) - && ((q = strstr(power, ")")) != NULL)) { + if (((p = strstr(str_speed, "$rand(")) != NULL) + && ((q = strstr(str_speed, ")")) != NULL)) { if (p < q) { generator = xbt_malloc(q - (p + 6) + 1); memcpy(generator, p + 6, q - (p + 6)); generator[q - (p + 6)] = '\0'; random = xbt_dict_get_or_null(random_data_list, generator); xbt_assert(random, "Random generator %s undefined", generator); - power_scale = random_generate(random); + speed = random_generate(random); } } else { - power_scale = surf_parse_get_power(power); + speed = surf_parse_get_speed(str_speed); } - return power_scale; + return speed; } double random_min, random_max, random_mean, random_std_deviation;