From: Martin Quinson Date: Wed, 4 Apr 2018 15:52:35 +0000 (+0200) Subject: Make cmd-line option "network/TCP-gamma" neat and clean X-Git-Tag: v3.20~523 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8de466d0f03f18b22c6c36170b509d48a39fcd52?hp=8c7988580207b11a5d1b03fd892e1d68ad0788a3 Make cmd-line option "network/TCP-gamma" neat and clean --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index d940b36da6..fa46962cda 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -14,6 +14,9 @@ #include namespace simgrid { +namespace config { +template class Flag; +} namespace kernel { class EngineImpl; namespace context { diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 1f46590a3f..9df266c554 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -227,6 +227,12 @@ public: simgrid::config::bindFlag(value_, name, desc); } + /** Constructor taking an array of aliases as name */ + Flag(std::initializer_list 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. */ diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 3fe0c43897..49cbfcc7cb 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -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)"); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 1a65f0437c..3970dcc8d5 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -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_); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 480a1a5ca3..ac8dcb2b4d 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -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 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*/) { diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 3cf8c35dee..822602ad8a 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -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 cfg_tcp_gamma; - /** @brief Destructor */ + explicit NetworkModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {} ~NetworkModel() override; /** diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index b0a80bb863..0454e7a340 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -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) diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index eaff399839..0b5a60f25f 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -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;