+ FatTreeNode *source, *destination, *currentNode;
+
+ std::map<int, FatTreeNode*>::const_iterator tempIter;
+
+if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) return;
+
+ /* Let's find the source and the destination in our internal structure */
+ tempIter = this->computeNodes_.find(src->id());
+
+ // xbt_die -> assert
+ if (tempIter == this->computeNodes_.end()) {
+ xbt_die("Could not find the source %s [%d] in the fat tree", src->name(),
+ src->id());
+ }
+ source = tempIter->second;
+ tempIter = this->computeNodes_.find(dst->id());
+ if (tempIter == this->computeNodes_.end()) {
+ xbt_die("Could not find the destination %s [%d] in the fat tree",
+ dst->name(), dst->id());
+ }
+
+
+ destination = tempIter->second;
+
+ XBT_VERB("Get route and latency from '%s' [%d] to '%s' [%d] in a fat tree",
+ src->name(), src->id(), dst->name(), dst->id());
+
+ /* In case destination is the source, and there is a loopback, let's get
+ through it instead of going up to a switch*/
+ if(source->id == destination->id && this->has_loopback_) {
+ xbt_dynar_push_as(into->link_list, void*, source->loopback);
+ if(latency) {
+ *latency += source->loopback->getLatency();
+ }
+ return;
+ }
+
+ currentNode = source;
+
+ // up part
+ while (!isInSubTree(currentNode, destination)) {
+ int d, k; // as in d-mod-k
+ d = destination->position;
+
+ for (unsigned int i = 0 ; i < currentNode->level ; i++) {
+ d /= this->upperLevelNodesNumber_[i];
+ }
+ k = this->upperLevelNodesNumber_[currentNode->level];
+ d = d % k;
+ xbt_dynar_push_as(into->link_list, void*,currentNode->parents[d]->upLink);
+
+ if(latency) {
+ *latency += currentNode->parents[d]->upLink->getLatency();
+ }
+
+ if (this->has_limiter_) {
+ xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink);
+ }
+ currentNode = currentNode->parents[d]->upNode;
+ }
+
+ XBT_DEBUG("%d(%u,%u) is in the sub tree of %d(%u,%u).", destination->id,
+ destination->level, destination->position, currentNode->id,
+ currentNode->level, currentNode->position);
+
+ // Down part
+ while(currentNode != destination) {
+ for(unsigned int i = 0 ; i < currentNode->children.size() ; i++) {
+ if(i % this->lowerLevelNodesNumber_[currentNode->level - 1] ==
+ destination->label[currentNode->level - 1]) {
+ xbt_dynar_push_as(into->link_list, void*,currentNode->children[i]->downLink);
+ if(latency) {
+ *latency += currentNode->children[i]->downLink->getLatency();
+ }
+ currentNode = currentNode->children[i]->downNode;
+ if (this->has_limiter_) {
+ xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink);
+ }
+ XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id,
+ destination->level, destination->position, currentNode->id,
+ currentNode->level, currentNode->position);
+ }
+ }
+ }