Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill src/include
[simgrid.git] / src / kernel / resource / NetworkModelFactors.cpp
index 6641350..3e9f8cf 100644 (file)
@@ -1,11 +1,10 @@
-/* Copyright (c) 2013-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-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 "src/kernel/resource/NetworkModelFactors.hpp"
-#include "simgrid/sg_config.hpp"
-#include "src/kernel/resource/FactorSet.hpp"
+#include "src/simgrid/sg_config.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
 
@@ -14,9 +13,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
  *********/
 
 namespace simgrid::kernel::resource {
-static FactorSet cfg_latency_factor("network/latency-factor");
-static FactorSet cfg_bandwidth_factor("network/bandwidth-factor");
-
 config::Flag<std::string> cfg_latency_factor_str(
     "network/latency-factor", std::initializer_list<const char*>{"smpi/lat-factor"},
     "Correction factor to apply to the provided latency (default value overridden by network model)", "1.0");
@@ -24,7 +20,10 @@ static config::Flag<std::string> cfg_bandwidth_factor_str(
     "network/bandwidth-factor", std::initializer_list<const char*>{"smpi/bw-factor"},
     "Correction factor to apply to the provided bandwidth (default value overridden by network model)", "1.0");
 
-double NetworkModelFactors::get_bandwidth_factor()
+FactorSet NetworkModelFactors::cfg_latency_factor("network/latency-factor");
+FactorSet NetworkModelFactors::cfg_bandwidth_factor("network/bandwidth-factor");
+
+double NetworkModelFactors::get_bandwidth_factor() const
 {
   xbt_assert(not bw_factor_cb_,
              "Cannot access the global bandwidth factor since a callback is used. Please go for the advanced API.");
@@ -35,7 +34,7 @@ double NetworkModelFactors::get_bandwidth_factor()
   return cfg_bandwidth_factor(0);
 }
 
-double NetworkModelFactors::get_latency_factor()
+double NetworkModelFactors::get_latency_factor() const
 {
   xbt_assert(not lat_factor_cb_,
              "Cannot access the global latency factor since a callback is used. Please go for the advanced API.");
@@ -46,10 +45,9 @@ double NetworkModelFactors::get_latency_factor()
   return cfg_latency_factor(0);
 }
 
-#if 0
 double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
                                                const std::vector<s4u::Link*>& links,
-                                               const std::unordered_set<s4u::NetZone*>& netzones)
+                                               const std::unordered_set<s4u::NetZone*>& netzones) const
 {
   if (lat_factor_cb_)
     return lat_factor_cb_(size, src, dst, links, netzones);
@@ -62,33 +60,7 @@ double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src
 
 double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
                                                  const std::vector<s4u::Link*>& links,
-                                                 const std::unordered_set<s4u::NetZone*>& netzones)
-{
-  if (bw_factor_cb_)
-    return bw_factor_cb_(size, src, dst, links, netzones);
-
-  if (not cfg_bandwidth_factor.is_initialized())
-    cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
-
-  return cfg_bandwidth_factor(size);
-}
-#endif
-
-double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
-                                               const std::vector<s4u::Link*>& links,
-                                               const std::unordered_set<s4u::NetZone*>& netzones)
-{
-  if (lat_factor_cb_)
-    return lat_factor_cb_(size, src, dst, links, netzones);
-
-  if (not cfg_latency_factor.is_initialized()) // lazy initiaization to avoid initialization fiasco
-    cfg_latency_factor.parse(cfg_latency_factor_str.get());
-
-  return cfg_latency_factor(size);
-}
-double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
-                                                 const std::vector<s4u::Link*>& links,
-                                                 const std::unordered_set<s4u::NetZone*>& netzones)
+                                                 const std::unordered_set<s4u::NetZone*>& netzones) const
 {
   if (bw_factor_cb_)
     return bw_factor_cb_(size, src, dst, links, netzones);