From 7d195832dafde68afd749dd614e9a14d697bdb92 Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Sun, 5 Sep 2021 13:53:56 +0200 Subject: [PATCH] yet another bunch of int -> unsigned long --- .../s4u-clusters-multicpu.cpp | 4 +- .../simgrid/kernel/routing/ClusterZone.hpp | 8 +- .../simgrid/kernel/routing/DragonflyZone.hpp | 2 +- .../simgrid/kernel/routing/FatTreeZone.hpp | 2 +- include/simgrid/kernel/routing/FloydZone.hpp | 2 +- include/simgrid/kernel/routing/TorusZone.hpp | 2 +- include/simgrid/s4u/NetZone.hpp | 4 +- src/kernel/routing/ClusterZone.cpp | 12 +- src/kernel/routing/DragonflyZone.cpp | 5 +- src/kernel/routing/FatTreeZone.cpp | 2 +- src/kernel/routing/NetZone_test.hpp | 2 +- src/kernel/routing/TorusZone.cpp | 7 +- src/plugins/host_dvfs.cpp | 2 +- src/surf/cpu_interface.cpp | 16 +-- src/surf/cpu_interface.hpp | 8 +- src/surf/sg_platf.cpp | 14 ++- teshsuite/simdag/flatifier/flatifier.tesh | 112 +++++++++--------- 17 files changed, 103 insertions(+), 101 deletions(-) diff --git a/examples/cpp/clusters-multicpu/s4u-clusters-multicpu.cpp b/examples/cpp/clusters-multicpu/s4u-clusters-multicpu.cpp index ec90b026b5..18c1184fe4 100644 --- a/examples/cpp/clusters-multicpu/s4u-clusters-multicpu.cpp +++ b/examples/cpp/clusters-multicpu/s4u-clusters-multicpu.cpp @@ -89,7 +89,7 @@ public: * @return netpoint, gateway: the netpoint to the StarZone and CPU0 as gateway */ static std::pair -create_hostzone(const sg4::NetZone* zone, const std::vector& /*coord*/, int id) +create_hostzone(const sg4::NetZone* zone, const std::vector& /*coord*/, unsigned long id) { constexpr int num_cpus = 8; //!< Number of CPUs in the zone constexpr double speed = 1e9; //!< Speed of each CPU @@ -139,7 +139,7 @@ create_hostzone(const sg4::NetZone* zone, const std::vector& /*coo * @param id Internal identifier in the torus (for information) * @return Limiter link */ -static sg4::Link* create_limiter(sg4::NetZone* zone, const std::vector& /*coord*/, int id) +static sg4::Link* create_limiter(sg4::NetZone* zone, const std::vector& /*coord*/, unsigned long id) { return zone->create_link("limiter-" + std::to_string(id), 1e9)->seal(); } diff --git a/include/simgrid/kernel/routing/ClusterZone.hpp b/include/simgrid/kernel/routing/ClusterZone.hpp index 7944122757..1dd04ac7f4 100644 --- a/include/simgrid/kernel/routing/ClusterZone.hpp +++ b/include/simgrid/kernel/routing/ClusterZone.hpp @@ -119,11 +119,11 @@ protected: bool has_backbone() const { return backbone_ != nullptr; } void set_router(NetPoint* router) { router_ = router; } /** @brief Sets gateway for the leaf */ - void set_gateway(unsigned int position, NetPoint* gateway); + void set_gateway(unsigned long position, NetPoint* gateway); /** @brief Gets gateway for the leaf or nullptr */ - NetPoint* get_gateway(unsigned int position); - void add_private_link_at(unsigned int position, std::pair link); - bool private_link_exists_at(unsigned int position) const + NetPoint* get_gateway(unsigned long position); + void add_private_link_at(unsigned long position, std::pair link); + bool private_link_exists_at(unsigned long position) const { return private_links_.find(position) != private_links_.end(); } diff --git a/include/simgrid/kernel/routing/DragonflyZone.hpp b/include/simgrid/kernel/routing/DragonflyZone.hpp index e54343556d..22604f07c9 100644 --- a/include/simgrid/kernel/routing/DragonflyZone.hpp +++ b/include/simgrid/kernel/routing/DragonflyZone.hpp @@ -91,7 +91,7 @@ public: void build_upper_levels(const s4u::ClusterCallbacks& set_callbacks); /** @brief Set the characteristics of links inside the Dragonfly zone */ void set_link_characteristics(double bw, double lat, s4u::Link::SharingPolicy sharing_policy) override; - Coords rankId_to_coords(int rank_id) const; + Coords rankId_to_coords(unsigned long rank_id) const; XBT_ATTRIB_DEPRECATED_v330("Please use rankId_to_coords(int)") void rankId_to_coords(int rank_id, unsigned int coords[4]) const; diff --git a/include/simgrid/kernel/routing/FatTreeZone.hpp b/include/simgrid/kernel/routing/FatTreeZone.hpp index 33cb0788fc..a493182be1 100644 --- a/include/simgrid/kernel/routing/FatTreeZone.hpp +++ b/include/simgrid/kernel/routing/FatTreeZone.hpp @@ -115,7 +115,7 @@ class XBT_PRIVATE FatTreeZone : public ClusterBase { std::vector num_parents_per_node_; // number of parents by node std::vector num_port_lower_level_; // ports between each level l and l-1 - std::map> compute_nodes_; + std::map> compute_nodes_; std::vector> nodes_; std::vector> links_; std::vector nodes_by_level_; diff --git a/include/simgrid/kernel/routing/FloydZone.hpp b/include/simgrid/kernel/routing/FloydZone.hpp index 83539d1b00..46f12088c2 100644 --- a/include/simgrid/kernel/routing/FloydZone.hpp +++ b/include/simgrid/kernel/routing/FloydZone.hpp @@ -23,7 +23,7 @@ namespace routing { */ class XBT_PRIVATE FloydZone : public RoutedZone { /* vars to compute the Floyd algorithm. */ - std::vector> predecessor_table_; + std::vector> predecessor_table_; std::vector> cost_table_; std::vector>> link_table_; diff --git a/include/simgrid/kernel/routing/TorusZone.hpp b/include/simgrid/kernel/routing/TorusZone.hpp index 2335bbfe72..36fb7bdc10 100644 --- a/include/simgrid/kernel/routing/TorusZone.hpp +++ b/include/simgrid/kernel/routing/TorusZone.hpp @@ -24,7 +24,7 @@ class XBT_PRIVATE TorusZone : public ClusterBase { public: explicit TorusZone(const std::string& name) : ClusterBase(name){}; - void create_torus_links(int id, int rank, unsigned long position); + void create_torus_links(unsigned long id, int rank, unsigned long position); void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override; void set_topology(const std::vector& dimensions); diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 76491671b8..6c0f3e7306 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -211,7 +211,7 @@ struct ClusterCallbacks { * @return pair: returns a pair of netpoint and gateway. */ using ClusterNetPointCb = std::pair( - NetZone* zone, const std::vector& coord, int id); + NetZone* zone, const std::vector& coord, unsigned long id); /** * @brief Callback used to set the links for some leaf of the cluster (Torus, FatTree, etc) * @@ -227,7 +227,7 @@ struct ClusterCallbacks { * @param id: Internal identifier of the element * @return Pointer to the Link */ - using ClusterLinkCb = Link*(NetZone* zone, const std::vector& coord, int id); + using ClusterLinkCb = Link*(NetZone* zone, const std::vector& coord, unsigned long id); std::function netpoint; std::function loopback = {}; diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index 6cb3575468..84052939e9 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -40,19 +40,19 @@ void ClusterBase::set_link_characteristics(double bw, double lat, s4u::Link::Sha link_lat_ = lat; } -void ClusterBase::add_private_link_at(unsigned int position, std::pair link) +void ClusterBase::add_private_link_at(unsigned long position, std::pair link) { private_links_.insert({position, link}); } -void ClusterBase::set_gateway(unsigned int position, NetPoint* gateway) +void ClusterBase::set_gateway(unsigned long position, NetPoint* gateway) { xbt_assert(not gateway || not gateway->is_netzone(), "ClusterBase: gateway cannot be another netzone %s", gateway->get_cname()); gateways_[position] = gateway; } -NetPoint* ClusterBase::get_gateway(unsigned int position) +NetPoint* ClusterBase::get_gateway(unsigned long position) { NetPoint* res = nullptr; auto it = gateways_.find(position); @@ -73,13 +73,13 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector dims_array(dimensions.size()); + auto index_to_dims = [&dimensions](unsigned long index) { + std::vector dims_array(dimensions.size()); for (auto i = static_cast(dimensions.size() - 1); i >= 0; --i) { if (index <= 0) { break; } - unsigned int value = index % dimensions[i]; + unsigned long value = index % dimensions[i]; dims_array[i] = value; index = (index / dimensions[i]); } diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 8e674525bd..2512b4f016 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -20,7 +20,7 @@ namespace routing { DragonflyZone::DragonflyZone(const std::string& name) : ClusterBase(name) {} -DragonflyZone::Coords DragonflyZone::rankId_to_coords(int rankId) const +DragonflyZone::Coords DragonflyZone::rankId_to_coords(unsigned long rankId) const { // coords : group, chassis, blade, node Coords coords; @@ -150,7 +150,7 @@ void DragonflyZone::build_upper_levels(const s4u::ClusterCallbacks& set_callback void DragonflyZone::generate_routers(const s4u::ClusterCallbacks& set_callbacks) { - int id = 0; + unsigned long id = 2 * num_groups_ * num_chassis_per_group_ * num_blades_per_chassis_ * num_nodes_per_blade_; /* get limiter for this router */ auto get_limiter = [this, &id, &set_callbacks](unsigned int i, unsigned int j, unsigned int k) -> resource::LinkImpl* { @@ -432,7 +432,6 @@ NetZone* create_dragonfly_zone(const std::string& name, const NetZone* parent, c zone->fill_leaf_from_cb(i, dimensions, set_callbacks, &netpoint, &loopback, &limiter); } zone->build_upper_levels(set_callbacks); - return zone->get_iface(); } } // namespace s4u diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index 8642501116..ee430208fb 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -259,7 +259,7 @@ void FatTreeZone::generate_switches(const s4u::ClusterCallbacks& set_callbacks) return limiter; }; // Create the switches - int k = 0; + 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++) { k--; diff --git a/src/kernel/routing/NetZone_test.hpp b/src/kernel/routing/NetZone_test.hpp index 18500258ee..e0a047aefc 100644 --- a/src/kernel/routing/NetZone_test.hpp +++ b/src/kernel/routing/NetZone_test.hpp @@ -13,7 +13,7 @@ // Callback function common to several routing unit tests struct CreateHost { std::pair - operator()(simgrid::s4u::NetZone* zone, const std::vector& /*coord*/, int id) const + operator()(simgrid::s4u::NetZone* zone, const std::vector& /*coord*/, unsigned long id) const { const simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal(); return std::make_pair(host->get_netpoint(), nullptr); diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index ca8c430ad0..ce370db168 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -20,14 +20,15 @@ namespace simgrid { namespace kernel { namespace routing { -void TorusZone::create_torus_links(int id, int rank, unsigned long position) +void TorusZone::create_torus_links(unsigned long id, int rank, unsigned long position) { /* Create all links that exist in the torus. Each rank creates @a dimensions-1 links */ int dim_product = 1; // Needed to calculate the next neighbor_id for (unsigned long j = 0; j < dimensions_.size(); j++) { - int current_dimension = dimensions_[j]; // which dimension are we currently in? - // we need to iterate over all dimensions and create all links there + unsigned long current_dimension = + 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 diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index 85ed693c7b..bb830cf074 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -205,7 +205,7 @@ public: */ // Load is now < freq_up_threshold; exclude pstate 0 (the fastest) // because pstate 0 can only be selected if load > freq_up_threshold_ - unsigned long new_pstate = static_cast(get_max_pstate() - load * (get_max_pstate() + 1)); + auto new_pstate = get_max_pstate() - static_cast(load) * (get_max_pstate() + 1); if (new_pstate < get_min_pstate()) new_pstate = get_min_pstate(); get_host()->set_pstate(new_pstate); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index f6eeaa0f76..df62d8a3ab 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -65,12 +65,13 @@ void CpuImpl::reset_vcpu(CpuImpl* that) this->speed_per_pstate_.assign(that->speed_per_pstate_.begin(), that->speed_per_pstate_.end()); } -CpuImpl* CpuImpl::set_pstate(int pstate_index) +CpuImpl* CpuImpl::set_pstate(unsigned long pstate_index) { - xbt_assert(pstate_index <= static_cast(speed_per_pstate_.size()), - "Invalid parameters for CPU %s (pstate %d > length of pstates %d). Please fix your platform file, or your " - "call to change the pstate.", - get_cname(), pstate_index, static_cast(speed_per_pstate_.size())); + xbt_assert( + pstate_index <= speed_per_pstate_.size(), + "Invalid parameters for CPU %s (pstate %lu > length of pstates %lu). Please fix your platform file, or your " + "call to change the pstate.", + get_cname(), pstate_index, speed_per_pstate_.size()); double new_peak_speed = speed_per_pstate_[pstate_index]; pstate_ = pstate_index; @@ -89,10 +90,9 @@ CpuImpl* CpuImpl::set_pstate_speed(const std::vector& speed_per_state) return this; } -double CpuImpl::get_pstate_peak_speed(int pstate_index) const +double CpuImpl::get_pstate_peak_speed(unsigned long pstate_index) const { - xbt_assert((pstate_index <= static_cast(speed_per_pstate_.size())), - "Invalid parameters (pstate index out of bounds)"); + xbt_assert((pstate_index <= speed_per_pstate_.size()), "Invalid parameters (pstate index out of bounds)"); return speed_per_pstate_[pstate_index]; } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 82c24bee11..8f63dd419a 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -53,7 +53,7 @@ class XBT_PUBLIC CpuImpl : public Resource_T { s4u::Host* piface_; int core_count_ = 1; - int pstate_ = 0; /*< Current pstate (index in the speed_per_pstate_)*/ + unsigned long pstate_ = 0; /*< Current pstate (index in the speed_per_pstate_)*/ std::vector speed_per_pstate_; /*< List of supported CPU capacities (pstate related). Not 'const' because VCPU get modified on migration */ s4u::Host::SharingPolicy sharing_policy_ = s4u::Host::SharingPolicy::LINEAR; @@ -97,12 +97,12 @@ public: virtual double get_speed_ratio() { return speed_.scale; } /** @brief Get the peak processor speed (in flops/s), at the specified pstate */ - virtual double get_pstate_peak_speed(int pstate_index) const; + virtual double get_pstate_peak_speed(unsigned long pstate_index) const; virtual unsigned long get_pstate_count() const { return speed_per_pstate_.size(); } - virtual int get_pstate() const { return pstate_; } - virtual CpuImpl* set_pstate(int pstate_index); + virtual unsigned long get_pstate() const { return pstate_; } + virtual CpuImpl* set_pstate(unsigned long pstate_index); /*< @brief Setup the profile file with availability events (peak speed changes due to external load). * Profile must contain relative values (ratio between 0 and 1) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 5810642ee6..48b2c0129c 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -151,10 +151,10 @@ void sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk) /** @brief Auxiliary function to create hosts */ static std::pair sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs* cluster, simgrid::s4u::NetZone* zone, - const std::vector& /*coord*/, int id) + const std::vector& /*coord*/, unsigned long id) { xbt_assert(static_cast(id) < cluster->radicals.size(), - "Zone(%s): error when creating host number %d in the zone. Insufficient number of radicals available " + "Zone(%s): error when creating host number %lu in the zone. Insufficient number of radicals available " "(total = %zu). Check the 'radical' parameter in XML", cluster->id.c_str(), id, cluster->radicals.size()); @@ -170,11 +170,12 @@ sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs /** @brief Auxiliary function to create loopback links */ static simgrid::s4u::Link* sg_platf_cluster_create_loopback(const simgrid::kernel::routing::ClusterCreationArgs* cluster, - simgrid::s4u::NetZone* zone, const std::vector& /*coord*/, int id) + simgrid::s4u::NetZone* zone, const std::vector& /*coord*/, + unsigned long id) { xbt_assert(static_cast(id) < cluster->radicals.size(), - "Zone(%s): error when creating loopback for host number %d in the zone. Insufficient number of radicals " - "available " + "Zone(%s): error when creating loopback for host number %lu in the zone. Insufficient number of " + "radicals available " "(total = %zu). Check the 'radical' parameter in XML", cluster->id.c_str(), id, cluster->radicals.size()); @@ -191,7 +192,8 @@ sg_platf_cluster_create_loopback(const simgrid::kernel::routing::ClusterCreation /** @brief Auxiliary function to create limiter links */ static simgrid::s4u::Link* sg_platf_cluster_create_limiter(const simgrid::kernel::routing::ClusterCreationArgs* cluster, simgrid::s4u::NetZone* zone, - const std::vector& /*coord*/, int id) + const std::vector& /*coord*/, + unsigned long id) { std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id) + "_limiter"; XBT_DEBUG("Cluster: creating limiter link=%s bw=%f", link_id.c_str(), cluster->limiter_link); diff --git a/teshsuite/simdag/flatifier/flatifier.tesh b/teshsuite/simdag/flatifier/flatifier.tesh index 8935cba2da..80a1f7a87e 100644 --- a/teshsuite/simdag/flatifier/flatifier.tesh +++ b/teshsuite/simdag/flatifier/flatifier.tesh @@ -1226,10 +1226,6 @@ $ ${bindir:=.}/flatifier ../platforms/cluster_dragonfly_noncontiguous_rad.xml "- > > > -> -> -> -> > > > @@ -1238,6 +1234,10 @@ $ ${bindir:=.}/flatifier ../platforms/cluster_dragonfly_noncontiguous_rad.xml "- > > > +> +> +> +> > > > @@ -1254,46 +1254,46 @@ $ ${bindir:=.}/flatifier ../platforms/cluster_dragonfly_noncontiguous_rad.xml "- > > > -> +> > > -> +> > > -> +> > > -> +> > > > > > -> +> > > -> +> > > -> +> > > -> +> > > > > > -> +> > > -> +> > > -> +> > > -> +> > > > @@ -1311,10 +1311,6 @@ $ ${bindir:=.}/flatifier ../platforms/cluster_fat_tree_noncontiguous_rad.xml "-- > > > -> -> -> -> > > > @@ -1323,74 +1319,78 @@ $ ${bindir:=.}/flatifier ../platforms/cluster_fat_tree_noncontiguous_rad.xml "-- > > > -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> +> > > > > -> +> > > -> +> > > -> +> > > -> +> > > > > > -> +> > > -> +> > > -> +> > > -> +> > > > > > -> +> > > -> +> > > -> +> > > -> +> > > > -- 2.20.1