X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/040d8fa855d2b6ac9884f68108a09b935570be21..b2852b7c61948f495d7437ffaa7fd9aced12849c:/src/kernel/routing/ClusterZone.cpp diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index 4a51f60936..fa82dd48d0 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -1,21 +1,19 @@ -/* Copyright (c) 2009-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "simgrid/s4u/Host.hpp" #include "simgrid/kernel/routing/ClusterZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" -#include "simgrid/kernel/routing/RoutedZone.hpp" #include "src/kernel/resource/StandardLinkImpl.hpp" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_routing, "Kernel Cluster Routing"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_platform, "Kernel Cluster Routing"); /* This routing is specifically setup to represent clusters, aka homogeneous sets of machines * Note that a router is created, easing the interconnection with the rest of the world. */ -namespace simgrid { -namespace kernel { -namespace routing { +namespace simgrid::kernel::routing { void ClusterBase::set_loopback() { @@ -43,7 +41,7 @@ void ClusterBase::set_link_characteristics(double bw, double lat, s4u::Link::Sha void ClusterBase::add_private_link_at(unsigned long position, std::pair link) { - private_links_.insert({position, link}); + private_links_.try_emplace(position, link); } void ClusterBase::set_gateway(unsigned long position, NetPoint* gateway) @@ -55,12 +53,8 @@ void ClusterBase::set_gateway(unsigned long position, NetPoint* gateway) NetPoint* ClusterBase::get_gateway(unsigned long position) { - NetPoint* res = nullptr; - auto it = gateways_.find(position); - if (it != gateways_.end()) { - res = it->second; - } - return res; + auto it = gateways_.find(position); + return it == gateways_.end() ? nullptr : it->second; } void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector& dimensions, @@ -77,9 +71,8 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector dims_array(dimensions.size()); for (auto i = static_cast(dimensions.size() - 1); i >= 0; --i) { - if (index <= 0) { + if (index == 0) break; - } unsigned long value = index % dimensions[i]; dims_array[i] = value; index = (index / dimensions[i]); @@ -90,7 +83,17 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vectorget_netpoint(); + gw = netzone->get_gateway(); + } else { + s4u::Host* host = set_callbacks.host(get_iface(), dims, position); + netpoint = host->get_netpoint(); + } + xbt_assert(netpoint, "set_netpoint(elem=%lu): Invalid netpoint (nullptr)", position); if (netpoint->is_netzone()) { xbt_assert(gw && not gw->is_netzone(), @@ -120,6 +123,4 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector