if ((src->id() == dst->id()) && hasLoopback_) {
xbt_assert(not src->isRouter(), "Routing from a cluster private router to itself is meaningless");
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
route->link_list->push_back(info.first);
if (lat)
*lat += info.first->latency();
if (not src->isRouter()) { // No private link for the private router
if (hasLimiter_) { // limiter for sender
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
- privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
route->link_list->push_back(info.first);
}
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
- privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0));
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(src->id()));
if (info.first) { // link up
route->link_list->push_back(info.first);
if (lat)
if (not dst->isRouter()) { // No specific link for router
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
- privateLinks_.at(dst->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0));
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(dst->id()));
if (info.second) { // link down
route->link_list->push_back(info.second);
if (lat)
*lat += info.second->latency();
}
if (hasLimiter_) { // limiter for receiver
- info = privateLinks_.at(dst->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
+ info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
route->link_list->push_back(info.first);
}
}
-/* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2017. 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. */
/* The pair is {linkUp, linkDown} */
std::unordered_map<unsigned int, std::pair<surf::LinkImpl*, surf::LinkImpl*>> privateLinks_;
+ int nodePosition(int id) { return id * linkCountPerNode_; }
+ int nodePositionWithLoopback(int id) { return nodePosition(id) + (hasLoopback_ ? 1 : 0); }
+ int nodePositionWithLimiter(int id) { return nodePositionWithLoopback(id) + (hasLimiter_ ? 1 : 0); }
+
surf::LinkImpl* backbone_ = nullptr;
void* loopback_ = nullptr;
NetPoint* router_ = nullptr;
dst->id());
if ((src->id() == dst->id()) && hasLoopback_) {
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
route->link_list->push_back(info.first);
if (latency)
*latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
if (hasLimiter_) { // limiter for sender
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
- privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
route->link_list->push_back(info.first);
}
}
if (hasLimiter_) { // limiter for receiver
- std::pair<surf::LinkImpl*, surf::LinkImpl*> info =
- privateLinks_.at(dst->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
+ std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
route->link_list->push_back(info.first);
}
linkDown = simgrid::surf::LinkImpl::byName(tmp_link);
auto as_cluster = static_cast<ClusterZone*>(current_as);
- as_cluster->privateLinks_.insert({rankId * as_cluster->linkCountPerNode_, {linkUp, linkDown}});
+ as_cluster->privateLinks_.insert({as_cluster->nodePosition(rankId), {linkUp, linkDown}});
}
//add a limiter link (shared link to account for maximal bandwidth of the node)
sg_platf_new_link(&link);
linkDown = simgrid::surf::LinkImpl::byName(tmp_link);
linkUp = linkDown;
- current_as->privateLinks_.insert(
- {rankId * current_as->linkCountPerNode_ + (current_as->hasLoopback_ ? 1 : 0), {linkUp, linkDown}});
+ current_as->privateLinks_.insert({current_as->nodePositionWithLoopback(rankId), {linkUp, linkDown}});
}
//call the cluster function that adds the others links
if (cluster->topology == SURF_CLUSTER_FAT_TREE) {
static_cast<FatTreeZone*>(current_as)->addProcessingNode(i);
} else {
- current_as->create_links_for_node(cluster, i, rankId, rankId * current_as->linkCountPerNode_ +
- (current_as->hasLoopback_ ? 1 : 0) +
- (current_as->hasLimiter_ ? 1 : 0));
+ current_as->create_links_for_node(cluster, i, rankId, current_as->nodePositionWithLimiter(rankId));
}
rankId++;
}