From: Frederic Suter Date: Mon, 18 Apr 2016 11:23:33 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_13~76 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/72cfaf84e1338bfa4821d04a291c702f87f12a82?hp=74fc60e78b0e3839d62fdf57eea7d99ad24fafcc Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index 7775b9599f..9d52127c65 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -338,10 +338,11 @@ int console_add_route(lua_State *L) { type = lua_gettable(L,-2); lua_ensure(type == LUA_TSTRING, "Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces."); + route.link_list = new std::vector(); xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n"); if (xbt_dynar_is_empty(names)) { /* unique name */ - route.link_list.push_back(Link::byName(lua_tostring(L, -1))); + route.link_list->push_back(Link::byName(lua_tostring(L, -1))); } else { // Several names separated by , \t\r\n unsigned int cpt; @@ -349,7 +350,7 @@ int console_add_route(lua_State *L) { xbt_dynar_foreach(names, cpt, name) { if (strlen(name)>0) { Link *link = Link::byName(name); - route.link_list.push_back(link); + route.link_list->push_back(link); } } } @@ -413,10 +414,11 @@ int console_add_ASroute(lua_State *L) { lua_pushstring(L,"links"); lua_gettable(L,-2); + ASroute.link_list = new std::vector(); xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n"); if (xbt_dynar_is_empty(names)) { /* unique name with no comma */ - ASroute.link_list.push_back(Link::byName(lua_tostring(L, -1))); + ASroute.link_list->push_back(Link::byName(lua_tostring(L, -1))); } else { // Several names separated by , \t\r\n unsigned int cpt; @@ -424,7 +426,7 @@ int console_add_ASroute(lua_State *L) { xbt_dynar_foreach(names, cpt, name) { if (strlen(name)>0) { Link *link = Link::byName(name); - ASroute.link_list.push_back(link); + ASroute.link_list->push_back(link); } } } diff --git a/src/s4u/s4u_as.cpp b/src/s4u/s4u_as.cpp index ec748abc80..b0f760f50e 100644 --- a/src/s4u/s4u_as.cpp +++ b/src/s4u/s4u_as.cpp @@ -82,19 +82,19 @@ namespace simgrid { if (e_route->gw_dst) { XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s", src, e_route->gw_src->name(), dst, e_route->gw_dst->name()); - xbt_assert(!e_route->link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", + xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src, e_route->gw_src->name(), dst, e_route->gw_dst->name()); xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s@%s and %s@%s already exists.", src, e_route->gw_src->name(), dst, e_route->gw_dst->name()); } else { XBT_DEBUG("Load bypassRoute from %s to %s", src, dst); - xbt_assert(!e_route->link_list.empty(), "Bypass route between %s and %s cannot be empty.", src, dst); + xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", src, dst); xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s and %s already exists.", src, dst); } /* Build a copy that will be stored in the dict */ std::vector *newRoute = new std::vector(); - for (auto link: e_route->link_list) + for (auto link: *e_route->link_list) newRoute->push_back(link); /* Store it */ diff --git a/src/surf/AsCluster.cpp b/src/surf/AsCluster.cpp index cd79138109..8fe7144a12 100644 --- a/src/surf/AsCluster.cpp +++ b/src/surf/AsCluster.cpp @@ -32,7 +32,7 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb if((src->id() == dst->id()) && has_loopback_ ){ info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); if (lat) *lat += info.link_up->getLatency(); return; @@ -41,12 +41,12 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb if (has_limiter_){ // limiter for sender info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); - route->link_list.push_back((Link*)info.link_up); + route->link_list->push_back((Link*)info.link_up); } info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_up) { // link up - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); if (lat) *lat += info.link_up->getLatency(); } @@ -54,7 +54,7 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb } if (backbone_) { - route->link_list.push_back(backbone_); + route->link_list->push_back(backbone_); if (lat) *lat += backbone_->getLatency(); } @@ -63,19 +63,20 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb info = xbt_dynar_get_as(privateLinks_, dst->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_down) { // link down - route->link_list.push_back(info.link_down); + route->link_list->push_back(info.link_down); if (lat) *lat += info.link_down->getLatency(); } if (has_limiter_){ // limiter for receiver info = xbt_dynar_get_as(privateLinks_, dst->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); } } } void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) { + int isrc; int table_size = xbt_dynar_length(vertices_); NetCard *src; @@ -95,7 +96,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) new_xbt_graph_edge(graph, routerNode, backboneNode, edges); } - for (int isrc = 0; isrc < table_size; isrc++) { + for (isrc = 0; isrc < table_size; isrc++) { src = xbt_dynar_get_as(vertices_, isrc, NetCard*); if (! src->isRouter()) { diff --git a/src/surf/AsClusterFatTree.cpp b/src/surf/AsClusterFatTree.cpp index 912561664c..2f99736be8 100644 --- a/src/surf/AsClusterFatTree.cpp +++ b/src/surf/AsClusterFatTree.cpp @@ -93,7 +93,7 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, /* In case destination is the source, and there is a loopback, let's get through it instead of going up to a switch*/ if(source->id == destination->id && this->has_loopback_) { - into->link_list.push_back(source->loopback); + into->link_list->push_back(source->loopback); if(latency) { *latency += source->loopback->getLatency(); } @@ -112,14 +112,14 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, } k = this->upperLevelNodesNumber_[currentNode->level]; d = d % k; - into->link_list.push_back(currentNode->parents[d]->upLink); + into->link_list->push_back(currentNode->parents[d]->upLink); if(latency) { *latency += currentNode->parents[d]->upLink->getLatency(); } if (this->has_limiter_) { - into->link_list.push_back(currentNode->limiterLink); + into->link_list->push_back(currentNode->limiterLink); } currentNode = currentNode->parents[d]->upNode; } @@ -133,13 +133,13 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, for(unsigned int i = 0 ; i < currentNode->children.size() ; i++) { if(i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) { - into->link_list.push_back(currentNode->children[i]->downLink); + into->link_list->push_back(currentNode->children[i]->downLink); if(latency) { *latency += currentNode->children[i]->downLink->getLatency(); } currentNode = currentNode->children[i]->downNode; if (this->has_limiter_) { - into->link_list.push_back(currentNode->limiterLink); + into->link_list->push_back(currentNode->limiterLink); } XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level, destination->position, currentNode->id, diff --git a/src/surf/AsClusterTorus.cpp b/src/surf/AsClusterTorus.cpp index 31f6524db9..223c068e9f 100644 --- a/src/surf/AsClusterTorus.cpp +++ b/src/surf/AsClusterTorus.cpp @@ -120,7 +120,7 @@ namespace simgrid { if ((src->id() == dst->id()) && has_loopback_) { s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); if (lat) *lat += info.link_up->getLatency(); return; @@ -201,17 +201,17 @@ namespace simgrid { if (has_limiter_) { // limiter for sender info = xbt_dynar_get_as(privateLinks_, nodeOffset + has_loopback_, s_surf_parsing_link_up_down_t); - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); } info = xbt_dynar_get_as(privateLinks_, linkOffset, s_surf_parsing_link_up_down_t); if (use_lnk_up == false) { - route->link_list.push_back(info.link_down); + route->link_list->push_back(info.link_down); if (lat) *lat += info.link_down->getLatency(); } else { - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); if (lat) *lat += info.link_up->getLatency(); } diff --git a/src/surf/AsDijkstra.cpp b/src/surf/AsDijkstra.cpp index 57845ae50d..ec9af59303 100644 --- a/src/surf/AsDijkstra.cpp +++ b/src/surf/AsDijkstra.cpp @@ -28,7 +28,10 @@ static void graph_node_map_elem_free(void *e) static void graph_edge_data_free(void *e) // FIXME: useless code duplication { sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t) e; - xbt_free(e_route); + if (e_route) { + delete e_route->link_list; + xbt_free(e_route); + } } /* Utility functions */ @@ -61,7 +64,8 @@ void AsDijkstra::seal() if (!found) { sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - e_route->link_list.push_back(routing_platf->loopback_); + e_route->link_list = new std::vector(); + e_route->link_list->push_back(routing_platf->loopback_); xbt_graph_new_edge(routeGraph_, node, node, e_route); } } @@ -163,8 +167,8 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge); - for (auto link: e_route->link_list) { - route->link_list.insert(route->link_list.begin(), link); + for (auto link: *e_route->link_list) { + route->link_list->insert(route->link_list->begin(), link); if (lat) *lat += static_cast(link)->getLatency(); } @@ -214,7 +218,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(u_node); int u_id = data->graph_id; sg_platf_route_cbarg_t tmp_e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge); - int cost_v_u = tmp_e_route->link_list.size(); /* count of links, old model assume 1 */ + int cost_v_u = tmp_e_route->link_list->size(); /* count of links, old model assume 1 */ if (cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) { pred_arr[u_id] = *v_id; @@ -258,17 +262,17 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c std::vector *e_route_as_to_as = new std::vector(); routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, NULL); - auto pos = route->link_list.begin(); + auto pos = route->link_list->begin(); for (auto link : *e_route_as_to_as) { - route->link_list.insert(pos, link); + route->link_list->insert(pos, link); if (lat) *lat += link->getLatency(); pos++; } } - for (auto link: e_route->link_list) { - route->link_list.insert(route->link_list.begin(), link); + for (auto link: *e_route->link_list) { + route->link_list->insert(route->link_list->begin(), link); if (lat) *lat += static_cast(link)->getLatency(); } diff --git a/src/surf/AsFloyd.cpp b/src/surf/AsFloyd.cpp index 6f215c540f..960b039f34 100644 --- a/src/surf/AsFloyd.cpp +++ b/src/surf/AsFloyd.cpp @@ -68,11 +68,11 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t); if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) { - routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, &route->link_list, lat); + routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat); } - for (auto link: e_route->link_list) { - route->link_list.push_back(link); + for (auto link: *e_route->link_list) { + route->link_list->push_back(link); if (lat) *lat += link->getLatency(); } @@ -118,7 +118,7 @@ void AsFloyd::addRoute(sg_platf_route_cbarg_t route) TO_FLOYD_LINK(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1); TO_FLOYD_PRED(src->id(), dst->id()) = src->id(); - TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list.size(); + TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list->size(); if (route->symmetrical == true) { @@ -145,7 +145,7 @@ void AsFloyd::addRoute(sg_platf_route_cbarg_t route) TO_FLOYD_LINK(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0); TO_FLOYD_PRED(dst->id(), src->id()) = dst->id(); - TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list.size(); /* count of links, old model assume 1 */ + TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list->size(); /* count of links, old model assume 1 */ } } @@ -177,7 +177,8 @@ void AsFloyd::seal(){ e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); e_route->gw_src = NULL; e_route->gw_dst = NULL; - e_route->link_list.push_back(routing_platf->loopback_); + e_route->link_list = new std::vector(); + e_route->link_list->push_back(routing_platf->loopback_); TO_FLOYD_LINK(i, i) = e_route; TO_FLOYD_PRED(i, i) = i; TO_FLOYD_COST(i, i) = 1; diff --git a/src/surf/AsFull.cpp b/src/surf/AsFull.cpp index 07c585119d..37d3ff7709 100644 --- a/src/surf/AsFull.cpp +++ b/src/surf/AsFull.cpp @@ -36,7 +36,8 @@ void AsFull::seal() { e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); e_route->gw_src = NULL; e_route->gw_dst = NULL; - e_route->link_list.push_back(routing_platf->loopback_); + e_route->link_list = new std::vector(); + e_route->link_list->push_back(routing_platf->loopback_); TO_ROUTE_FULL(i, i) = e_route; } } @@ -46,11 +47,15 @@ void AsFull::seal() { AsFull::~AsFull(){ if (routingTable_) { int table_size = (int)xbt_dynar_length(vertices_); + int i, j; /* Delete routing table */ - for (int i = 0; i < table_size; i++) - for (int j = 0; j < table_size; j++) - if (TO_ROUTE_FULL(i,j)) + for (i = 0; i < table_size; i++) + for (j = 0; j < table_size; j++) { + if (TO_ROUTE_FULL(i,j)){ + delete TO_ROUTE_FULL(i,j)->link_list; xbt_free(TO_ROUTE_FULL(i,j)); + } + } xbt_free(routingTable_); } } @@ -70,8 +75,8 @@ void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg if (e_route) { res->gw_src = e_route->gw_src; res->gw_dst = e_route->gw_dst; - for (auto link : e_route->link_list) { - res->link_list.push_back(link); + for (auto link : *e_route->link_list) { + res->link_list->push_back(link); if (lat) *lat += static_cast(link)->getLatency(); } @@ -103,7 +108,7 @@ void AsFull::addRoute(sg_platf_route_cbarg_t route) /* Add the route to the base */ TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()) = newExtendedRoute(hierarchy_, route, 1); - TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list.shrink_to_fit(); + TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list->shrink_to_fit(); if (route->symmetrical == true && src_net_elm != dst_net_elm) { if (route->gw_dst && route->gw_src) { @@ -120,7 +125,7 @@ void AsFull::addRoute(sg_platf_route_cbarg_t route) "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", dst,src); TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0); - TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list.shrink_to_fit(); + TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list->shrink_to_fit(); } } diff --git a/src/surf/AsImpl.cpp b/src/surf/AsImpl.cpp index 5fb43f4f38..3a9f80e595 100644 --- a/src/surf/AsImpl.cpp +++ b/src/surf/AsImpl.cpp @@ -192,14 +192,15 @@ namespace simgrid { /* If src and dst are in the same AS, life is good */ if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */ + route.link_list = links; common_ancestor->getRouteAndLatency(src, dst, &route, latency); - for (surf::Link *link : route.link_list) - links->push_back(link); return; } /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/ + route.link_list = new std::vector(); + common_ancestor->getRouteAndLatency(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency); xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL), "bad gateways for route from \"%s\" to \"%s\"", src->name(), dst->name()); @@ -207,12 +208,14 @@ namespace simgrid { /* If source gateway is not our source, we have to recursively find our way up to this point */ if (src != route.gw_src) getRouteRecursive(src, route.gw_src, links, latency); - for (auto link: route.link_list) + for (auto link: *route.link_list) links->push_back(link); /* If dest gateway is not our destination, we have to recursively find our way from this point */ if (route.gw_dst != dst) getRouteRecursive(route.gw_dst, dst, links, latency); + } + } }; diff --git a/src/surf/AsRoutedGraph.cpp b/src/surf/AsRoutedGraph.cpp index 503f600d1d..e58e1979d2 100644 --- a/src/surf/AsRoutedGraph.cpp +++ b/src/surf/AsRoutedGraph.cpp @@ -16,7 +16,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic imple void routing_route_free(sg_platf_route_cbarg_t route) { - xbt_free(route); + if (route) { + delete route->link_list; + xbt_free(route); + } } namespace simgrid { @@ -86,17 +89,18 @@ namespace surf { { xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); + route->link_list = new std::vector(); int table_size = (int)xbt_dynar_length(vertices_); for(int src=0; src < table_size; src++) { for(int dst=0; dst< table_size; dst++) { - route->link_list.clear(); + route->link_list->clear(); NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*); NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*); this->getRouteAndLatency(src_elm, dst_elm,route, NULL); - if (route->link_list.size() == 1) { - Link *link = route->link_list.at(0); + if (route->link_list->size() == 1) { + Link *link = route->link_list->at(0); Onelink *onelink; if (hierarchy_ == RoutingMode::base) onelink = new Onelink(link, src_elm, dst_elm); @@ -127,6 +131,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg xbt_dynar_get_as(vertices_, dst, NetCard*); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); + route->link_list = new std::vector(); getRouteAndLatency(my_src, my_dst, route, NULL); @@ -143,7 +148,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg previous_name = my_src->name(); } - for (auto link: route->link_list) { + for (auto link: *route->link_list) { const char *link_name = link->getName(); current = new_xbt_graph_node(graph, link_name, nodes); current_name = link_name; @@ -163,6 +168,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg new_xbt_graph_edge(graph, previous, current, edges); XBT_DEBUG (" %s -> %s", previous_name, current_name); + delete route->link_list; xbt_free (route); } } @@ -177,6 +183,7 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(RoutingMode hierarchy, sg sg_platf_route_cbarg_t result; result = xbt_new0(s_sg_platf_route_cbarg_t, 1); + result->link_list = new std::vector(); xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive, "The hierarchy of this AS is neither BASIC nor RECURSIVE, I'm lost here."); @@ -188,11 +195,11 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(RoutingMode hierarchy, sg result->gw_dst = routearg->gw_dst; } - for (auto link : routearg->link_list) { + for (auto link : *routearg->link_list) { if (change_order) - result->link_list.push_back(link); + result->link_list->push_back(link); else - result->link_list.insert(result->link_list.begin(), link); + result->link_list->insert(result->link_list->begin(), link); } return result; @@ -223,7 +230,7 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName); xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName); xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName); - xbt_assert(! route->link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName); + xbt_assert(! route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName); xbt_assert(! src->isAS(), "When defining a route, src cannot be an AS such as '%s'. Did you meant to have an ASroute?", srcName); xbt_assert(! dst->isAS(), "When defining a route, dst cannot be an AS such as '%s'. Did you meant to have an ASroute?", dstName); } else { @@ -242,7 +249,7 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { srcName,route->gw_src->name(), dstName,route->gw_dst->name(), srcName); xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName,route->gw_src->name(), dstName,route->gw_dst->name(), dstName); - xbt_assert(! route->link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.", + xbt_assert(! route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,route->gw_src->name(), dstName,route->gw_dst->name()); } } diff --git a/src/surf/AsVivaldi.cpp b/src/surf/AsVivaldi.cpp index 682afe3f4e..1a17446b0f 100644 --- a/src/surf/AsVivaldi.cpp +++ b/src/surf/AsVivaldi.cpp @@ -64,7 +64,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb if ((int)xbt_dynar_length(privateLinks_) > src->id()) { s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(privateLinks_, src->id(), s_surf_parsing_link_up_down_t); if(info.link_up) { - route->link_list.push_back(info.link_up); + route->link_list->push_back(info.link_up); if (lat) *lat += info.link_up->getLatency(); } @@ -72,7 +72,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb if ((int)xbt_dynar_length(privateLinks_)>dst->id()) { s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(privateLinks_, dst->id(), s_surf_parsing_link_up_down_t); if(info.link_down) { - route->link_list.push_back(info.link_down); + route->link_list->push_back(info.link_down); if (lat) *lat += info.link_down->getLatency(); } diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index df823bb6b6..3d21302f1a 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -91,7 +91,7 @@ typedef struct s_sg_platf_route_cbarg { const char *dst; sg_netcard_t gw_src; sg_netcard_t gw_dst; - std::vector link_list; + std::vector *link_list; } s_sg_platf_route_cbarg_t; typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index bf7b20ee55..3d2e6a3aad 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -728,16 +728,18 @@ void ETag_surfxml_route(void){ route.dst = A_surfxml_route_dst; route.gw_src = nullptr; route.gw_dst = nullptr; + route.link_list = new std::vector(); route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES); unsigned int cpt; char *link_name; xbt_dynar_foreach(parsed_link_list, cpt, link_name) { simgrid::surf::Link *link = Link::byName(link_name); - route.link_list.push_back(link); + route.link_list->push_back(link); } sg_platf_new_route(&route); + delete route.link_list; xbt_dynar_free(&parsed_link_list); } @@ -758,12 +760,13 @@ void ETag_surfxml_ASroute(void){ surf_parse_error("gw_dst=\"%s\" not found for ASroute from \"%s\" to \"%s\"", A_surfxml_ASroute_gw___dst, ASroute.src, ASroute.dst); + ASroute.link_list = new std::vector(); unsigned int cpt; char *link_name; xbt_dynar_foreach(parsed_link_list, cpt, link_name) { simgrid::surf::Link *link = Link::byName(link_name); - ASroute.link_list.push_back(link); + ASroute.link_list->push_back(link); } xbt_dynar_free(&parsed_link_list); @@ -789,12 +792,13 @@ void ETag_surfxml_bypassRoute(void){ route.gw_src = nullptr; route.gw_dst = nullptr; route.symmetrical = false; + route.link_list = new std::vector(); unsigned int cpt; char *link_name; xbt_dynar_foreach(parsed_link_list, cpt, link_name) { simgrid::surf::Link *link = Link::byName(link_name); - route.link_list.push_back(link); + route.link_list->push_back(link); } xbt_dynar_free(&parsed_link_list); @@ -807,11 +811,12 @@ void ETag_surfxml_bypassASroute(void){ ASroute.src = A_surfxml_bypassASroute_src; ASroute.dst = A_surfxml_bypassASroute_dst; + ASroute.link_list = new std::vector(); unsigned int cpt; char *link_name; xbt_dynar_foreach(parsed_link_list, cpt, link_name) { simgrid::surf::Link *link = Link::byName(link_name); - ASroute.link_list.push_back(link); + ASroute.link_list->push_back(link); } xbt_dynar_free(&parsed_link_list); ASroute.symmetrical = false;