X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8d4d9afda47914b5a7a12905d9220c3a394608d1..55633c554b60455d85885816b1b73e9698b73a14:/src/surf/surf_routing.cpp diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 4c8b00f9ef..1ef547b3c5 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -5,14 +5,10 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "surf_routing.hpp" -#include "surf_routing_private.hpp" #include "surf_routing_cluster.hpp" -#include "simgrid/platf_interface.h" // platform creation API internal interface #include "simgrid/sg_config.h" #include "storage_interface.hpp" -#include "src/surf/platform.hpp" -#include "surf/surfxml_parse_values.h" #include "src/surf/surf_routing_cluster_torus.hpp" #include "src/surf/surf_routing_cluster_fat_tree.hpp" @@ -20,6 +16,7 @@ #include "src/surf/surf_routing_floyd.hpp" #include "src/surf/surf_routing_full.hpp" #include "src/surf/surf_routing_vivaldi.hpp" +#include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area #include @@ -79,7 +76,7 @@ namespace surf { char *route_name = bprintf("%s#%s", src->name(), dst->name()); if (bypassRoutes_->find(route_name) != bypassRoutes_->end()) { bypassedRoute = bypassRoutes_->at(route_name); - XBT_DEBUG("Found a bypass route with %ld links",bypassedRoute->size()); + XBT_DEBUG("Found a bypass route with %zu links",bypassedRoute->size()); } free(route_name); return bypassedRoute; @@ -184,28 +181,21 @@ namespace surf { 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(!xbt_dynar_is_empty(e_route->link_list), "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(route_name) == 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(!xbt_dynar_is_empty(e_route->link_list), "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(route_name) == bypassRoutes_->end(), "The bypass route between %s and %s already exists.", src, dst); } - /* Build the value that will be stored in the dict */ + /* Build a copy that will be stored in the dict */ std::vector *newRoute = new std::vector(); - char *linkName; - unsigned int cpt; - xbt_dynar_foreach(e_route->link_list, cpt, linkName) { - Link *link = Link::byName(linkName); - if (link) - newRoute->push_back(link); - else - THROWF(mismatch_error, 0, "Link '%s' not found", linkName); - } + for (auto link: *e_route->link_list) + newRoute->push_back(link); /* Store it */ bypassRoutes_->insert({route_name, newRoute}); @@ -463,7 +453,7 @@ static void elements_father(sg_netcard_t src, sg_netcard_t dst, * \param *latency the latency, if needed */ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, - xbt_dynar_t * links, double *latency) + std::vector * links, double *latency) { s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER; memset(&route,0,sizeof(route)); @@ -481,7 +471,7 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N std::vector *bypassed_route = common_father->getBypassRoute(src, dst); if (nullptr != bypassed_route) { for (Link *link : *bypassed_route) { - xbt_dynar_push(*links,&link); + links->push_back(link); if (latency) *latency += link->getLatency(); } @@ -490,14 +480,14 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N /* If src and dst are in the same AS, life is good */ if (src_father == dst_father) { /* SURF_ROUTING_BASE */ - route.link_list = *links; + route.link_list = links; common_father->getRouteAndLatency(src, dst, &route, latency); return; } /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/ - route.link_list = xbt_dynar_new(sizeof(Link*), NULL); + route.link_list = new std::vector(); common_father->getRouteAndLatency(src_father->netcard_, dst_father->netcard_, &route, latency); xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL), @@ -506,7 +496,8 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N /* If source gateway is not our source, we have to recursively find our way up to this point */ if (src != route.gw_src) _get_route_and_latency(src, route.gw_src, links, latency); - xbt_dynar_merge(links, &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) @@ -514,14 +505,6 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N } -AS_t surf_platf_get_root(routing_platf_t platf){ - return platf->root_; -} - -e_surf_network_element_type_t surf_routing_edge_get_rc_type(sg_netcard_t netcard){ - return netcard->getRcType(); -} - namespace simgrid { namespace surf { @@ -539,13 +522,9 @@ namespace surf { * walk through the routing components tree and find a route between hosts * by calling each "get_route" function in each routing component. */ -void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t* route, double *latency) +void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector * route, double *latency) { XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name()); - if (NULL == *route) { - xbt_dynar_reset(routing_platf->lastRoute_); - *route = routing_platf->lastRoute_; - } _get_route_and_latency(src, dst, route, latency); } @@ -579,7 +558,7 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ } /** @brief create the root AS */ -void routing_model_create( void *loopback) +void routing_model_create(Link *loopback) { routing_platf = new simgrid::surf::RoutingPlatf(loopback); } @@ -625,14 +604,11 @@ void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet) } s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; memset(&host, 0, sizeof(host)); - host.initiallyOn = 1; host.pstate = 0; - host.speed_scale = 1.0; host.core_amount = 1; s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; memset(&link, 0, sizeof(link)); - link.initiallyOn = 1; link.policy = SURF_LINK_FULLDUPLEX; link.latency = cabinet->lat; link.bandwidth = cabinet->bw; @@ -679,9 +655,9 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) char *router_id = NULL; XBT_DEBUG(" "); - host_id = HOST_PEER(peer->id); - link_id = LINK_PEER(peer->id); - router_id = ROUTER_PEER(peer->id); + host_id = bprintf("peer_%s", peer->id); + link_id = bprintf("link_%s", peer->id); + router_id = bprintf("router_%s", peer->id); XBT_DEBUG("", peer->id); s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER; @@ -692,14 +668,12 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) XBT_DEBUG("", host_id, peer->speed); s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; memset(&host, 0, sizeof(host)); - host.initiallyOn = 1; host.id = host_id; host.speed_peak = xbt_dynar_new(sizeof(double), NULL); xbt_dynar_push(host.speed_peak,&peer->speed); host.pstate = 0; //host.power_peak = peer->power; - host.speed_scale = 1.0; host.speed_trace = peer->availability_trace; host.state_trace = peer->state_trace; host.core_amount = 1; @@ -708,7 +682,6 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; memset(&link, 0, sizeof(link)); - link.initiallyOn = 1; link.policy = SURF_LINK_SHARED; link.latency = peer->lat; @@ -925,7 +898,7 @@ void routing_exit(void) { namespace simgrid { namespace surf { - RoutingPlatf::RoutingPlatf(void *loopback) + RoutingPlatf::RoutingPlatf(Link *loopback) : loopback_(loopback) { }