elm = xbt_new0(struct graph_node_map_element, 1);
elm->node = node;
xbt_dict_set_ext(as->graph_node_map, (char *) (&id), sizeof(int),
- (xbt_set_elm_t) elm, &graph_node_map_elem_free);
+ (xbt_set_elm_t) elm, NULL);
return node;
}
}
}
-static void dijkstra_get_route(AS_t as_generic,
- const char *src, const char *dst, route_t route);
+static void dijkstra_get_route_and_latency(AS_t as_generic,
+ const char *src, const char *dst, route_t route, double *lat);
static xbt_dynar_t dijkstra_get_onelink_routes(AS_t as)
{
- // xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet");
xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
//size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
xbt_dict_foreach(as->to_index, c2, k2, d2) {
route_t route = xbt_new0(s_route_t,1);
route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
- dijkstra_get_route(as, k1, k2,route);
+ dijkstra_get_route_and_latency(as, k1, k2,route, NULL);
if (xbt_dynar_length(route->link_list) == 1) {
void *link =
return ret;
}
-static void dijkstra_get_route(AS_t asg,
+static void dijkstra_get_route_and_latency(AS_t asg,
const char *src, const char *dst,
- route_t route)
+ route_t route, double *lat)
{
/* set utils vars */
links = e_route->link_list;
xbt_dynar_foreach(links, cpt, link) {
xbt_dynar_unshift(route->link_list, &link);
+ if (lat)
+ *lat += surf_network_model->extension.network.get_link_latency(link);
}
}
int pos = 0;
xbt_dynar_foreach(links, cpt, link) {
xbt_dynar_insert_at(route->link_list, pos, &link);
+ if (lat)
+ *lat += surf_network_model->extension.network.get_link_latency(link);
pos++;
}
}
links = e_route->link_list;
xbt_dynar_foreach(links, cpt, link) {
xbt_dynar_unshift(route->link_list, &link);
+ if (lat)
+ *lat += surf_network_model->extension.network.get_link_latency(link);
}
size++;
}
elm->pred_arr = pred_arr;
elm->size = size;
xbt_dict_set_ext(as->route_cache, (char *) (&src_id), sizeof(int),
- (xbt_set_elm_t) elm, &route_cache_elem_free);
+ (xbt_set_elm_t) elm, NULL);
}
if (!as->cached)
new_component->generic_routing.parse_route = model_dijkstra_both_parse_route;
new_component->generic_routing.parse_ASroute = model_dijkstra_both_parse_route;
- new_component->generic_routing.get_route = dijkstra_get_route;
+ new_component->generic_routing.get_route_and_latency = dijkstra_get_route_and_latency;
new_component->generic_routing.get_onelink_routes =
dijkstra_get_onelink_routes;
new_component->generic_routing.finalize = dijkstra_finalize;
void model_dijkstra_both_end(AS_t as)
{
- as_dijkstra_t THIS = (as_dijkstra_t) as;
+ as_dijkstra_t THIS_AS = (as_dijkstra_t) as;
xbt_node_t node = NULL;
unsigned int cursor2;
xbt_dynar_t nodes = NULL;
/* Create the topology graph */
- if(!THIS->route_graph)
- THIS->route_graph = xbt_graph_new_graph(1, NULL);
- if(!THIS->graph_node_map)
- THIS->graph_node_map = xbt_dict_new();
+ if(!THIS_AS->route_graph)
+ THIS_AS->route_graph = xbt_graph_new_graph(1, NULL);
+ if(!THIS_AS->graph_node_map)
+ THIS_AS->graph_node_map = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
- if (THIS->cached && !THIS->route_cache)
- THIS->route_cache = xbt_dict_new();
+ if (THIS_AS->cached && !THIS_AS->route_cache)
+ THIS_AS->route_cache = xbt_dict_new_homogeneous(&route_cache_elem_free);
/* Add the loopback if needed */
if (as->hierarchy == SURF_ROUTING_BASE)
- add_loopback_dijkstra(THIS);
+ add_loopback_dijkstra(THIS_AS);
/* initialize graph indexes in nodes after graph has been built */
- nodes = xbt_graph_get_nodes(THIS->route_graph);
+ nodes = xbt_graph_get_nodes(THIS_AS->route_graph);
xbt_dynar_foreach(nodes, cursor2, node) {
graph_node_data_t data = xbt_graph_node_get_data(node);
if(!as->route_graph)
as->route_graph = xbt_graph_new_graph(1, NULL);
if(!as->graph_node_map)
- as->graph_node_map = xbt_dict_new();
+ as->graph_node_map = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
if (as->cached && !as->route_cache)
- as->route_cache = xbt_dict_new();
+ as->route_cache = xbt_dict_new_homogeneous(&route_cache_elem_free);
if( A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES
|| A_surfxml_ASroute_symmetrical == A_surfxml_ASroute_symmetrical_YES )