* 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"
#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 <vector>
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;
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<Link*> *newRoute = new std::vector<Link*>();
- 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});
* \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<Link*> * links, double *latency)
{
s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER;
memset(&route,0,sizeof(route));
std::vector<Link*> *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();
}
/* 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<Link*>();
common_father->getRouteAndLatency(src_father->netcard_, dst_father->netcard_, &route, latency);
xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL),
/* 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)
}
-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 {
* 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<Link*> * 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);
}
}
/** @brief create the root AS */
-void routing_model_create( void *loopback)
+void routing_model_create(Link *loopback)
{
routing_platf = new simgrid::surf::RoutingPlatf(loopback);
}
}
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;
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("<AS id=\"%s\"\trouting=\"Cluster\">", peer->id);
s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", 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;
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;
namespace simgrid {
namespace surf {
- RoutingPlatf::RoutingPlatf(void *loopback)
+ RoutingPlatf::RoutingPlatf(Link *loopback)
: loopback_(loopback)
{
}