-/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2018. 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. */
-#include "src/kernel/routing/TorusZone.hpp"
-#include "src/kernel/routing/NetPoint.hpp"
+#include "simgrid/kernel/routing/TorusZone.hpp"
+#include "simgrid/kernel/routing/NetPoint.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/xml/platf_private.hpp"
+
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <string>
{
}
-void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, int position)
+void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position)
{
/* Create all links that exist in the torus. Each rank creates @a dimensions-1 links */
int dim_product = 1; // Needed to calculate the next neighbor_id
sg_platf_new_link(&link);
surf::LinkImpl* linkUp;
surf::LinkImpl* linkDown;
- if (link.policy == SURF_LINK_FULLDUPLEX) {
+ if (link.policy == SURF_LINK_SPLITDUPLEX) {
std::string tmp_link = link_id + "_UP";
linkUp = surf::LinkImpl::byName(tmp_link);
tmp_link = link_id + "_DOWN";
linkDown = linkUp;
}
/*
- * Add the link to its appropriate position;
- * note that position rankId*(xbt_dynar_length(dimensions)+has_loopback?+has_limiter?)
+ * Add the link to its appropriate position.
+ * Note that position rankId*(xbt_dynar_length(dimensions)+has_loopback?+has_limiter?)
* holds the link "rankId->rankId"
*/
- privateLinks_.insert({position + j, {linkUp, linkDown}});
+ private_links_.insert({position + j, {linkUp, linkDown}});
dim_product *= current_dimension;
}
rank++;
for (auto const& group : dimensions)
dimensions_.push_back(surf_parse_get_int(group));
- linkCountPerNode_ = dimensions_.size();
+ num_links_per_node_ = dimensions_.size();
}
}
-void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat)
+void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
{
- XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->name().c_str(), src->id(), dst->name().c_str(),
- dst->id());
+ XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
- if (dst->isRouter() || src->isRouter())
+ if (dst->is_router() || src->is_router())
return;
- if (src->id() == dst->id() && hasLoopback_) {
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
+ if (src->id() == dst->id() && has_loopback_) {
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = private_links_.at(src->id() * num_links_per_node_);
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
return;
next_node = (current_node + dim_product);
// HERE: We use *CURRENT* node for calculation (as opposed to next_node)
- nodeOffset = current_node * (linkCountPerNode_);
- linkOffset = nodeOffset + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0) + j;
+ nodeOffset = current_node * (num_links_per_node_);
+ linkOffset = nodeOffset + (has_loopback_ ? 1 : 0) + (has_limiter_ ? 1 : 0) + j;
use_lnk_up = true;
assert(linkOffset >= 0);
} else { // Route to the left
next_node = (current_node - dim_product);
// HERE: We use *next* node for calculation (as opposed to current_node!)
- nodeOffset = next_node * (linkCountPerNode_);
- linkOffset = nodeOffset + j + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0);
+ nodeOffset = next_node * (num_links_per_node_);
+ linkOffset = nodeOffset + j + (has_loopback_ ? 1 : 0) + (has_limiter_ ? 1 : 0);
use_lnk_up = false;
assert(linkOffset >= 0);
std::pair<surf::LinkImpl*, surf::LinkImpl*> info;
- if (hasLimiter_) { // limiter for sender
- info = privateLinks_.at(nodeOffset + hasLoopback_);
- route->link_list->push_back(info.first);
+ if (has_limiter_) { // limiter for sender
+ info = private_links_.at(nodeOffset + (has_loopback_ ? 1 : 0));
+ route->link_list.push_back(info.first);
}
- info = privateLinks_.at(linkOffset);
+ info = private_links_.at(linkOffset);
if (use_lnk_up == false) {
- route->link_list->push_back(info.second);
+ route->link_list.push_back(info.second);
if (lat)
*lat += info.second->latency();
} else {
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
}