X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c1139d8e995d20f3afebc6cb69c66c155348dbdd..6157f90cc9d3cce63b341338c15e91af8ccd6347:/src/kernel/routing/DragonflyZone.cpp diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 3ad8df8a71..9e23f6951a 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -31,15 +31,15 @@ DragonflyZone::~DragonflyZone() } } -void DragonflyZone::rankId_to_coords(int rankId, unsigned int (*coords)[4]) +void DragonflyZone::rankId_to_coords(int rankId, unsigned int coords[4]) { // coords : group, chassis, blade, node - (*coords)[0] = rankId / (num_chassis_per_group_ * num_blades_per_chassis_ * num_nodes_per_blade_); - rankId = rankId % (num_chassis_per_group_ * num_blades_per_chassis_ * num_nodes_per_blade_); - (*coords)[1] = rankId / (num_blades_per_chassis_ * num_nodes_per_blade_); - rankId = rankId % (num_blades_per_chassis_ * num_nodes_per_blade_); - (*coords)[2] = rankId / num_nodes_per_blade_; - (*coords)[3] = rankId % num_nodes_per_blade_; + coords[0] = rankId / (num_chassis_per_group_ * num_blades_per_chassis_ * num_nodes_per_blade_); + rankId = rankId % (num_chassis_per_group_ * num_blades_per_chassis_ * num_nodes_per_blade_); + coords[1] = rankId / (num_blades_per_chassis_ * num_nodes_per_blade_); + rankId = rankId % (num_blades_per_chassis_ * num_nodes_per_blade_); + coords[2] = rankId / num_nodes_per_blade_; + coords[3] = rankId % num_nodes_per_blade_; } void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster) @@ -113,10 +113,11 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster) throw std::invalid_argument(std::string("Last parameter is not the amount of nodes per blade:") + parameters[3]); } - if (cluster->sharing_policy == SURF_LINK_SPLITDUPLEX) + this->sharing_policy_ = cluster->sharing_policy; + if (cluster->sharing_policy == s4u::Link::SharingPolicy::SPLITDUPLEX) this->num_links_per_link_ = 2; - - this->cluster_ = cluster; + this->bw_ = cluster->bw; + this->lat_ = cluster->lat; } /* Generate the cluster once every node is created */ @@ -158,23 +159,24 @@ void DragonflyZone::generateRouters() } } -void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown) +void DragonflyZone::createLink(const std::string& id, int numlinks, resource::LinkImpl** linkup, + resource::LinkImpl** linkdown) { *linkup = nullptr; *linkdown = nullptr; LinkCreationArgs linkTemplate; - linkTemplate.bandwidth = this->cluster_->bw * numlinks; - linkTemplate.latency = this->cluster_->lat; - linkTemplate.policy = this->cluster_->sharing_policy; // sthg to do with that ? + linkTemplate.bandwidth = this->bw_ * numlinks; + linkTemplate.latency = this->lat_; + linkTemplate.policy = this->sharing_policy_; linkTemplate.id = id; sg_platf_new_link(&linkTemplate); XBT_DEBUG("Generating link %s", id.c_str()); - surf::LinkImpl* link; - if (this->cluster_->sharing_policy == SURF_LINK_SPLITDUPLEX) { - *linkup = surf::LinkImpl::byName(linkTemplate.id + "_UP"); // check link? - *linkdown = surf::LinkImpl::byName(linkTemplate.id + "_DOWN"); // check link ? + resource::LinkImpl* link; + if (this->sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) { + *linkup = resource::LinkImpl::byName(linkTemplate.id + "_UP"); // check link? + *linkdown = resource::LinkImpl::byName(linkTemplate.id + "_DOWN"); // check link ? } else { - link = surf::LinkImpl::byName(linkTemplate.id); + link = resource::LinkImpl::byName(linkTemplate.id); *linkup = link; *linkdown = link; } @@ -183,17 +185,17 @@ void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkIm void DragonflyZone::generateLinks() { static int uniqueId = 0; - surf::LinkImpl* linkup; - surf::LinkImpl* linkdown; + resource::LinkImpl* linkup; + resource::LinkImpl* linkdown; unsigned int numRouters = this->num_groups_ * this->num_chassis_per_group_ * this->num_blades_per_chassis_; // Links from routers to their local nodes. for (unsigned int i = 0; i < numRouters; i++) { // allocate structures - this->routers_[i]->my_nodes_ = new surf::LinkImpl*[num_links_per_link_ * this->num_nodes_per_blade_]; - this->routers_[i]->green_links_ = new surf::LinkImpl*[this->num_blades_per_chassis_]; - this->routers_[i]->black_links_ = new surf::LinkImpl*[this->num_chassis_per_group_]; + this->routers_[i]->my_nodes_ = new resource::LinkImpl*[num_links_per_link_ * this->num_nodes_per_blade_]; + this->routers_[i]->green_links_ = new resource::LinkImpl*[this->num_blades_per_chassis_]; + this->routers_[i]->black_links_ = new resource::LinkImpl*[this->num_chassis_per_group_]; for (unsigned int j = 0; j < num_links_per_link_ * this->num_nodes_per_blade_; j += num_links_per_link_) { std::string id = "local_link_from_router_" + std::to_string(i) + "_to_node_" + @@ -201,7 +203,7 @@ void DragonflyZone::generateLinks() this->createLink(id, 1, &linkup, &linkdown); this->routers_[i]->my_nodes_[j] = linkup; - if (this->cluster_->sharing_policy == SURF_LINK_SPLITDUPLEX) + if (this->sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) this->routers_[i]->my_nodes_[j + 1] = linkdown; uniqueId++; @@ -249,8 +251,8 @@ void DragonflyZone::generateLinks() for (unsigned int j = i + 1; j < this->num_groups_; j++) { unsigned int routernumi = i * num_blades_per_chassis_ * num_chassis_per_group_ + j; unsigned int routernumj = j * num_blades_per_chassis_ * num_chassis_per_group_ + i; - this->routers_[routernumi]->blue_links_ = new surf::LinkImpl*; - this->routers_[routernumj]->blue_links_ = new surf::LinkImpl*; + this->routers_[routernumi]->blue_links_ = new resource::LinkImpl*; + this->routers_[routernumj]->blue_links_ = new resource::LinkImpl*; std::string id = "blue_link_between_group_"+ std::to_string(i) +"_and_" + std::to_string(j) +"_routers_" + std::to_string(routernumi) + "_and_" + std::to_string(routernumj) + "_" + std::to_string(uniqueId); this->createLink(id, this->num_links_blue_, &linkup, &linkdown); @@ -262,18 +264,19 @@ void DragonflyZone::generateLinks() } } -void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* latency) +void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* latency) { // Minimal routing version. // TODO : non-minimal random one, and adaptive ? - if (dst->isRouter() || src->isRouter()) + if (dst->is_router() || src->is_router()) return; - XBT_VERB("dragonfly getLocalRoute from '%s'[%u] to '%s'[%u]", src->getCname(), src->id(), dst->getCname(), dst->id()); + XBT_VERB("dragonfly getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), + dst->id()); if ((src->id() == dst->id()) && has_loopback_) { - std::pair info = private_links_.at(nodePosition(src->id())); + std::pair info = private_links_.at(node_pos(src->id())); route->link_list.push_back(info.first); if (latency) @@ -282,9 +285,9 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArg } unsigned int myCoords[4]; - rankId_to_coords(src->id(), &myCoords); + rankId_to_coords(src->id(), myCoords); unsigned int targetCoords[4]; - rankId_to_coords(dst->id(), &targetCoords); + rankId_to_coords(dst->id(), targetCoords); XBT_DEBUG("src : %u group, %u chassis, %u blade, %u node", myCoords[0], myCoords[1], myCoords[2], myCoords[3]); XBT_DEBUG("dst : %u group, %u chassis, %u blade, %u node", targetCoords[0], targetCoords[1], targetCoords[2], targetCoords[3]); @@ -301,7 +304,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArg *latency += myRouter->my_nodes_[myCoords[3] * num_links_per_link_]->latency(); if (has_limiter_) { // limiter for sender - std::pair info = private_links_.at(nodePositionWithLoopback(src->id())); + std::pair info = private_links_.at(node_pos_with_loopback(src->id())); route->link_list.push_back(info.first); } @@ -351,7 +354,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArg } if (has_limiter_) { // limiter for receiver - std::pair info = private_links_.at(nodePositionWithLoopback(dst->id())); + std::pair info = private_links_.at(node_pos_with_loopback(dst->id())); route->link_list.push_back(info.first); }