+ FatTreeNode *source, *destination, *currentNode;
+ std::vector<NetworkLink*> route;
+ std::map<int, FatTreeNode*>::const_iterator tempIter;
+ tempIter = this->computeNodes.find(src->getId());
+
+ // xbt_die -> assert
+ if (tempIter == this->computeNodes.end()) {
+ xbt_die("Could not find the source %s [%d] in the fat tree", src->getName(), src->getId());
+ }
+ source = tempIter->second;
+ tempIter = this->computeNodes.find(dst->getId());
+ if (tempIter == this->computeNodes.end()) {
+ xbt_die("Could not find the destination %s [%d] in the fat tree", src->getName(), src->getId());
+ }
+
+
+ destination = tempIter->second;
+ XBT_DEBUG("%d %d", src->getId(), source->id);
+ XBT_DEBUG("Get route and latency from '%s' [%d] to '%s' [%d] in a fat tree",
+ src->getName(), src->getId(), dst->getName(), dst->getId());
+
+ 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;
+ route.push_back(currentNode->parents[d]->upLink);
+
+ if(latency) {
+ *latency += currentNode->parents[d]->upLink->getLatency();
+ }
+ 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]) {
+ route.push_back(currentNode->children[i]->downLink);
+ if(latency) {
+ *latency += currentNode->children[i]->downLink->getLatency();
+ }
+ currentNode = currentNode->children[i]->downNode;
+ XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level, destination->position, currentNode->id, currentNode->level, currentNode->position);
+ }
+ }
+ }