Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[procrasticommit] less implicit casts and more consistency
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 2 Sep 2021 14:52:45 +0000 (16:52 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 2 Sep 2021 14:52:45 +0000 (16:52 +0200)
15 files changed:
examples/cpp/exec-dvfs/s4u-exec-dvfs.cpp
include/simgrid/host.h
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/Host.hpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/TorusZone.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_Host.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp

index d281d64..1f4e28b 100644 (file)
@@ -12,8 +12,8 @@ static int dvfs()
   double workload = 100E6;
   simgrid::s4u::Host* host = simgrid::s4u::this_actor::get_host();
 
-  int nb = host->get_pstate_count();
-  XBT_INFO("Count of Processor states=%d", nb);
+  unsigned long nb = host->get_pstate_count();
+  XBT_INFO("Count of Processor states=%lu", nb);
 
   XBT_INFO("Current power peak=%f", host->get_speed());
 
@@ -40,7 +40,7 @@ static int dvfs()
 
   // Verify that the default pstate is set to 0
   host = simgrid::s4u::Host::by_name_or_null("MyHost2");
-  XBT_INFO("Count of Processor states=%d", host->get_pstate_count());
+  XBT_INFO("Count of Processor states=%lu", host->get_pstate_count());
 
   XBT_INFO("Current power peak=%f", host->get_speed());
   return 0;
index 0a872a6..bb73630 100644 (file)
@@ -89,7 +89,7 @@ XBT_PUBLIC const char* sg_host_self_get_name();
  *
  * @param  host host to test
  */
-XBT_PUBLIC int sg_host_get_nb_pstates(const_sg_host_t host);
+XBT_PUBLIC unsigned long sg_host_get_nb_pstates(const_sg_host_t host);
 
 XBT_PUBLIC int sg_host_get_pstate(const_sg_host_t host);
 XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
index cb5f12c..6acc05b 100644 (file)
@@ -171,9 +171,8 @@ public:
   void seal();
   /** @brief Check if netpoint is a member of this NetZone or some of the childrens */
   bool is_component_recursive(const NetPoint* netpoint) const;
-  virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
-  virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
-                         kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+  virtual unsigned long add_component(NetPoint* elm); /* A host, a router or a netzone, whatever */
+  virtual void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                          const std::vector<s4u::LinkInRoute>& link_list, bool symmetrical);
   /** @brief Set parent of this Netzone */
   void set_parent(NetZoneImpl* parent);
@@ -191,11 +190,11 @@ public:
    * @param links Accumulator in which all traversed links should be pushed (caller must empty it)
    * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
    */
