X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/14f0f468f6a34f7501aa5a30e6e78c36d2b65e74..a2a8fbb62b1993b24307c5228b281e3e50416e6c:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index c4ba3d4288..0556aa711c 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -1,6 +1,5 @@ -/* $Id$ */ - -/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */ +/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -270,6 +269,7 @@ void ETag_surfxml_platform(void) void STag_surfxml_host(void) { surfxml_call_cb_functions(STag_surfxml_host_cb_list); + } void ETag_surfxml_host(void) @@ -438,13 +438,14 @@ void surf_parse_open(const char *file) } return; } + surf_file_to_parse = surf_fopen(file, "r"); + xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file); + if (!surf_input_buffer_stack) surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL); if (!surf_file_to_parse_stack) surf_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL); - surf_file_to_parse = surf_fopen(file, "r"); - xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file); surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10); surf_parse__switch_to_buffer(surf_input_buffer); surf_parse_lineno = 1; @@ -463,7 +464,6 @@ void surf_parse_close(void) } } - static int _surf_parse(void) { return surf_parse_lex(); @@ -609,11 +609,15 @@ static void free_data(void) void parse_platform_file(const char *file) { + int parse_status; surf_parse_open(file); init_data(); - xbt_assert1((!(*surf_parse) ()), "Parse error in %s", file); + parse_status = surf_parse(); free_data(); surf_parse_close(); + if (parse_status) + xbt_dict_free(&random_data_list); + xbt_assert1(!parse_status, "Parse error in %s", file); } /* Functions to bypass route tag. Used by the route:multi tag */ @@ -693,6 +697,7 @@ static void parse_sets(void) } static void parse_host_foreach(void){ + xbt_dynar_t names = NULL; unsigned int cpt = 0; char *name; @@ -832,6 +837,7 @@ static void parse_route_elem(void) val = xbt_strdup(A_surfxml_link_c_ctn_id); xbt_dynar_push(route_link_list, &val); + //INFO2("Push %s (size now:%ld)",val,xbt_dynar_length(route_link_list)); } static void parse_Stag_route_multi(void) @@ -858,7 +864,11 @@ void manage_route(xbt_dict_t routing_table, const char *route_name, /* get already existing list if it exists */ links = xbt_dict_get_or_null(routing_table, route_name); - DEBUG1("ROUTE: %s", route_name); + DEBUG3("ROUTE: %s (action:%s; len:%ld)", route_name, + (action==A_surfxml_route_action_OVERRIDE?"override":( + action==A_surfxml_route_action_PREPEND?"prepend":"postpend")), + (links?xbt_dynar_length(links):0)); + if (links != NULL) { switch (action) { case A_surfxml_route_action_PREPEND: /* add existing links at the end; route_link_list + links */ @@ -868,7 +878,7 @@ void manage_route(xbt_dict_t routing_table, const char *route_name, xbt_dynar_free(&links); break; case A_surfxml_route_action_POSTPEND: /* add existing links in front; links + route_link_list */ - xbt_dynar_foreach(route_link_list, cpt, value) { + xbt_dynar_foreach(route_link_list, cpt, value) { xbt_dynar_push(links, &value); } xbt_dynar_free(&route_link_list); @@ -878,8 +888,11 @@ void manage_route(xbt_dict_t routing_table, const char *route_name, xbt_dynar_free(&links); break; default: + xbt_die(bprintf("While dealing with routes of %s, got action=%d. Please report this bug.", + route_name,action)); break; } + } /* this is the final route; do not add if name is a set; add only if name is in set list */ if (!isMultiRoute) { @@ -1039,7 +1052,6 @@ static void convert_route_multi_to_routes(void) /* Trace management functions */ static double trace_periodicity = -1.0; -static double trace_timestep = -1.0; static char *trace_file = NULL; static char *trace_id; @@ -1048,7 +1060,6 @@ static void parse_Stag_trace(void) trace_id = strdup(A_surfxml_trace_id); trace_file = strdup(A_surfxml_trace_file); surf_parse_get_double(&trace_periodicity, A_surfxml_trace_periodicity); - surf_parse_get_double(&trace_timestep, A_surfxml_trace_timestep); } static void parse_Etag_trace(void) @@ -1062,7 +1073,7 @@ static void parse_Etag_trace(void) else trace = tmgr_trace_new_from_string(trace_id, surfxml_pcdata, - trace_periodicity, trace_timestep); + trace_periodicity); } xbt_dict_set(traces_set_list, trace_id, (void *) trace, NULL); } @@ -1155,3 +1166,75 @@ static void add_randomness(void) random_std_deviation); xbt_dict_set(random_data_list, random_id, (void *) random, NULL); } + +void surf_host_create_resource(char *name, double power_peak, + double power_scale, + tmgr_trace_t power_trace, + e_surf_resource_state_t state_initial, + tmgr_trace_t state_trace, + xbt_dict_t cpu_properties) +{ + return surf_cpu_model->extension.cpu. + create_resource(name,power_peak,power_scale,power_trace,state_initial,state_trace,cpu_properties); +} + + +void surf_link_create_resouce(char *name, + double bw_initial, + double lat_initial) +{ + return surf_network_model->extension.network. + create_resource(name,bw_initial,lat_initial); + +} + +/** + * Route: add route element bypassing the parser : + * same job as parse_route_elem + */ + +void surf_add_route_element(char* link_ctn_id) +{ + char *val; + val = xbt_strdup(link_ctn_id); + xbt_dynar_push(route_link_list,&val); +} +/** + * set route + */ +void surf_route_set_resource(char *source_id,char *destination_id,xbt_dynar_t links_id,int action) +{ + route_link_list = xbt_dynar_new(sizeof(char *), NULL); + routing_add_route(source_id,destination_id,links_id,action); + +} + +/** + * add host to routing host list + */ +void surf_route_add_host(char *host_id) +{ + routing_add_host(host_id); +} + +/* + * Add Traces + */ +void surf_add_host_traces(void) +{ + return surf_cpu_model->extension.cpu. + add_traces(); +} + +void surf_add_link_traces(void) +{ + return surf_network_model->extension.network. + add_traces(); +} +/** + * set routes + */ +void surf_set_routes(void) +{ + routing_set_routes(); +}