Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Explicit cast to double (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 28 Apr 2022 17:16:20 +0000 (19:16 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 28 Apr 2022 17:16:20 +0000 (19:16 +0200)
src/kernel/resource/WifiLinkImpl.cpp
src/plugins/link_energy_wifi.cpp
src/smpi/internals/smpi_bench.cpp

index afa0c00..8de4c54 100644 (file)
@@ -66,7 +66,7 @@ size_t WifiLinkImpl::get_host_count() const
 void WifiLinkImpl::refresh_decay_bandwidths()
 {
   // Compute number of STAtion on the Access Point
-  size_t nSTA = get_host_count();
+  const auto nSTA_minus_1 = static_cast<double>(get_host_count() - 1);
 
   std::vector<Metric> new_bandwidths;
   for (auto const& bandwidth : bandwidths_) {
@@ -78,7 +78,7 @@ void WifiLinkImpl::refresh_decay_bandwidths()
     double N0     = max_bw - min_bw;
     double lambda = (-log(model_rate - min_bw) + log(N0)) / model_n_;
     // Since decay model start at 0 we should use (nSTA-1)
-    double new_peak = N0 * exp(-lambda * (nSTA - 1)) + min_bw;
+    double new_peak = N0 * exp(-lambda * nSTA_minus_1) + min_bw;
     new_bandwidths.push_back({new_peak, 1.0, nullptr});
   }
   decay_bandwidths_ = new_bandwidths;
index 76bc939..60d067b 100644 (file)
@@ -105,10 +105,11 @@ void LinkEnergyWifi::update_destroy()
   dur_idle_ += duration;
 
   // add IDLE energy usage, as well as beacons consumption since previous update
-  eDyn_ += duration * control_duration_ * wifi_link->get_host_count() * pRx_;
-  eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (wifi_link->get_host_count() + 1);
+  const auto host_count = static_cast<double>(wifi_link->get_host_count());
+  eDyn_ += duration * control_duration_ * host_count * pRx_;
+  eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (host_count + 1);
 
-  XBT_DEBUG("finish eStat_ += %f * %f * (%zu+1) | eStat = %f", duration, pIdle_, wifi_link->get_host_count(), eStat_);
+  XBT_DEBUG("finish eStat_ += %f * %f * (%f+1) | eStat = %f", duration, pIdle_, host_count, eStat_);
 }
 
 void LinkEnergyWifi::update()
@@ -177,7 +178,8 @@ void LinkEnergyWifi::update()
   XBT_DEBUG("durUsage: %f", durUsage);
 
   // beacons cost
-  eDyn_ += duration * control_duration_ * wifi_link->get_host_count() * pRx_;
+  const auto host_count = static_cast<double>(wifi_link->get_host_count());
+  eDyn_ += duration * control_duration_ * host_count * pRx_;
 
   /**
    * Same principle as ns3:
@@ -186,17 +188,17 @@ void LinkEnergyWifi::update()
    * P_{tot} = P_{dyn}+P_{stat}
    */
   if (link_->get_usage() != 0.0) {
-    eDyn_ += /*duration * */ durUsage * ((wifi_link->get_host_count() * pRx_) + pTx_);
-    eStat_ += (duration - durUsage) * pIdle_ * (wifi_link->get_host_count() + 1);
-    XBT_DEBUG("eDyn +=  %f * ((%zu * %f) + %f) | eDyn = %f (durusage =%f)", durUsage, wifi_link->get_host_count(), pRx_,
-              pTx_, eDyn_, durUsage);
+    eDyn_ += /*duration * */ durUsage * ((host_count * pRx_) + pTx_);
+    eStat_ += (duration - durUsage) * pIdle_ * (host_count + 1);
+    XBT_DEBUG("eDyn +=  %f * ((%f * %f) + %f) | eDyn = %f (durusage =%f)", durUsage, host_count, pRx_, pTx_, eDyn_,
+              durUsage);
     dur_TxRx_ += duration;
   } else {
     dur_idle_ += duration;
-    eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (wifi_link->get_host_count() + 1);
+    eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (host_count + 1);
   }
 
-  XBT_DEBUG("eStat_ += %f * %f * (%zu+1) | eStat = %f", duration, pIdle_, wifi_link->get_host_count(), eStat_);
+  XBT_DEBUG("eStat_ += %f * %f * (%f+1) | eStat = %f", duration, pIdle_, host_count, eStat_);
 }
 
 void LinkEnergyWifi::init_watts_range_list()
index 0960495..ebe1d34 100644 (file)
@@ -154,7 +154,7 @@ void smpi_bench_end()
     const papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& [counter, value] : counter_data) {
-      container->get_variable(counter)->set_event(simgrid::s4u::Engine::get_clock(), value);
+      container->get_variable(counter)->set_event(simgrid::s4u::Engine::get_clock(), static_cast<double>(value));
     }
   }
 #endif