Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Minor simplification in CM02::communicate
authorBruno Donassolo <bruno.donassolo@inria.fr>
Wed, 26 May 2021 10:17:33 +0000 (12:17 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Wed, 26 May 2021 10:17:33 +0000 (12:17 +0200)
Don't need a function in NetworkModel for an "if" used only in CM02

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

index dc4afd6..8e1c76d 100644 (file)
@@ -320,7 +320,8 @@ bool NetworkCm02Model::comm_get_route_info(const s4u::Host* src, const s4u::Host
 
 void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size,
                                               NetworkCm02Action* action, const std::vector<LinkImpl*>& route,
-                                              const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones)
+                                              const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones,
+                                              double rate)
 {
   std::vector<s4u::Link*> s4u_route;
   std::unordered_set<s4u::NetZone*> s4u_netzones;
@@ -348,7 +349,11 @@ void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::H
   }
   bandwidth_bound *= bw_factor;
 
-  action->set_user_bound(get_bandwidth_constraint(action->get_user_bound(), bandwidth_bound, size));
+  /* the bandwidth is determined by the minimum between flow and user's defined rate */
+  if (rate >= 0 && rate < bandwidth_bound)
+    bandwidth_bound = rate;
+
+  action->set_user_bound(bandwidth_bound);
 
   action->lat_current_ = action->latency_;
   if (lat_factor_cb_) {
@@ -404,7 +409,6 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   NetworkCm02Action* action = comm_action_create(src, dst, size, route, failed);
   action->sharing_penalty_  = latency;
   action->latency_          = latency;
-  action->set_user_bound(rate);
 
   if (sg_weight_S_parameter > 0) {
     action->sharing_penalty_ =
@@ -414,7 +418,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   }
 
   /* setting bandwidth and latency bounds considering route and configured bw/lat factors */
-  comm_action_set_bounds(src, dst, size, action, route, netzones);
+  comm_action_set_bounds(src, dst, size, action, route, netzones, rate);
 
   /* creating the maxmin variable associated to this action */
   comm_action_set_variable(action, route, back_route);
index 390e3b5..172a267 100644 (file)
@@ -44,7 +44,7 @@ class NetworkCm02Model : public NetworkModel {
   /** @brief Set communication bounds for latency and bandwidth */
   void comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size, NetworkCm02Action* action,
                               const std::vector<LinkImpl*>& route,
-                              const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones);
+                              const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones, double rate);
   /** @brief Create maxmin variable in communication action */
   void comm_action_set_variable(NetworkCm02Action* action, const std::vector<LinkImpl*>& route,
                                 const std::vector<LinkImpl*>& back_route);
index 69e392a..2cb1cdf 100644 (file)
@@ -52,11 +52,6 @@ double NetworkModel::next_occurring_event_full(double now)
   return minRes;
 }
 
-double NetworkModel::get_bandwidth_constraint(double rate, double bound, double /* size */) const
-{
-  return rate < 0 ? bound : std::min(bound, rate);
-}
-
 /************
  * Resource *
  ************/
index 8c643c7..debc9a0 100644 (file)
@@ -85,17 +85,6 @@ public:
    */
   virtual double get_bandwidth_factor(double /* size*/) { return sg_bandwidth_factor; }
 
-  /**
-   * @brief Get definitive bandwidth.
-   * @details It gives the minimum bandwidth between the one that would occur if no limitation was enforced, and the
-   * one arbitrary limited.
-   * @param rate The desired maximum bandwidth.
-   * @param bound The bandwidth with only the network taken into account.
-   * @param size The size of the message.
-   * @return The new bandwidth.
-   */
-  double get_bandwidth_constraint(double rate, double bound, double size) const;
-
   double next_occurring_event_full(double now) override;
 
   void set_lat_factor_cb(const std::function<NetworkFactorCb>& cb) override { THROW_UNIMPLEMENTED; }