#include "xbt/graph.h"
#include "src/kernel/routing/AsRoutedGraph.hpp"
+#include "src/kernel/routing/NetCard.hpp"
#include "src/surf/network_interface.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
}
}
-namespace simgrid {
-namespace kernel {
-namespace routing {
-
-AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name)
-{
-}
-
-}}} // namespace simgrid::kernel::routing
-
/* ************************************************************************** */
/* *********************** GENERIC BUSINESS METHODS ************************* */
namespace kernel {
namespace routing {
-void AsRoutedGraph::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
+AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name)
{
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- route->link_list = new std::vector<Link*>();
-
- int table_size = static_cast<int>(vertices_.size());
- for (int src = 0; src < table_size; src++) {
- for (int dst = 0; dst < table_size; dst++) {
- route->link_list->clear();
- NetCard* src_elm = vertices_.at(src);
- NetCard* dst_elm = vertices_.at(dst);
- this->getLocalRoute(src_elm, dst_elm, route, nullptr);
-
- 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);
- else if (hierarchy_ == RoutingMode::recursive)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, nullptr, nullptr);
- accumulator->push_back(onelink);
- }
- }
- }
- AsImpl::getOneLinkRoutes(accumulator); // Recursivly call this function on all my childs too
}
void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
getLocalRoute(my_src, my_dst, route, nullptr);
- XBT_DEBUG("get_route_and_latency %s -> %s", my_src->name().c_str(), my_dst->name().c_str());
+ XBT_DEBUG("get_route_and_latency %s -> %s", my_src->cname(), my_dst->cname());
xbt_node_t current, previous;
const char *previous_name, *current_name;
if (route->gw_src) {
- previous = new_xbt_graph_node(graph, route->gw_src->name().c_str(), nodes);
- previous_name = route->gw_src->name().c_str();
+ previous = new_xbt_graph_node(graph, route->gw_src->cname(), nodes);
+ previous_name = route->gw_src->cname();
} else {
- previous = new_xbt_graph_node(graph, my_src->name().c_str(), nodes);
- previous_name = my_src->name().c_str();
+ previous = new_xbt_graph_node(graph, my_src->cname(), nodes);
+ previous_name = my_src->cname();
}
for (auto link: *route->link_list) {
}
if (route->gw_dst) {
- current = new_xbt_graph_node(graph, route->gw_dst->name().c_str(), nodes);
- current_name = route->gw_dst->name().c_str();
+ current = new_xbt_graph_node(graph, route->gw_dst->cname(), nodes);
+ current_name = route->gw_dst->cname();
} else {
- current = new_xbt_graph_node(graph, my_dst->name().c_str(), nodes);
- current_name = my_dst->name().c_str();
+ current = new_xbt_graph_node(graph, my_dst->cname(), nodes);
+ current_name = my_dst->cname();
}
new_xbt_graph_edge(graph, previous, current, edges);
XBT_DEBUG (" %s -> %s", previous_name, current_name);
void AsRoutedGraph::getRouteCheckParams(NetCard *src, NetCard *dst)
{
- xbt_assert(src, "Cannot find a route from nullptr to %s", dst->name().c_str());
- xbt_assert(dst, "Cannot find a route from %s to nullptr", src->name().c_str());
+ xbt_assert(src, "Cannot find a route from nullptr to %s", dst->cname());
+ xbt_assert(dst, "Cannot find a route from %s to nullptr", src->cname());
As *src_as = src->containingAS();
As *dst_as = dst->containingAS();
xbt_assert(src_as == dst_as,
"Internal error: %s@%s and %s@%s are not in the same AS as expected. Please report that bug.",
- src->name().c_str(), src_as->name(), dst->name().c_str(), dst_as->name());
+ src->cname(), src_as->name(), dst->cname(), dst_as->name());
xbt_assert(this == dst_as, "Internal error: route destination %s@%s is not in AS %s as expected (route source: "
"%s@%s). Please report that bug.",
- src->name().c_str(), dst->name().c_str(), src_as->name(), dst_as->name(), name());
+ src->cname(), dst->cname(), src_as->name(), dst_as->name(), name());
}
void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
NetCard *src = route->src;
NetCard *dst = route->dst;
- const char* srcName = src->name().c_str();
- const char* dstName = dst->name().c_str();
+ const char* srcName = src->cname();
+ const char* dstName = dst->cname();
if(!route->gw_dst && !route->gw_src) {
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", 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 {
- XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name().c_str(), dstName,
- route->gw_dst->name().c_str());
+ XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->cname(), dstName, route->gw_dst->cname());
xbt_assert(src->isAS(), "When defining an ASroute, src must be an AS but '%s' is not", srcName);
xbt_assert(dst->isAS(), "When defining an ASroute, dst must be an AS but '%s' is not", dstName);
xbt_assert(route->gw_dst->isHost() || route->gw_dst->isRouter(),
"When defining an ASroute, gw_dst must be an host or a router but '%s' is not.", dstName);
- xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself",
- route->gw_src->name().c_str());
+ xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", route->gw_src->cname());
- xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName,
- route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str(), srcName);
- xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName,
- route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str(), dstName);
+ xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->cname(),
+ dstName, route->gw_dst->cname(), srcName);
+ xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->cname(),
+ dstName, route->gw_dst->cname(), dstName);
xbt_assert(!route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
- route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str());
+ route->gw_src->cname(), dstName, route->gw_dst->cname());
}
+
+ onRouteCreation(route->symmetrical, route->src, route->dst, route->gw_src, route->gw_dst, route->link_list);
}
}}}