Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Single get_bandwidth_constraint function.
authorBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 20 May 2021 15:07:52 +0000 (17:07 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Mon, 24 May 2021 07:39:55 +0000 (09:39 +0200)
Unify behavior of get_bandwidth_constraint function.

Note: Possible side-effect in SMPI communications with user defined
rate. Do not scale the user rate with bandwidth factor.

No impact on tests

src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_smpi.cpp
src/surf/network_smpi.hpp

index cb1e7cf..e293749 100644 (file)
@@ -336,18 +336,18 @@ void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::H
   } else {
     bw_factor = get_bandwidth_factor(size);
   }
-  /* get mininum bandwidth among links in the route and multiply by correct factor */
-  const auto& min_bw = std::min_element(
-      route.begin(), route.end(), [](const auto& a, const auto& b) { return a->get_bandwidth() < b->get_bandwidth(); });
-
-  double bandwidth_bound = min_bw == route.end() ? -1.0 : bw_factor * (*min_bw)->get_bandwidth();
-
-  if (bw_constraint_cb_) {
-    action->set_user_bound(
-        bw_constraint_cb_(action->get_user_bound(), bandwidth_bound, size, src, dst, s4u_route, s4u_netzones));
-  } else {
-    action->set_user_bound(get_bandwidth_constraint(action->get_user_bound(), bandwidth_bound, size));
+  /* get mininum bandwidth among links in the route and multiply by correct factor
+   * ignore wi-fi links, they're not considered for bw_factors */
+  double bandwidth_bound = -1.0;
+  for (const auto* l : route) {
+    if (l->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI)
+      continue;
+    if (bandwidth_bound == -1.0 || l->get_bandwidth() < bandwidth_bound)
+      bandwidth_bound = l->get_bandwidth();
   }
+  bandwidth_bound *= bw_factor;
+
+  action->set_user_bound(get_bandwidth_constraint(action->get_user_bound(), bandwidth_bound, size));
 
   action->lat_current_ = action->latency_;
   if (lat_factor_cb_) {
index 2cb1cdf..d4e4eb0 100644 (file)
@@ -52,6 +52,11 @@ double NetworkModel::next_occurring_event_full(double now)
   return minRes;
 }
 
+double NetworkModel::get_bandwidth_constraint(double rate, double bound, double size)
+{
+  return rate < 0 ? bound : std::min(bound, rate);
+}
+
 /************
  * Resource *
  ************/
index 3861316..88f9351 100644 (file)
@@ -94,7 +94,7 @@ public:
    * @param size The size of the message.
    * @return The new bandwidth.
    */
-  virtual double get_bandwidth_constraint(double rate, double /*bound*/, double /*size*/) { return rate; }
+  double get_bandwidth_constraint(double rate, double bound, double size);
 
   double next_occurring_event_full(double now) override;
 
index 4c9adb6..6dd0e42 100644 (file)
@@ -96,11 +96,6 @@ double NetworkSmpiModel::get_latency_factor(double size)
 
   return current;
 }
-
-double NetworkSmpiModel::get_bandwidth_constraint(double rate, double bound, double size)
-{
-  return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size));
-}
 } // namespace resource
 } // namespace kernel
 } // namespace simgrid
index ea69e4a..dff3a6d 100644 (file)
@@ -21,7 +21,6 @@ public:
 
   double get_latency_factor(double size) override;
   double get_bandwidth_factor(double size) override;
-  double get_bandwidth_constraint(double rate, double bound, double size) override;
 
 protected:
   virtual void check_lat_factor_cb() override;