From c8fff2666abf04e486dc400ca026b788b47c74cb Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Mon, 6 Sep 2021 08:48:20 +0200 Subject: [PATCH] unsigned long-ing --- examples/cpp/energy-boot/s4u-energy-boot.cpp | 14 ++++++-------- .../cpp/engine-filtering/s4u-engine-filtering.cpp | 2 +- .../s4u-routing-get-clusters.cpp | 2 +- include/simgrid/kernel/routing/ClusterZone.hpp | 4 ++-- include/simgrid/kernel/routing/DragonflyZone.hpp | 8 ++++---- include/simgrid/s4u/Host.hpp | 2 +- src/kernel/routing/DragonflyZone.cpp | 4 ++-- src/kernel/routing/FatTreeZone.cpp | 6 +++--- src/kernel/routing/TorusZone.cpp | 14 +++++++------- src/s4u/s4u_Host.cpp | 2 +- 10 files changed, 28 insertions(+), 30 deletions(-) diff --git a/examples/cpp/energy-boot/s4u-energy-boot.cpp b/examples/cpp/energy-boot/s4u-energy-boot.cpp index 39f3179e3c..ac01774f8c 100644 --- a/examples/cpp/energy-boot/s4u-energy-boot.cpp +++ b/examples/cpp/energy-boot/s4u-energy-boot.cpp @@ -69,32 +69,30 @@ static void simulate_shutdown(simgrid::s4u::Host* host) host->turn_off(); } -static int monitor() +static void monitor() { simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1"); - XBT_INFO("Initial pstate: %d; Energy dissipated so far:%.0E J", host1->get_pstate(), + XBT_INFO("Initial pstate: %lu; Energy dissipated so far:%.0E J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); XBT_INFO("Sleep for 10 seconds"); simgrid::s4u::this_actor::sleep_for(10); - XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), + XBT_INFO("Done sleeping. Current pstate: %lu; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); simulate_shutdown(host1); - XBT_INFO("Host1 is now OFF. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), + XBT_INFO("Host1 is now OFF. Current pstate: %lu; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); XBT_INFO("Sleep for 10 seconds"); simgrid::s4u::this_actor::sleep_for(10); - XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), + XBT_INFO("Done sleeping. Current pstate: %lu; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); simulate_bootup(host1); - XBT_INFO("Host1 is now ON again. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), + XBT_INFO("Host1 is now ON again. Current pstate: %lu; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); - - return 0; } int main(int argc, char* argv[]) diff --git a/examples/cpp/engine-filtering/s4u-engine-filtering.cpp b/examples/cpp/engine-filtering/s4u-engine-filtering.cpp index ea905676fa..ac510a6802 100644 --- a/examples/cpp/engine-filtering/s4u-engine-filtering.cpp +++ b/examples/cpp/engine-filtering/s4u-engine-filtering.cpp @@ -36,7 +36,7 @@ public: * Then, it allows one to easily retrieve the hosts which frequency changed since the functor creation. */ class FrequencyChanged { - std::map host_list; + std::map host_list; public: explicit FrequencyChanged(const simgrid::s4u::Engine& e) diff --git a/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp b/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp index 660f1eb896..09f693de55 100644 --- a/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp +++ b/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) XBT_INFO("%s' dragonfly topology:", d->get_cname()); for (int i = 0; i < d->get_host_count(); i++) { const simgrid::kernel::routing::DragonflyZone::Coords coords = d->rankId_to_coords(i); - XBT_INFO(" %d: (%u, %u, %u, %u)", i, coords.group, coords.chassis, coords.blade, coords.node); + XBT_INFO(" %d: (%lu, %lu, %lu, %lu)", i, coords.group, coords.chassis, coords.blade, coords.node); } } diff --git a/include/simgrid/kernel/routing/ClusterZone.hpp b/include/simgrid/kernel/routing/ClusterZone.hpp index 1dd04ac7f4..8ed8894319 100644 --- a/include/simgrid/kernel/routing/ClusterZone.hpp +++ b/include/simgrid/kernel/routing/ClusterZone.hpp @@ -88,8 +88,8 @@ protected: class XBT_PRIVATE ClusterBase : public ClusterZone { /* We use a map instead of a std::vector here because that's a sparse vector. Some values may not exist */ /* The pair is {link_up, link_down} */ - std::unordered_map> private_links_; - std::unordered_map gateways_; //!< list of gateways for leafs (if they're netzones) + std::unordered_map> private_links_; + std::unordered_map gateways_; //!< list of gateways for leafs (if they're netzones) resource::LinkImpl* backbone_ = nullptr; NetPoint* router_ = nullptr; bool has_limiter_ = false; diff --git a/include/simgrid/kernel/routing/DragonflyZone.hpp b/include/simgrid/kernel/routing/DragonflyZone.hpp index 22604f07c9..7c3411be78 100644 --- a/include/simgrid/kernel/routing/DragonflyZone.hpp +++ b/include/simgrid/kernel/routing/DragonflyZone.hpp @@ -65,10 +65,10 @@ public: class XBT_PUBLIC DragonflyZone : public ClusterBase { public: struct Coords { - unsigned group; - unsigned chassis; - unsigned blade; - unsigned node; + unsigned long group; + unsigned long chassis; + unsigned long blade; + unsigned long node; }; explicit DragonflyZone(const std::string& name); diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index cd0797a68a..88d7d361ee 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -188,7 +188,7 @@ public: double get_load() const; unsigned long get_pstate_count() const; - int get_pstate() const; + unsigned long get_pstate() const; double get_pstate_speed(unsigned long pstate_index) const; Host* set_pstate(unsigned long pstate_index); Host* set_coordinates(const std::string& coords); diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 2512b4f016..d301c5ba37 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -296,9 +296,9 @@ void DragonflyZone::get_local_route(const NetPoint* src, const NetPoint* dst, Ro const auto myCoords = rankId_to_coords(src->id()); const auto targetCoords = rankId_to_coords(dst->id()); - XBT_DEBUG("src : %u group, %u chassis, %u blade, %u node", myCoords.group, myCoords.chassis, myCoords.blade, + XBT_DEBUG("src : %lu group, %lu chassis, %lu blade, %lu node", myCoords.group, myCoords.chassis, myCoords.blade, myCoords.node); - XBT_DEBUG("dst : %u group, %u chassis, %u blade, %u node", targetCoords.group, targetCoords.chassis, + XBT_DEBUG("dst : %lu group, %lu chassis, %lu blade, %lu node", targetCoords.group, targetCoords.chassis, targetCoords.blade, targetCoords.node); DragonflyRouter* myRouter = &routers_[myCoords.group * (num_chassis_per_group_ * num_blades_per_chassis_) + diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index ee430208fb..8f625132cc 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -248,7 +248,7 @@ void FatTreeZone::generate_switches(const s4u::ClusterCallbacks& set_callbacks) } /* get limiter for this router */ - auto get_limiter = [this, &set_callbacks](unsigned int i, unsigned int j, int id) -> resource::LinkImpl* { + auto get_limiter = [this, &set_callbacks](unsigned long i, unsigned long j, long id) -> resource::LinkImpl* { kernel::resource::LinkImpl* limiter = nullptr; if (set_callbacks.limiter) { const auto* s4u_link = set_callbacks.limiter(get_iface(), {i + 1, j}, id); @@ -260,8 +260,8 @@ void FatTreeZone::generate_switches(const s4u::ClusterCallbacks& set_callbacks) }; // Create the switches unsigned long k = 2 * nodes_.size(); - for (unsigned int i = 0; i < this->levels_; i++) { - for (unsigned int j = 0; j < this->nodes_by_level_[i + 1]; j++) { + for (unsigned long i = 0; i < this->levels_; i++) { + for (unsigned long j = 0; j < this->nodes_by_level_[i + 1]; j++) { k--; auto newNode = std::make_shared(k, i + 1, j, get_limiter(i, j, k), nullptr); XBT_DEBUG("We create the switch %d(%u,%u)", newNode->id, newNode->level, newNode->position); diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index ce370db168..f96b1ec991 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -30,9 +30,9 @@ void TorusZone::create_torus_links(unsigned long id, int rank, unsigned long pos dimensions_[j]; // which dimension are we currently in? // we need to iterate over all dimensions and create all links there // The other node the link connects - int neighbor_rank_id = ((rank / dim_product) % current_dimension == current_dimension - 1) - ? rank - (current_dimension - 1) * dim_product - : rank + dim_product; + unsigned long neighbor_rank_id = ((rank / dim_product) % current_dimension == current_dimension - 1) + ? rank - (current_dimension - 1) * dim_product + : rank + dim_product; // name of neighbor is not right for non contiguous cluster radicals (as id != rank in this case) std::string link_id = get_name() + "_link_from_" + std::to_string(id) + "_to_" + std::to_string(neighbor_rank_id); const s4u::Link* linkup; @@ -106,7 +106,7 @@ void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* std::vector targetCoords(dsize); unsigned int dim_size_product = 1; for (unsigned long i = 0; i < dsize; i++) { - unsigned cur_dim_size = dimensions_[i]; + unsigned long cur_dim_size = dimensions_[i]; myCoords[i] = (src->id() / dim_size_product) % cur_dim_size; targetCoords[i] = (dst->id() / dim_size_product) % cur_dim_size; dim_size_product *= cur_dim_size; @@ -119,12 +119,12 @@ void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* unsigned long linkOffset = (dsize + 1) * src->id(); bool use_lnk_up = false; // Is this link of the form "cur -> next" or "next -> cur"? false means: next -> cur - unsigned int current_node = src->id(); + unsigned long current_node = src->id(); while (current_node != dst->id()) { unsigned int next_node = 0; unsigned int dim_product = 1; // First, we will route in x-dimension for (unsigned j = 0; j < dsize; j++) { - const unsigned cur_dim = dimensions_[j]; + const unsigned long cur_dim = dimensions_[j]; // current_node/dim_product = position in current dimension if ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) { if ((targetCoords[j] > myCoords[j] && @@ -150,7 +150,7 @@ void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* linkOffset = node_pos_with_loopback_limiter(next_node) + j; use_lnk_up = false; } - XBT_DEBUG("torus_get_route_and_latency - current_node: %u, next_node: %u, linkOffset is %lu", current_node, + XBT_DEBUG("torus_get_route_and_latency - current_node: %lu, next_node: %u, linkOffset is %lu", current_node, next_node, linkOffset); break; } diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index f8be7d0ab6..e3f77fa63b 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -321,7 +321,7 @@ Host* Host::set_pstate(unsigned long pstate_index) } /** @brief Retrieve the pstate at which the host is currently running */ -int Host::get_pstate() const +unsigned long Host::get_pstate() const { return this->pimpl_cpu_->get_pstate(); } -- 2.20.1