-  static void get_global_route(const routing::NetPoint* src, const routing::NetPoint* dst,
+  static void get_global_route(const NetPoint* src, const NetPoint* dst,
                                /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
 
   /** @brief Similar to get_global_route but get the NetZones traversed by route */
-  static void get_global_route_with_netzones(const routing::NetPoint* src, const routing::NetPoint* dst,
+  static void get_global_route_with_netzones(const NetPoint* src, const NetPoint* dst,
                                              /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
                                              std::unordered_set<NetZoneImpl*>& netzones);
 
@@ -203,9 +202,8 @@ public:
                          std::map<std::string, xbt_edge_t, std::less<>>* edges) = 0;
 
   /*** Called on each newly created regular route (not on bypass routes) */
-  static xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
-                          kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                          std::vector<kernel::resource::LinkImpl*> const& link_list)>
+  static xbt::signal<void(bool symmetrical, NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+                          std::vector<resource::LinkImpl*> const& link_list)>
       on_route_creation; // XBT_ATTRIB_DEPRECATED_v332 : should be an internal signal used by NS3.. if necessary,
                          // callback shouldn't use LinkImpl*
 
@@ -215,7 +213,7 @@ private:
   std::shared_ptr<resource::CpuModel> cpu_model_vm_;
   std::shared_ptr<resource::CpuModel> cpu_model_pm_;
   std::shared_ptr<resource::DiskModel> disk_model_;
-  std::shared_ptr<simgrid::surf::HostModel> host_model_;
+  std::shared_ptr<surf::HostModel> host_model_;
   /** @brief Perform sealing procedure for derived classes, if necessary */
   virtual void do_seal()
   { /* obviously nothing to do by default */
index 1be8e56..e45f2ae 100644 (file)
@@ -55,14 +55,14 @@ public:
    * There is really no limit on the hosts involved. In particular, the actor does not have to be on one of the involved
    * hosts.
    */
-  static CommPtr sendto_async(Host* from, Host* to, double simulated_size_in_bytes);
+  static CommPtr sendto_async(Host* from, Host* to, uint64_t simulated_size_in_bytes);
   /** Do a blocking communication between two arbitrary hosts.
    *
    * This starts a blocking communication right away, bypassing the mailbox and actors mechanism.
    * The calling actor is blocked until the end of the communication; there is really no limit on the hosts involved.
    * In particular, the actor does not have to be on one of the involved hosts. Enjoy the comfort of the simulator :)
    */
-  static void sendto(Host* from, Host* to, double simulated_size_in_bytes);
+  static void sendto(Host* from, Host* to, uint64_t simulated_size_in_bytes);
 
   static xbt::signal<void(Comm const&, bool is_sender)> on_start;
   static xbt::signal<void(Comm const&)> on_completion;
@@ -136,7 +136,7 @@ public:
    * :cpp:func:`simgrid::s4u::Comm::set_src_data_size`).
    * @endrst
    */
-  CommPtr set_payload_size(double bytes);
+  CommPtr set_payload_size(uint64_t bytes);
 
   /** Specify the data to send and its size (not to be mixed with set_payload_size())
    *
index 37921b3..5ca3ce3 100644 (file)
@@ -187,7 +187,7 @@ public:
    */
   double get_load() const;
 
-  int get_pstate_count() const;
+  unsigned long get_pstate_count() const;
   int get_pstate() const;
   double get_pstate_speed(int pstate_index) const;
   Host* set_pstate(int pstate_index);
index cd0cc7e..b803a4c 100644 (file)
@@ -195,7 +195,8 @@ NetPoint* NetZoneImpl::create_router(const std::string& name)
 
   return (new NetPoint(name, NetPoint::Type::Router))->set_englobing_zone(this);
 }
-int NetZoneImpl::add_component(NetPoint* elm)
+
+unsigned long NetZoneImpl::add_component(NetPoint* elm)
 {
   vertices_.push_back(elm);
   return vertices_.size() - 1; // The rank of the newly created object
index 1ef8955..f17a7d3 100644 (file)
@@ -115,7 +115,7 @@ void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route*
    * linkOffset describes the offset where the link we want to use is stored(+1 is added because each node has a link
    * from itself to itself, which can only be the case if src->m_id == dst->m_id -- see above for this special case)
    */
-  unsigned int linkOffset = (dsize + 1) * src->id();
+  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();
@@ -149,7 +149,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 %u", current_node,
+        XBT_DEBUG("torus_get_route_and_latency - current_node: %u, next_node: %u, linkOffset is %lu", current_node,
                   next_node, linkOffset);
         break;
       }
