Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to disable the TCP windowing modeling by setting network/TCP-gamma to 0
[simgrid.git] / src / surf / network_cm02.cpp
index a0f4776..5cc26f4 100644 (file)
@@ -1,4 +1,4 @@
-/* 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. */
@@ -369,10 +369,16 @@ void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::H
 }
 
 void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
-                                                const std::vector<StandardLinkImpl*>& back_route)
+                                                const std::vector<StandardLinkImpl*>& back_route, bool streamed)
 {
   size_t constraints_per_variable = route.size();
   constraints_per_variable += back_route.size();
+  if (streamed) {
+    // setting the number of variable for a communication action involved in a I/O streaming operation
+    // requires to reserve some extra space for the constraints related to the source disk (global and read
+    // bandwidth) and destination disk (global and write bandwidth). We thus add 4 constraints.
+    constraints_per_variable += 4;
+  }
 
   if (action->latency_ > 0) {
     action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
@@ -391,16 +397,17 @@ void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const
   /* after setting the variable, update the bounds depending on user configuration */
   if (action->get_user_bound() < 0) {
     get_maxmin_system()->update_variable_bound(
-        action->get_variable(), (action->lat_current_ > 0) ? cfg_tcp_gamma / (2.0 * action->lat_current_) : -1.0);
+        action->get_variable(),
+        (action->lat_current_ > 0 && cfg_tcp_gamma > 0) ? cfg_tcp_gamma / (2.0 * action->lat_current_) : -1.0);
   } else {
     get_maxmin_system()->update_variable_bound(
-        action->get_variable(), (action->lat_current_ > 0)
+        action->get_variable(), (action->lat_current_ > 0 && cfg_tcp_gamma > 0)
                                     ? std::min(action->get_user_bound(), cfg_tcp_gamma / (2.0 * action->lat_current_))
                                     : action->get_user_bound());
   }
 }
 
-Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
+Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed)
 {
   double latency = 0.0;
   std::vector<StandardLinkImpl*> back_route;
@@ -426,7 +433,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   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);
+  comm_action_set_variable(action, route, back_route, streamed);
 
   /* expand maxmin system to consider this communication in bw constraint for each link in route and back_route */
   comm_action_expand_constraints(src, dst, action, route, back_route);
@@ -512,20 +519,21 @@ void NetworkCm02Link::set_latency(double value)
     auto* action = static_cast<NetworkCm02Action*>(var->get_id());
     action->lat_current_ += delta;
     action->sharing_penalty_ += delta;
-    if (action->get_user_bound() < 0)
+    if (action->get_user_bound() < 0 && NetworkModel::cfg_tcp_gamma > 0)
       get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), NetworkModel::cfg_tcp_gamma /
                                                                                           (2.0 * action->lat_current_));
-    else {
+    else if (NetworkModel::cfg_tcp_gamma > 0) {
       get_model()->get_maxmin_system()->update_variable_bound(
           action->get_variable(),
           std::min(action->get_user_bound(), NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)));
-
-      if (action->get_user_bound() < NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)) {
-        XBT_DEBUG("Flow is limited BYBANDWIDTH");
-      } else {
-        XBT_DEBUG("Flow is limited BYLATENCY, latency of flow is %f", action->lat_current_);
-      }
     }
+    if (NetworkModel::cfg_tcp_gamma == 0 ||
+        action->get_user_bound() < NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)) {
+      XBT_DEBUG("Flow is limited BYBANDWIDTH");
+    } else {
+      XBT_DEBUG("Flow is limited BYLATENCY, latency of flow is %f", action->lat_current_);
+    }
+
     if (not action->is_suspended())
       get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), action->sharing_penalty_);
   }