X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/073f8bce5afb1febdc3580607be8819b90705280..504b4d20dd2db9ea1eaa9c4b390b2a412d7c9779:/src/surf/network_gtnets.c diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index c0c0eb0020..e1ba8706e0 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -26,11 +26,11 @@ static int *routing_table_size = NULL; #endif /** QUESTIONS for GTNetS integration - ** 1. Check that we did the right thing with name_service and get_model_name + ** 1. Check that we did the right thing with name_service and get_resource_name ** 2. Right now there is no "kill flow" in our GTNetS implementation. Do we ** need to do something about this? ** 3. We ignore the fact there is some max_duration on flows (see #2 above) - ** 4. share_models() returns a duration, not a date, right? + ** 4. share_resources() returns a duration, not a date, right? ** 5. We don't suppoer "rates" ** 6. We don't update "remaining" for ongoing flows. Is it bad? **/ @@ -46,7 +46,7 @@ static void network_link_free(void *nw_link) /* name: some name for the link, from the XML */ /* bw: The bandwidth value */ /* lat: The latency value */ -static void network_link_new(char *name, double bw, double lat) +static void network_link_new(char *name, double bw, double lat, xbt_dict_t props) { static int link_count = -1; network_link_GTNETS_t gtnets_link; @@ -87,6 +87,9 @@ static void network_link_new(char *name, double bw, double lat) gtnets_link->bw_current = bw; gtnets_link->lat_current = lat; gtnets_link->id = link_count; + /* Add the properties */ + gtnets_link->properties = current_property_set; + xbt_dict_set(network_link_set, name, gtnets_link, network_link_free); return; @@ -177,8 +180,10 @@ static void route_onehop_new(int src_id, int dst_id, char **links, } } + + /* Parse the XML for a network link */ -static void parse_network_link(void) +static void parse_network_link_init(void) { char *name; double bw; @@ -213,10 +218,9 @@ static void parse_network_link(void) ("The GTNetS network model doesn't support link state traces"); #endif } - - /* KF: remove several arguments to network_link_new */ - network_link_new(name, bw, lat); + current_property_set = xbt_dict_new(); + network_link_new(name, bw, lat, current_property_set); } static int nb_link = 0; @@ -269,47 +273,20 @@ static void parse_route_set_onehop_route(void) /* Main XML parsing */ static void parse_file(const char *file) { - /* Figuring out the network links */ surf_parse_reset_parser(); - ETag_surfxml_network_link_fun = parse_network_link; - surf_parse_open(file); - xbt_assert1((!surf_parse()), "Parse error in %s", file); - surf_parse_close(); - /* Figuring out the network cards used */ - /* KF - surf_parse_reset_parser(); - STag_surfxml_route_fun=parse_route_set_endpoints; - surf_parse_open(file); - xbt_assert1((!surf_parse()),"Parse error in %s",file); - surf_parse_close(); - */ - - /* KF: Figuring out the router (considered as part of - network cards) used. */ - surf_parse_reset_parser(); - STag_surfxml_router_fun = parse_route_set_routers; - surf_parse_open(file); - xbt_assert1((!surf_parse()), "Parse error in %s", file); - surf_parse_close(); + surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties); + surfxml_add_callback(STag_surfxml_router_cb_list, &parse_route_set_routers); + surfxml_add_callback(STag_surfxml_network_link_cb_list, &parse_network_link_init); + surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints); + surfxml_add_callback(ETag_surfxml_route_element_cb_list, &parse_route_elem); + surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_onehop_route); + surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route); - /* Building the one-hop routes */ - surf_parse_reset_parser(); - STag_surfxml_route_fun = parse_route_set_endpoints; - ETag_surfxml_route_element_fun = parse_route_elem; - ETag_surfxml_route_fun = parse_route_set_onehop_route; surf_parse_open(file); xbt_assert1((!surf_parse()), "Parse error in %s", file); surf_parse_close(); - /* Building the routes */ - surf_parse_reset_parser(); - STag_surfxml_route_fun = parse_route_set_endpoints; - ETag_surfxml_route_element_fun = parse_route_elem; - ETag_surfxml_route_fun = parse_route_set_route; - surf_parse_open(file); - xbt_assert1((!surf_parse()), "Parse error in %s", file); - surf_parse_close(); } static void *name_service(const char *name) @@ -317,13 +294,19 @@ static void *name_service(const char *name) return xbt_dict_get_or_null(network_card_set, name); } -static const char *get_model_name(void *model_id) +static const char *get_resource_name(void *resource_id) { - return ((network_card_GTNETS_t) model_id)->name; + return ((network_card_GTNETS_t) resource_id)->name; } +static xbt_dict_t get_link_property_list(void *link) +{ + return ((network_card_GTNETS_t) link)->properties; +} + + /* We do not care about this: only used for traces */ -static int model_used(void *model_id) +static int resource_used(void *resource_id) { return 0; /* We don't care */ } @@ -371,8 +354,8 @@ static void action_change_state(surf_action_t action, } -/* share_models() */ -static double share_models(double now) +/* share_resources() */ +static double share_resources(double now) { #if 0 s_surf_action_network_GTNETS_t s_action; @@ -443,7 +426,7 @@ static void update_actions_state(double now, double delta) } /* UNUSED HERE: no traces */ -static void update_model_state(void *id, +static void update_resource_state(void *id, tmgr_trace_event_t event_type, double value) { @@ -575,8 +558,8 @@ static void surf_network_model_init_internal(void) xbt_swag_new(xbt_swag_offset(action, state_hookup)); surf_network_model->common_public->name_service = name_service; - surf_network_model->common_public->get_model_name = - get_model_name; + surf_network_model->common_public->get_resource_name = + get_resource_name; surf_network_model->common_public->action_get_state = surf_action_get_state; surf_network_model->common_public->action_use = action_use; @@ -589,12 +572,12 @@ static void surf_network_model_init_internal(void) surf_action_set_data; surf_network_model->common_public->name = "network"; - surf_network_model->common_private->model_used = model_used; - surf_network_model->common_private->share_models = share_models; + surf_network_model->common_private->resource_used = resource_used; + surf_network_model->common_private->share_resources = share_resources; surf_network_model->common_private->update_actions_state = update_actions_state; - surf_network_model->common_private->update_model_state = - update_model_state; + surf_network_model->common_private->update_resource_state = + update_resource_state; surf_network_model->common_private->finalize = finalize; surf_network_model->common_public->suspend = action_suspend; @@ -603,12 +586,12 @@ static void surf_network_model_init_internal(void) surf_network_model->extension_public->communicate = communicate; + /*for the props of the link*/ + surf_network_model->common_public->get_link_properties = get_link_property_list; + network_link_set = xbt_dict_new(); network_card_set = xbt_dict_new(); - /* HC: I am assuming that this stays in for simulation of compute tasks */ - xbt_assert0(maxmin_system, "surf_init has to be called first!"); - /* KF: Added the initialization for GTNetS interface */ if (gtnets_initialize()) { xbt_assert0(0, "impossible to initialize GTNetS interface");