A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
rename As::getRouteAndLatency into As::getLocalRoute
[simgrid.git]
/
src
/
kernel
/
routing
/
AsRoutedGraph.cpp
diff --git
a/src/kernel/routing/AsRoutedGraph.cpp
b/src/kernel/routing/AsRoutedGraph.cpp
index
c25a516
..
8dc559f
100644
(file)
--- a/
src/kernel/routing/AsRoutedGraph.cpp
+++ b/
src/kernel/routing/AsRoutedGraph.cpp
@@
-30,8
+30,6
@@
AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name
{
}
-AsRoutedGraph::~AsRoutedGraph()=default;
-
}}} // namespace simgrid::kernel::routing
/* ************************************************************************** */
@@
-81,35
+79,34
@@
namespace simgrid {
namespace kernel {
namespace routing {
- xbt_dynar_t AsRoutedGraph::getOneLinkRoutes()
- {
- 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<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->getRouteAndLatency(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);
- xbt_dynar_push(ret, &onelink);
- }
+void AsRoutedGraph::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
+{
+ 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);
}
}
- return ret;
}
+ 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)
{
@@
-121,19
+118,19
@@
void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
route->link_list = new std::vector<Link*>();
- get
RouteAndLatency
(my_src, my_dst, route, nullptr);
+ get
LocalRoute
(my_src, my_dst, route, nullptr);
- XBT_DEBUG
("get_route_and_latency %s -> %s", my_src->name(), my_dst->name
());
+ XBT_DEBUG
("get_route_and_latency %s -> %s", my_src->name().c_str(), my_dst->name().c_str
());
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
(), nodes);
- previous_name = route->gw_src->name();
+ previous
= new_xbt_graph_node(graph, route->gw_src->name().c_str
(), nodes);
+ previous_name = route->gw_src->name()
.c_str()
;
} else {
- previous
= new_xbt_graph_node(graph, my_src->name
(), nodes);
- previous_name = my_src->name();
+ previous
= new_xbt_graph_node(graph, my_src->name().c_str
(), nodes);
+ previous_name = my_src->name()
.c_str()
;
}
for (auto link: *route->link_list) {
@@
-147,11
+144,11
@@
void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
}
if (route->gw_dst) {
- current
= new_xbt_graph_node(graph, route->gw_dst->name
(), nodes);
- current_name = route->gw_dst->name();
+ current
= new_xbt_graph_node(graph, route->gw_dst->name().c_str
(), nodes);
+ current_name = route->gw_dst->name()
.c_str()
;
} else {
- current
= new_xbt_graph_node(graph, my_dst->name
(), nodes);
- current_name = my_dst->name();
+ current
= new_xbt_graph_node(graph, my_dst->name().c_str
(), nodes);
+ current_name = my_dst->name()
.c_str()
;
}
new_xbt_graph_edge(graph, previous, current, edges);
XBT_DEBUG (" %s -> %s", previous_name, current_name);
@@
-194,24
+191,25
@@
sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(RoutingMode hierarchy, sg
void AsRoutedGraph::getRouteCheckParams(NetCard *src, NetCard *dst)
{
- xbt_assert(src,
"Cannot find a route from nullptr to %s", dst->name
());
- xbt_assert(dst,
"Cannot find a route from %s to nullptr", src->name
());
+ 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
());
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(), src_as->name(), dst->name(), dst_as->name());
+ 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());
- 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(), dst->name(), src_as->name(), dst_as->name(),
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());
}
void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
NetCard *src = route->src;
NetCard *dst = route->dst;
- const char
*srcName = src->name
();
- const char
*dstName = dst->name
();
+ const char
* srcName = src->name().c_str
();
+ const char
* dstName = dst->name().c_str
();
if(!route->gw_dst && !route->gw_src) {
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
@@
-221,7
+219,8
@@
void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
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(), dstName, route->gw_dst->name());
+ 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_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);
@@
-230,14
+229,15
@@
void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
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());
+ xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself",
+ route->gw_src->name().c_str());
- xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
-
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."
,
-
srcName,route->gw_src->name(), dstName,route->gw_dst->name
());
+ 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(!
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
());
}
}