Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make cmd-line option "network/TCP-gamma" neat and clean
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 4 Apr 2018 15:52:35 +0000 (17:52 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 4 Apr 2018 16:26:42 +0000 (18:26 +0200)
include/simgrid/forward.h
include/xbt/config.hpp
src/simgrid/sg_config.cpp
src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/ptask_L07.cpp
src/surf/surf_interface.hpp

index d940b36..fa46962 100644 (file)
@@ -14,6 +14,9 @@
 #include <boost/intrusive_ptr.hpp>
 
 namespace simgrid {
+namespace config {
+template <class T> class Flag;
+}
 namespace kernel {
 class EngineImpl;
 namespace context {
index 1f46590..9df266c 100644 (file)
@@ -227,6 +227,12 @@ public:
     simgrid::config::bindFlag(value_, name, desc);
   }
 
+  /** Constructor taking an array of aliases as name */
+  Flag(std::initializer_list<const char*> names, const char* desc, T value) : value_(value)
+  {
+    simgrid::config::bindFlag(value_, names, desc);
+  }
+
   /* A constructor accepting a callback that will be passed the parameter.
    * It can either return a boolean (informing whether the parameter is valid), or returning void.
    */
index 3fe0c43..49cbfcc 100644 (file)
@@ -314,11 +314,6 @@ void sg_config_init(int *argc, char **argv)
   describe_model(description, descsize, surf_host_model_description, "model", "The model to use for the host");
   xbt_cfg_register_string("host/model", "default", &_sg_cfg_cb__host_model, description);
 
-  sg_tcp_gamma = 4194304.0;
-  simgrid::config::bindFlag(sg_tcp_gamma, {"network/TCP-gamma", "network/TCP_gamma"},
-                            "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; "
-                            "Use the last given value, which is the max window size)");
-
   simgrid::config::bindFlag(sg_surf_precision, "surf/precision",
                             "Numerical precision used when updating simulation times (in seconds)");
 
index 1a65f04..3970dcc 100644 (file)
@@ -17,7 +17,6 @@ double sg_latency_factor = 1.0; /* default value; can be set by model or from co
 double sg_bandwidth_factor = 1.0;       /* default value; can be set by model or from command line */
 double sg_weight_S_parameter = 0.0;     /* default value; can be set by model or from command line */
 
-double sg_tcp_gamma = 0.0;
 int sg_network_crosstraffic = 0;
 
 /************************************************************************/
@@ -310,11 +309,11 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos
 
   if (action->rate_ < 0) {
     get_maxmin_system()->update_variable_bound(
-        action->get_variable(), (action->lat_current_ > 0) ? sg_tcp_gamma / (2.0 * action->lat_current_) : -1.0);
+        action->get_variable(), (action->lat_current_ > 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)
-                                    ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_))
+                                    ? std::min(action->rate_, cfg_tcp_gamma / (2.0 * action->lat_current_))
                                     : action->rate_);
   }
 
@@ -434,13 +433,13 @@ void NetworkCm02Link::setLatency(double value)
     action->lat_current_ += delta;
     action->weight_ += delta;
     if (action->rate_ < 0)
-      get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(),
-                                                              sg_tcp_gamma / (2.0 * action->lat_current_));
+      get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), NetworkModel::cfg_tcp_gamma /
+                                                                                          (2.0 * action->lat_current_));
     else {
       get_model()->get_maxmin_system()->update_variable_bound(
-          action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_)));
+          action->get_variable(), std::min(action->rate_, NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)));
 
-      if (action->rate_ < sg_tcp_gamma / (2.0 * action->lat_current_)) {
+      if (action->rate_ < NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)) {
         XBT_INFO("Flow is limited BYBANDWIDTH");
       } else {
         XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->lat_current_);
index 480a1a5..ac8dcb2 100644 (file)
@@ -66,6 +66,13 @@ simgrid::surf::NetworkModel *surf_network_model = nullptr;
 namespace simgrid {
   namespace surf {
 
+  /** Value of the command-line option 'network/TCP-gamma' -- see \ref options_model_network_gamma */
+  simgrid::config::Flag<double> NetworkModel::cfg_tcp_gamma(
+      {"network/TCP-gamma", "network/TCP_gamma"},
+      "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; "
+      "Use the last given value, which is the max window size)",
+      4194304.0);
+
   NetworkModel::~NetworkModel() = default;
 
     double NetworkModel::latencyFactor(double /*size*/) {
index 3cf8c35..822602a 100644 (file)
@@ -33,10 +33,9 @@ namespace surf {
  */
 class NetworkModel : public kernel::resource::Model {
 public:
-  /** @brief Constructor */
-  explicit NetworkModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
+  static simgrid::config::Flag<double> cfg_tcp_gamma;
 
-  /** @brief Destructor */
+  explicit NetworkModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
   ~NetworkModel() override;
 
   /**
index b0a80bb..0454e7a 100644 (file)
@@ -11,6 +11,7 @@
 #include "ptask_L07.hpp"
 
 #include "cpu_interface.hpp"
+#include "xbt/config.hpp"
 #include "xbt/utility.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
@@ -400,7 +401,7 @@ void L07Action::updateBound()
       }
     }
   }
-  double lat_bound = sg_tcp_gamma / (2.0 * lat_current);
+  double lat_bound = NetworkModel::cfg_tcp_gamma / (2.0 * lat_current);
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) {
     if (rate_ < 0)
index eaff399..0b5a60f 100644 (file)
@@ -30,7 +30,6 @@ XBT_PUBLIC_DATA double sg_maxmin_precision;
 XBT_PUBLIC_DATA double sg_surf_precision;
 XBT_PUBLIC_DATA int sg_concurrency_limit;
 
-extern XBT_PRIVATE double sg_tcp_gamma;
 extern XBT_PRIVATE double sg_latency_factor;
 extern XBT_PRIVATE double sg_bandwidth_factor;
 extern XBT_PRIVATE double sg_weight_S_parameter;