Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move get_{bandwidth,latency}_factor to the NetworkModelFactors trait
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Oct 2022 22:23:27 +0000 (00:23 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Oct 2022 22:32:57 +0000 (00:32 +0200)
src/kernel/resource/NetworkModel.cpp
src/kernel/resource/NetworkModel.hpp
src/kernel/resource/NetworkModelFactors.cpp
src/kernel/resource/NetworkModelFactors.hpp

index 8341a7a..6029024 100644 (file)
@@ -20,30 +20,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_network, ker_resource, "Network resources, t
  *********/
 
 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");
-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 NetworkModel::get_latency_factor(double size)
-{
-  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 NetworkModel::get_bandwidth_factor(double size)
-{
-  if (not cfg_bandwidth_factor.is_initialized())
-    cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
-
-  return cfg_bandwidth_factor(size);
-}
 
 /** @brief Command-line option 'network/TCP-gamma' -- see @ref options_model_network_gamma */
 config::Flag<double> NetworkModel::cfg_tcp_gamma(
index 636387c..06ada68 100644 (file)
@@ -55,28 +55,6 @@ public:
    */
   virtual Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) = 0;
 
-  /**
-   * @brief Get the right multiplicative factor for the latency.
-   * @details Depending on the model, the effective latency when sending a message might be different from the
-   * theoretical latency of the link, in function of the message size. In order to account for this, this function gets
-   * this factor.
-   *
-   * @param size The size of the message.
-   * @return The latency factor.
-   */
-  virtual double get_latency_factor(double size = 0);
-
-  /**
-   * @brief Get the right multiplicative factor for the bandwidth.
-   * @details Depending on the model, the effective bandwidth when sending a message might be different from the
-   * theoretical bandwidth of the link, in function of the message size. In order to account for this, this function
-   * gets this factor.
-   *
-   * @param size The size of the message.
-   * @return The bandwidth factor.
-   */
-  virtual double get_bandwidth_factor(double size = 0);
-
   double next_occurring_event_full(double now) override;
 
   std::unique_ptr<StandardLinkImpl, StandardLinkImpl::Deleter> loopback_;
index 5037d46..52e8ba0 100644 (file)
@@ -14,7 +14,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
  *********/
 
 namespace simgrid::kernel::resource {
-#if 0
 static FactorSet cfg_latency_factor("network/latency-factor");
 static FactorSet cfg_bandwidth_factor("network/bandwidth-factor");
 
@@ -25,6 +24,7 @@ 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");
 
+#if 0
 double NetworkModelFactors::get_latency_factor()
 {
   xbt_assert(not lat_factor_cb_,
@@ -73,6 +73,21 @@ double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* s
 }
 #endif
 
+double NetworkModelFactors::get_latency_factor(double size)
+{
+  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)
+{
+  if (not cfg_bandwidth_factor.is_initialized())
+    cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
+
+  return cfg_bandwidth_factor(size);
+}
+
 void NetworkModelFactors::set_lat_factor_cb(const std::function<NetworkFactorCb>& cb)
 {
   if (not cb)
index 0a5e755..8dcb751 100644 (file)
@@ -15,9 +15,8 @@
 
 namespace simgrid::kernel::resource {
 
-/** @ingroup SURF_interface
- * @brief Network Model interface class
- */
+/** This Trait of NetworkModel is in charge of handling the network factors (bw and lat) */
+
 class XBT_PUBLIC NetworkModelFactors {
   using NetworkFactorCb = double(double size, const s4u::Host* src, const s4u::Host* dst,
                                  const std::vector<s4u::Link*>& links,
@@ -28,6 +27,28 @@ protected:
   std::function<NetworkFactorCb> bw_factor_cb_;
 
 public:
+  /**
+   * @brief Get the right multiplicative factor for the latency.
+   * @details Depending on the model, the effective latency when sending a message might be different from the
+   * theoretical latency of the link, in function of the message size. In order to account for this, this function gets
+   * this factor.
+   *
+   * @param size The size of the message.
+   * @return The latency factor.
+   */
+  double get_latency_factor(double size = 0);
+
+  /**
+   * @brief Get the right multiplicative factor for the bandwidth.
+   * @details Depending on the model, the effective bandwidth when sending a message might be different from the
+   * theoretical bandwidth of the link, in function of the message size. In order to account for this, this function
+   * gets this factor.
+   *
+   * @param size The size of the message.
+   * @return The bandwidth factor.
+   */
+  double get_bandwidth_factor(double size = 0);
+
   /**
    * @brief Callback to set the bandwidth and latency factors used in a communication
    *
@@ -51,4 +72,4 @@ public:
 
 } // namespace simgrid::kernel::resource
 
-#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELINTF_HPP */
+#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP */