-/* $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. */
void STag_surfxml_host(void)
{
surfxml_call_cb_functions(STag_surfxml_host_cb_list);
+
}
void ETag_surfxml_host(void)
}
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;
}
}
-
static int _surf_parse(void)
{
return surf_parse_lex();
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 */
}
static void parse_host_foreach(void){
+
xbt_dynar_t names = NULL;
unsigned int cpt = 0;
char *name;
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)
/* 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 */
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);
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) {
/* Trace management functions */
static double trace_periodicity = -1.0;
-static double trace_timestep = -1.0;
static char *trace_file = NULL;
static char *trace_id;
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)
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);
}
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)
+{
+ xbt_dynar_push(route_link_list,&link_ctn_id);
+}