namespace kernel {
namespace routing {
-DragonflyZone::DragonflyZone(const std::string& name) : ClusterZone(name) {}
+DragonflyZone::DragonflyZone(const std::string& name) : ClusterBase(name) {}
DragonflyZone::Coords DragonflyZone::rankId_to_coords(int rankId) const
{
void DragonflyZone::set_link_characteristics(double bw, double lat, s4u::Link::SharingPolicy sharing_policy)
{
- ClusterZone::set_link_characteristics(bw, lat, sharing_policy);
+ ClusterBase::set_link_characteristics(bw, lat, sharing_policy);
if (sharing_policy == s4u::Link::SharingPolicy::SPLITDUPLEX)
num_links_per_link_ = 2;
}
}
/* Generate the cluster once every node is created */
-void DragonflyZone::do_seal()
+void DragonflyZone::build_upper_levels(const s4u::ClusterCallbacks& set_callbacks)
{
- if (num_nodes_per_blade_ == 0)
- return;
-
- generate_routers();
+ generate_routers(set_callbacks);
generate_links();
}
-void DragonflyZone::generate_routers()
+void DragonflyZone::generate_routers(const s4u::ClusterCallbacks& set_callbacks)
{
+ int id = 0;
+ /* get limiter for this router */
+ auto get_limiter = [this, &id, &set_callbacks](unsigned int i, unsigned int j,
+ unsigned int k) -> resource::LinkImpl* {
+ kernel::resource::LinkImpl* limiter = nullptr;
+ if (set_callbacks.limiter) {
+ id--;
+ const auto* s4u_link =
+ set_callbacks.limiter(get_iface(), {i, j, k, std::numeric_limits<unsigned int>::max()}, id);
+ if (s4u_link) {
+ limiter = s4u_link->get_impl();
+ }
+ }
+ return limiter;
+ };
+
routers_.reserve(num_groups_ * num_chassis_per_group_ * num_blades_per_chassis_);
- for (unsigned int i = 0; i < num_groups_; i++)
- for (unsigned int j = 0; j < num_chassis_per_group_; j++)
- for (unsigned int k = 0; k < num_blades_per_chassis_; k++)
- routers_.emplace_back(i, j, k);
+ for (unsigned int i = 0; i < num_groups_; i++) {
+ for (unsigned int j = 0; j < num_chassis_per_group_; j++) {
+ for (unsigned int k = 0; k < num_blades_per_chassis_; k++) {
+ routers_.emplace_back(i, j, k, get_limiter(i, j, k));
+ }
+ }
+ }
}
void DragonflyZone::generate_link(const std::string& id, int numlinks, resource::LinkImpl** linkup,
}
}
-void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency)
+void DragonflyZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* latency)
{
// Minimal routing version.
// TODO : non-minimal random one, and adaptive ?
targetCoords.chassis * num_blades_per_chassis_ + targetCoords.blade];
DragonflyRouter* currentRouter = myRouter;
+ if (has_limiter()) { // limiter for sender
+ route->link_list_.push_back(get_uplink_from(node_pos_with_loopback(src->id())));
+ }
+
// node->router local link
route->link_list_.push_back(myRouter->my_nodes_[myCoords.node * num_links_per_link_]);
if (latency)
*latency += myRouter->my_nodes_[myCoords.node * num_links_per_link_]->get_latency();
- if (has_limiter()) { // limiter for sender
- route->link_list_.push_back(get_uplink_from(node_pos_with_loopback(src->id())));
- }
-
if (targetRouter != myRouter) {
// are we on a different group ?
if (targetRouter->group_ != currentRouter->group_) {
// go to the router of our group connected to this one.
if (currentRouter->blade_ != targetCoords.group) {
+ if (currentRouter->limiter_)
+ route->link_list_.push_back(currentRouter->limiter_);
// go to the nth router in our chassis
route->link_list_.push_back(currentRouter->green_links_[targetCoords.group]);
if (latency)
if (currentRouter->chassis_ != 0) {
// go to the first chassis of our group
+ if (currentRouter->limiter_)
+ route->link_list_.push_back(currentRouter->limiter_);
route->link_list_.push_back(currentRouter->black_links_[0]);
if (latency)
*latency += currentRouter->black_links_[0]->get_latency();
// go to destination group - the only optical hop
route->link_list_.push_back(currentRouter->blue_link_);
+ if (currentRouter->limiter_)
+ route->link_list_.push_back(currentRouter->limiter_);
if (latency)
*latency += currentRouter->blue_link_->get_latency();
currentRouter =
// same group, but same blade ?
if (targetRouter->blade_ != currentRouter->blade_) {
+ if (currentRouter->limiter_)
+ route->link_list_.push_back(currentRouter->limiter_);
route->link_list_.push_back(currentRouter->green_links_[targetCoords.blade]);
if (latency)
*latency += currentRouter->green_links_[targetCoords.blade]->get_latency();
// same blade, but same chassis ?
if (targetRouter->chassis_ != currentRouter->chassis_) {
+ if (currentRouter->limiter_)
+ route->link_list_.push_back(currentRouter->limiter_);
route->link_list_.push_back(currentRouter->black_links_[targetCoords.chassis]);
if (latency)
*latency += currentRouter->black_links_[targetCoords.chassis]->get_latency();
}
}
- if (has_limiter()) { // limiter for receiver
- route->link_list_.push_back(get_downlink_to(node_pos_with_loopback(dst->id())));
- }
-
// router->node local link
+ if (targetRouter->limiter_)
+ route->link_list_.push_back(targetRouter->limiter_);
route->link_list_.push_back(
targetRouter->my_nodes_[targetCoords.node * num_links_per_link_ + num_links_per_link_ - 1]);
+
if (latency)
*latency +=
targetRouter->my_nodes_[targetCoords.node * num_links_per_link_ + num_links_per_link_ - 1]->get_latency();
+ if (has_limiter()) { // limiter for receiver
+ route->link_list_.push_back(get_downlink_to(node_pos_with_loopback(dst->id())));
+ }
+
// set gateways (if any)
route->gw_src_ = get_gateway(src->id());
route->gw_dst_ = get_gateway(dst->id());
Link* loopback;
zone->fill_leaf_from_cb(i, dimensions, set_callbacks, &netpoint, &loopback, &limiter);
}
+ zone->build_upper_levels(set_callbacks);
return zone->get_iface();
}