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
enum class values should be UPPER_CASE
[simgrid.git]
/
src
/
kernel
/
routing
/
DijkstraZone.cpp
diff --git
a/src/kernel/routing/DijkstraZone.cpp
b/src/kernel/routing/DijkstraZone.cpp
index
85dfd1a
..
4aa05bb
100644
(file)
--- a/
src/kernel/routing/DijkstraZone.cpp
+++ b/
src/kernel/routing/DijkstraZone.cpp
@@
-1,11
+1,13
@@
-/* Copyright (c) 2009-201
7
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-201
8
. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "s
rc
/kernel/routing/DijkstraZone.hpp"
-#include "s
rc
/kernel/routing/NetPoint.hpp"
+#include "s
imgrid
/kernel/routing/DijkstraZone.hpp"
+#include "s
imgrid
/kernel/routing/NetPoint.hpp"
#include "src/surf/network_interface.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/xml/platf_private.hpp"
+#include "surf/surf.hpp"
#include <cfloat>
#include <queue>
#include <cfloat>
#include <queue>
@@
-17,14
+19,12
@@
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf
static void graph_node_data_free(void* n)
{
static void graph_node_data_free(void* n)
{
- graph_node_data_t data = static_cast<graph_node_data_t>(n);
- delete data;
+ delete static_cast<graph_node_data_t>(n);
}
static void graph_edge_data_free(void* e)
{
}
static void graph_edge_data_free(void* e)
{
- sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(e);
- delete e_route;
+ delete static_cast<simgrid::kernel::routing::RouteCreationArgs*>(e);
}
/* Utility functions */
}
/* Utility functions */
@@
-38,12
+38,12
@@
void DijkstraZone::seal()
xbt_node_t node = nullptr;
/* Create the topology graph */
xbt_node_t node = nullptr;
/* Create the topology graph */
- if (not route
G
raph_)
- route
G
raph_ = xbt_graph_new_graph(1, nullptr);
+ if (not route
_g
raph_)
+ route
_g
raph_ = xbt_graph_new_graph(1, nullptr);
/* Add the loopback if needed */
if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
/* Add the loopback if needed */
if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
- xbt_dynar_foreach (xbt_graph_get_nodes(route
G
raph_), cursor, node) {
+ xbt_dynar_foreach (xbt_graph_get_nodes(route
_g
raph_), cursor, node) {
bool found = false;
xbt_edge_t edge = nullptr;
bool found = false;
xbt_edge_t edge = nullptr;
@@
-56,15
+56,15
@@
void DijkstraZone::seal()
}
if (not found) {
}
if (not found) {
-
sg_platf_route_cbarg_t e_route = new s_sg_platf_route_cbarg_t
;
+
RouteCreationArgs* e_route = new simgrid::kernel::routing::RouteCreationArgs()
;
e_route->link_list.push_back(surf_network_model->loopback_);
e_route->link_list.push_back(surf_network_model->loopback_);
- xbt_graph_new_edge(route
G
raph_, node, node, e_route);
+ xbt_graph_new_edge(route
_g
raph_, node, node, e_route);
}
}
}
/* initialize graph indexes in nodes after graph has been built */
}
}
}
/* initialize graph indexes in nodes after graph has been built */
- xbt_dynar_t nodes = xbt_graph_get_nodes(route
G
raph_);
+ xbt_dynar_t nodes = xbt_graph_get_nodes(route
_g
raph_);
xbt_dynar_foreach (nodes, cursor, node) {
graph_node_data_t data = static_cast<graph_node_data_t>(xbt_graph_node_get_data(node));
xbt_dynar_foreach (nodes, cursor, node) {
graph_node_data_t data = static_cast<graph_node_data_t>(xbt_graph_node_get_data(node));
@@
-78,21
+78,21
@@
xbt_node_t DijkstraZone::routeGraphNewNode(int id, int graph_id)
data->id = id;
data->graph_id = graph_id;
data->id = id;
data->graph_id = graph_id;
- xbt_node_t node
= xbt_graph_new_node(routeG
raph_, data);
- graph
NodeM
ap_.emplace(id, node);
+ xbt_node_t node
= xbt_graph_new_node(route_g
raph_, data);
+ graph
_node_m
ap_.emplace(id, node);
return node;
}
xbt_node_t DijkstraZone::nodeMapSearch(int id)
{
return node;
}
xbt_node_t DijkstraZone::nodeMapSearch(int id)
{
- auto ret = graph
NodeM
ap_.find(id);
- return ret == graph
NodeM
ap_.end() ? nullptr : ret->second;
+ auto ret = graph
_node_m
ap_.find(id);
+ return ret == graph
_node_m
ap_.end() ? nullptr : ret->second;
}
/* Parsing */
}
/* Parsing */
-void DijkstraZone::newRoute(int src_id, int dst_id, s
g_platf_route_cbarg_t
e_route)
+void DijkstraZone::newRoute(int src_id, int dst_id, s
imgrid::kernel::routing::RouteCreationArgs*
e_route)
{
XBT_DEBUG("Load Route from \"%d\" to \"%d\"", src_id, dst_id);
xbt_node_t src = nullptr;
{
XBT_DEBUG("Load Route from \"%d\" to \"%d\"", src_id, dst_id);
xbt_node_t src = nullptr;
@@
-121,16
+121,16
@@
void DijkstraZone::newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_rou
}
/* add link as edge to graph */
}
/* add link as edge to graph */
- xbt_graph_new_edge(route
G
raph_, src, dst, e_route);
+ xbt_graph_new_edge(route
_g
raph_, src, dst, e_route);
}
}
-void DijkstraZone::get
LocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t
route, double* lat)
+void DijkstraZone::get
_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
route, double* lat)
{
getRouteCheckParams(src, dst);
int src_id = src->id();
int dst_id = dst->id();
{
getRouteCheckParams(src, dst);
int src_id = src->id();
int dst_id = dst->id();
- xbt_dynar_t nodes = xbt_graph_get_nodes(route
G
raph_);
+ xbt_dynar_t nodes = xbt_graph_get_nodes(route
_g
raph_);
/* Use the graph_node id mapping set to quickly find the nodes */
xbt_node_t src_elm = nodeMapSearch(src_id);
/* Use the graph_node id mapping set to quickly find the nodes */
xbt_node_t src_elm = nodeMapSearch(src_id);
@@
-144,21
+144,21
@@
void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(route
G
raph_, node_s_v, node_e_v);
+ xbt_edge_t edge = xbt_graph_get_edge(route
_g
raph_, node_s_v, node_e_v);
if (edge == nullptr)
if (edge == nullptr)
- THROWF(arg_error, 0, "No route from '%s' to '%s'", src->get
Cname(), dst->getC
name());
+ THROWF(arg_error, 0, "No route from '%s' to '%s'", src->get
_cname(), dst->get_c
name());
-
sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t
>(xbt_graph_edge_get_data(edge));
+
RouteCreationArgs* e_route = static_cast<RouteCreationArgs*
>(xbt_graph_edge_get_data(edge));
for (auto const& link : e_route->link_list) {
route->link_list.insert(route->link_list.begin(), link);
if (lat)
for (auto const& link : e_route->link_list) {
route->link_list.insert(route->link_list.begin(), link);
if (lat)
- *lat += static_cast<
surf
::LinkImpl*>(link)->latency();
+ *lat += static_cast<
resource
::LinkImpl*>(link)->latency();
}
}
}
}
- auto elm = route
C
ache_.emplace(src_id, std::vector<int>());
+ auto elm = route
_c
ache_.emplace(src_id, std::vector<int>());
std::vector<int>& pred_arr = elm.first->second;
if (elm.second) { /* new element was inserted (not cached mode, or cache miss) */
std::vector<int>& pred_arr = elm.first->second;
if (elm.second) { /* new element was inserted (not cached mode, or cache miss) */
@@
-194,7
+194,7
@@
void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
xbt_node_t u_node = xbt_graph_edge_get_target(edge);
graph_node_data_t data = static_cast<graph_node_data_t>(xbt_graph_node_get_data(u_node));
int u_id = data->graph_id;
xbt_node_t u_node = xbt_graph_edge_get_target(edge);
graph_node_data_t data = static_cast<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 = static_cast<sg_platf_route_cbarg_t
>(xbt_graph_edge_get_data(edge));
+
RouteCreationArgs* tmp_e_route = static_cast<RouteCreationArgs*
>(xbt_graph_edge_get_data(edge));
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]) {
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]) {
@@
-214,12
+214,12
@@
void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
xbt_node_t node_v = xbt_dynar_get_as(nodes, v, xbt_node_t);
for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
xbt_node_t node_v = xbt_dynar_get_as(nodes, v, xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(route
G
raph_, node_pred_v, node_v);
+ xbt_edge_t edge = xbt_graph_get_edge(route
_g
raph_, node_pred_v, node_v);
if (edge == nullptr)
if (edge == nullptr)
- THROWF(arg_error, 0, "No route from '%s' to '%s'", src->get
Cname(), dst->getC
name());
+ THROWF(arg_error, 0, "No route from '%s' to '%s'", src->get
_cname(), dst->get_c
name());
-
sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t
>(xbt_graph_edge_get_data(edge));
+
RouteCreationArgs* e_route = static_cast<RouteCreationArgs*
>(xbt_graph_edge_get_data(edge));
NetPoint* prev_gw_src = gw_src;
gw_src = e_route->gw_src;
NetPoint* prev_gw_src = gw_src;
gw_src = e_route->gw_src;
@@
-228,12
+228,12
@@
void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
if (v == dst_node_id)
first_gw = gw_dst;
if (v == dst_node_id)
first_gw = gw_dst;
- if (hierarchy_ == RoutingMode::recursive && v != dst_node_id && gw_dst->get
Name() != prev_gw_src->getN
ame()) {
- std::vector<
surf
::LinkImpl*> e_route_as_to_as;
+ if (hierarchy_ == RoutingMode::recursive && v != dst_node_id && gw_dst->get
_name() != prev_gw_src->get_n
ame()) {
+ std::vector<
resource
::LinkImpl*> e_route_as_to_as;
NetPoint* gw_dst_net_elm = nullptr;
NetPoint* prev_gw_src_net_elm = nullptr;
NetPoint* gw_dst_net_elm = nullptr;
NetPoint* prev_gw_src_net_elm = nullptr;
- get
GlobalR
oute(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
+ get
_global_r
oute(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
auto pos = route->link_list.begin();
for (auto const& link : e_route_as_to_as) {
route->link_list.insert(pos, link);
auto pos = route->link_list.begin();
for (auto const& link : e_route_as_to_as) {
route->link_list.insert(pos, link);
@@
-246,7
+246,7
@@
void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
for (auto const& link : e_route->link_list) {
route->link_list.insert(route->link_list.begin(), link);
if (lat)
for (auto const& link : e_route->link_list) {
route->link_list.insert(route->link_list.begin(), link);
if (lat)
- *lat += static_cast<
surf
::LinkImpl*>(link)->latency();
+ *lat += static_cast<
resource
::LinkImpl*>(link)->latency();
}
}
}
}
@@
-256,12
+256,12
@@
void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
}
if (not cached_)
}
if (not cached_)
- route
C
ache_.clear();
+ route
_c
ache_.clear();
}
DijkstraZone::~DijkstraZone()
{
}
DijkstraZone::~DijkstraZone()
{
- xbt_graph_free_graph(route
G
raph_, &graph_node_data_free, &graph_edge_data_free, nullptr);
+ xbt_graph_free_graph(route
_g
raph_, &graph_node_data_free, &graph_edge_data_free, nullptr);
}
/* Creation routing model functions */
}
/* Creation routing model functions */
@@
-270,52
+270,51
@@
DijkstraZone::DijkstraZone(NetZone* father, std::string name, bool cached) : Rou
{
}
{
}
-void DijkstraZone::addRoute(sg_platf_route_cbarg_t route)
+void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+ std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
{
{
- NetPoint* src = route->src;
- NetPoint* dst = route->dst;
- const char* srcName = src->getCname();
- const char* dstName = dst->getCname();
+ const char* srcName = src->get_cname();
+ const char* dstName = dst->get_cname();
- addRouteCheckParams(
route
);
+ addRouteCheckParams(
src, dst, gw_src, gw_dst, link_list, symmetrical
);
/* Create the topology graph */
/* Create the topology graph */
- if (not route
G
raph_)
- route
G
raph_ = xbt_graph_new_graph(1, nullptr);
+ if (not route
_g
raph_)
+ route
_g
raph_ = xbt_graph_new_graph(1, nullptr);
/* we don't check whether the route already exist, because the algorithm may find another path through some other
* nodes */
/* Add the route to the base */
/* we don't check whether the route already exist, because the algorithm may find another path through some other
* nodes */
/* Add the route to the base */
-
sg_platf_route_cbarg_t e_route = newExtendedRoute(hierarchy_, route
, 1);
+
RouteCreationArgs* e_route = newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical
, 1);
newRoute(src->id(), dst->id(), e_route);
// Symmetrical YES
newRoute(src->id(), dst->id(), e_route);
// Symmetrical YES
- if (
route->
symmetrical == true) {
+ if (symmetrical == true) {
- xbt_dynar_t nodes = xbt_graph_get_nodes(route
G
raph_);
+ xbt_dynar_t nodes = xbt_graph_get_nodes(route
_g
raph_);
xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src->id(), xbt_node_t);
xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst->id(), xbt_node_t);
xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src->id(), xbt_node_t);
xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst->id(), xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(route
G
raph_, node_e_v, node_s_v);
+ xbt_edge_t edge = xbt_graph_get_edge(route
_g
raph_, node_e_v, node_s_v);
- if (not
route->gw_dst || not route->gw_src)
{
+ if (not
gw_dst || not gw_src)
{
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName);
if (edge)
THROWF(arg_error, 0, "Route from %s to %s already exists", dstName, srcName);
} else {
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName);
if (edge)
THROWF(arg_error, 0, "Route from %s to %s already exists", dstName, srcName);
} else {
- XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->getCname(), srcName,
- route->gw_src->getCname());
+ XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, gw_dst->get_cname(), srcName, gw_src->get_cname());
if (edge)
if (edge)
- THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName,
route->gw_dst->getC
name(), srcName,
-
route->gw_src->getC
name());
+ THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName,
gw_dst->get_c
name(), srcName,
+
gw_src->get_c
name());
}
}
- if (
route->gw_dst && route->
gw_src) {
- NetPoint* gw_tmp =
route->
gw_src;
-
route->gw_src = route->
gw_dst;
-
route->gw_dst
= gw_tmp;
+ if (
gw_dst &&
gw_src) {
+ NetPoint* gw_tmp = gw_src;
+
gw_src =
gw_dst;
+
gw_dst
= gw_tmp;
}
}
- sg_platf_route_cbarg_t link_route_back = newExtendedRoute(hierarchy_, route, 0);
+ RouteCreationArgs* link_route_back =
+ newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 0);
newRoute(dst->id(), src->id(), link_route_back);
}
}
newRoute(dst->id(), src->id(), link_route_back);
}
}