index 5becbc1..9ab9a25 100644 (file)
@@ -89,8 +89,8 @@ namespace dvfs {
 class Governor {
   simgrid::s4u::Host* const host_;
   double sampling_rate_;
-  int min_pstate = cfg_min_pstate; //< Never use a pstate less than this one
-  int max_pstate = cfg_max_pstate; //< Never use a pstate larger than this one
+  unsigned long min_pstate = cfg_min_pstate; //< Never use a pstate less than this one
+  unsigned long max_pstate = cfg_max_pstate; //< Never use a pstate larger than this one
 
 public:
   explicit Governor(simgrid::s4u::Host* ptr)
@@ -116,16 +116,15 @@ public:
     }
     const char* local_min_pstate_config = host_->get_property(cfg_min_pstate.get_name());
     if (local_min_pstate_config != nullptr) {
-      min_pstate = std::stoi(local_min_pstate_config);
+      min_pstate = std::stoul(local_min_pstate_config);
     }
 
     const char* local_max_pstate_config = host_->get_property(cfg_max_pstate.get_name());
     if (local_max_pstate_config != nullptr) {
-      max_pstate = std::stoi(local_max_pstate_config);
+      max_pstate = std::stoul(local_max_pstate_config);
     }
     xbt_assert(max_pstate <= host_->get_pstate_count() - 1, "Value for max_pstate too large!");
     xbt_assert(min_pstate <= max_pstate, "min_pstate is larger than max_pstate!");
-    xbt_assert(0 <= min_pstate, "min_pstate is negative!");
   }
 
   virtual void update()         = 0;
@@ -341,7 +340,7 @@ public:
     bool is_initialized         = rates[task_id][best_pstate] != 0;
     rates[task_id][best_pstate] = computed_flops / comp_timer;
     if (not is_initialized) {
-      for (int i = 1; i < get_host()->get_pstate_count(); i++) {
+      for (unsigned long i = 1; i < get_host()->get_pstate_count(); i++) {
         rates[task_id][i] = rates[task_id][0] * (get_host()->get_pstate_speed(i) / get_host()->get_speed());
       }
     }
index 81f1162..7917c2d 100644 (file)
@@ -349,8 +349,8 @@ void HostEnergy::init_watts_range_list()
   boost::split(all_power_values, all_power_values_str, boost::is_any_of(","));
   XBT_DEBUG("%s: power properties: %s", host_->get_cname(), all_power_values_str);
 
-  xbt_assert(all_power_values.size() == (unsigned)host_->get_pstate_count(),
-             "Invalid XML file. Found %zu energetic profiles for %d pstates", all_power_values.size(),
+  xbt_assert(all_power_values.size() == host_->get_pstate_count(),
+             "Invalid XML file. Found %zu energetic profiles for %lu pstates", all_power_values.size(),
              host_->get_pstate_count());
 
   int i = 0;
index 4818d15..9eadb22 100644 (file)
@@ -40,7 +40,7 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host
 
   // Create a VCPU for this VM
   std::vector<double> speeds;
-  for (int i = 0; i < physical_host->get_pstate_count(); i++)
+  for (unsigned long i = 0; i < physical_host->get_pstate_count(); i++)
     speeds.push_back(physical_host->get_pstate_speed(i));
 
   physical_host->get_netpoint()
index ca60e6f..a359f50 100644 (file)
@@ -151,7 +151,7 @@ CommPtr Comm::set_dst_data(void** buff, size_t size)
   dst_buff_size_ = size;
   return this;
 }
-CommPtr Comm::set_payload_size(double bytes)
+CommPtr Comm::set_payload_size(uint64_t bytes)
 {
   Activity::set_remaining(bytes);
   return this;
@@ -166,14 +166,14 @@ CommPtr Comm::sendto_init(Host* from, Host* to)
   return res;
 }
 
-CommPtr Comm::sendto_async(Host* from, Host* to, double simulated_size_in_bytes)
+CommPtr Comm::sendto_async(Host* from, Host* to, uint64_t simulated_size_in_bytes)
 {
   auto res = Comm::sendto_init(from, to)->set_payload_size(simulated_size_in_bytes);
   res->vetoable_start();
   return res;
 }
 
-void Comm::sendto(Host* from, Host* to, double simulated_size_in_bytes)
+void Comm::sendto(Host* from, Host* to, uint64_t simulated_size_in_bytes)
 {
   sendto_async(from, to, simulated_size_in_bytes)->wait();
 }
index fb079bf..fba8ef4 100644 (file)
@@ -126,7 +126,7 @@ bool Host::is_on() const
   return this->pimpl_cpu_->is_on();
 }
 
