X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f21c3891971f5b45e2664c31a76ad526b076abfb..3dbeba193df2e406bd9eff5be73c8bce0db0185e:/src/surf/surf_routing_cluster_fat_tree.cpp diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index a1db45bbd2..2421ea5496 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -22,6 +22,9 @@ AsClusterFatTree::~AsClusterFatTree() { for (unsigned int i = 0 ; i < this->nodes.size() ; i++) { delete this->nodes[i]; } + for (unsigned int i = 0 ; i < this->links.size() ; i++) { + delete this->links[i]; + } } bool AsClusterFatTree::isInSubTree(FatTreeNode *root, FatTreeNode *node) { @@ -49,9 +52,12 @@ void AsClusterFatTree::getRouteAndLatency(RoutingEdgePtr src, sg_platf_route_cbarg_t into, double *latency) { FatTreeNode *source, *destination, *currentNode; - std::vector route; + std::map::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->getId()); // xbt_die -> assert @@ -63,14 +69,25 @@ void AsClusterFatTree::getRouteAndLatency(RoutingEdgePtr src, 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()); + dst->getName(), dst->getId()); } destination = tempIter->second; + XBT_VERB("Get route and latency from '%s' [%d] to '%s' [%d] in a fat tree", src->getName(), src->getId(), dst->getName(), dst->getId()); + /* 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->p_has_loopback) { + xbt_dynar_push_as(into->link_list, void*, source->loopback); + if(latency) { + *latency += source->loopback->getLatency(); + } + return; + } + currentNode = source; // up part @@ -83,41 +100,41 @@ void AsClusterFatTree::getRouteAndLatency(RoutingEdgePtr src, } k = this->upperLevelNodesNumber[currentNode->level]; d = d % k; - route.push_back(currentNode->parents[d]->upLink); + xbt_dynar_push_as(into->link_list, void*,currentNode->parents[d]->upLink); if(latency) { *latency += currentNode->parents[d]->upLink->getLatency(); } if (this->p_has_limiter) { - route.push_back(currentNode->limiterLink); + 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]) { - route.push_back(currentNode->children[i]->downLink); + 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->p_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); } } } - - for (unsigned int i = 0 ; i < route.size() ; i++) { - xbt_dynar_push_as(into->link_list, void*, route[i]); - } - } /* This function makes the assumption that parse_specific_arguments() and @@ -271,9 +288,6 @@ void AsClusterFatTree::generateSwitches() { } - // If we have to many compute nodes, we ditch them - - // We create the switches int k = 0; for (unsigned int i = 0 ; i < this->levels ; i++) { @@ -386,6 +400,9 @@ void AsClusterFatTree::addLink(FatTreeNode *parent, unsigned int parentPort, child->parents[childPort] = newLink; this->links.push_back(newLink); + + + } void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t @@ -399,7 +416,6 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t if (parameters.size() != 4){ surf_parse_error("Fat trees are defined by the levels number and 3 vectors" ", see the documentation for more informations"); - // Well, there's no doc, yet } // The first parts of topo_parameters should be the levels number