-int Host::get_pstate_count() const
+unsigned long Host::get_pstate_count() const
 {
   return this->pimpl_cpu_->get_pstate_count();
 }
@@ -538,7 +538,7 @@ double sg_host_get_available_speed(const_sg_host_t host)
  *
  *  See also @ref plugin_host_energy.
  */
-int sg_host_get_nb_pstates(const_sg_host_t host)
+unsigned long sg_host_get_nb_pstates(const_sg_host_t host)
 {
   return host->get_pstate_count();
 }
index a8b3440..82c24be 100644 (file)
@@ -99,7 +99,7 @@ public:
   /** @brief Get the peak processor speed (in flops/s), at the specified pstate */
   virtual double get_pstate_peak_speed(int pstate_index) const;
 
-  virtual int get_pstate_count() const { return speed_per_pstate_.size(); }
+  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);
index ec6191d..7df0d78 100644 (file)
@@ -31,7 +31,7 @@ CpuTiProfile::CpuTiProfile(const profile::Profile* profile)
 {
   double integral    = 0;
   double time        = 0;
-  unsigned nb_points = profile->get_event_list().size() + 1;
+  unsigned long nb_points = profile->get_event_list().size() + 1;
   time_points_.reserve(nb_points);
   integral_.reserve(nb_points);
   for (auto const& val : profile->get_event_list()) {
@@ -106,10 +106,10 @@ double CpuTiProfile::integrate_simple_point(double a) const
 {
   double integral = 0;
   double a_aux    = a;
-  int ind         = binary_search(time_points_, a);
+  long ind        = binary_search(time_points_, a);
   integral += integral_[ind];
 
-  XBT_DEBUG("a %f ind %d integral %f ind + 1 %f ind %f time +1 %f time %f", a, ind, integral, integral_[ind + 1],
+  XBT_DEBUG("a %f ind %ld integral %f ind + 1 %f ind %f time +1 %f time %f", a, ind, integral, integral_[ind + 1],
             integral_[ind], time_points_[ind + 1], time_points_[ind]);
   double_update(&a_aux, time_points_[ind], sg_maxmin_precision * sg_surf_precision);
   if (a_aux > 0)
@@ -187,7 +187,7 @@ double CpuTiTmgr::solve(double a, double amount) const
 double CpuTiProfile::solve_simple(double a, double amount) const
 {
   double integral_a = integrate_simple_point(a);
-  int ind           = binary_search(integral_, integral_a + amount);
+  long ind          = binary_search(integral_, integral_a + amount);
   double time       = time_points_[ind];
   time += (integral_a + amount - integral_[ind]) /
           ((integral_[ind + 1] - integral_[ind]) / (time_points_[ind + 1] - time_points_[ind]));
@@ -205,7 +205,7 @@ double CpuTiProfile::solve_simple(double a, double amount) const
 double CpuTiTmgr::get_power_scale(double a) const
 {
   double reduced_a                = a - floor(a / last_time_) * last_time_;
-  int point                       = CpuTiProfile::binary_search(profile_->time_points_, reduced_a);
+  long point                      = CpuTiProfile::binary_search(profile_->time_points_, reduced_a);
   kernel::profile::DatedValue val = speed_profile_->get_event_list().at(point);
   return val.value_;
 }
@@ -255,7 +255,7 @@ CpuTiTmgr::CpuTiTmgr(kernel::profile::Profile* speed_profile, double value) : sp
  * @param a        Value to search
  * @return Index of point
  */
-int CpuTiProfile::binary_search(const std::vector<double>& array, double a)
+long CpuTiProfile::binary_search(const std::vector<double>& array, double a)
 {
   if (array[0] > a)
     return 0;
index 9557b05..4d6cd17 100644 (file)
@@ -34,7 +34,7 @@ public:
 
   std::vector<double> time_points_;
   std::vector<double> integral_;
-  static int binary_search(const std::vector<double>& array, double a);
+  static long binary_search(const std::vector<double>& array, double a);
 };
 
 class CpuTiTmgr {