Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge network/bandwidth-factor and smpi/bw-factor (and same for latency)
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Oct 2022 09:28:33 +0000 (11:28 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Oct 2022 09:28:33 +0000 (11:28 +0200)
docs/source/XML_reference.rst
examples/platforms/config.xml
src/kernel/resource/NetworkModel.cpp
src/kernel/resource/NetworkModelIntf_test.cpp
src/simgrid/sg_config.cpp
src/surf/network_smpi.cpp
src/surf/network_smpi.hpp

index 1060796..95bba47 100644 (file)
@@ -134,7 +134,7 @@ name of the flag and ``value`` is what it has to be set to.
        <prop id = "maxmin/precision" value = "0.000010" />
        <prop id = "cpu/optim" value = "TI" />
        <prop id = "network/model" value = "SMPI" />
-       <prop id = "smpi/bw-factor" value = "65472:0.940694;15424:0.697866;9376:0.58729" />
+       <prop id = "network/bandwidth-factor" value = "65472:0.940694;15424:0.697866;9376:0.58729" />
      </config>
 
      <!-- The rest of your platform -->
index 20da60c..ce1f2f7 100644 (file)
@@ -7,7 +7,7 @@
     <prop id="host/model" value="compound"></prop>
     <prop id="network/model" value="SMPI"></prop>
     <prop id="path" value="~/"></prop>
-    <prop id="smpi/bw-factor" value="65472:0.940694;15424:0.697866;9376:0.58729"></prop>
+    <prop id="network/bandwidth-factor" value="65472:0.940694;15424:0.697866;9376:0.58729"></prop>
   </config>
 
   <zone  id="AS0"  routing="Full">
index 4573367..0e5aa79 100644 (file)
@@ -27,10 +27,10 @@ static smpi::utils::FactorSet cfg_latency_factor("network/latency-factor");
 static smpi::utils::FactorSet cfg_bandwidth_factor("network/bandwidth-factor");
 
 config::Flag<std::string> cfg_latency_factor_str(
-    "network/latency-factor",
+    "network/latency-factor", {{"smpi/lat-factor"}},
     "Correction factor to apply to the provided latency (default value overridden by network model)", "1.0");
 static config::Flag<std::string> cfg_bandwidth_factor_str(
-    "network/bandwidth-factor",
+    "network/bandwidth-factor", {{"smpi/bw-factor"}},
     "Correction factor to apply to the provided bandwidth (default value overridden by network model)", "1.0");
 
 double NetworkModel::get_latency_factor(double size)
index 5af8c05..5574eaa 100644 (file)
@@ -43,7 +43,13 @@ TEST_CASE("kernel::resource::NetworkModelIntf: Factors invalid callbacks: except
 
 TEST_CASE("kernel::resource::NetworkModelIntf: Invalid network/latency-factor and network/bandwidth-factor", "")
 {
-  for (const auto& model : std::vector<std::string>{"LV08", "CM02"}) {
+  std::vector<std::string> models{"LV08", "CM02"};
+#if HAVE_SMPI
+  models.emplace_back("SMPI");
+  models.emplace_back("IB");
+#endif
+
+  for (const auto& model : models) {
     _sg_cfg_init_status = 0; /* HACK: clear config global to be able to do set_config in UTs */
     simgrid::s4u::Engine e("test");
     simgrid::s4u::Engine::set_config("network/model:" + model);
@@ -59,25 +65,3 @@ TEST_CASE("kernel::resource::NetworkModelIntf: Invalid network/latency-factor an
     }
   }
 }
-
-#if HAVE_SMPI
-TEST_CASE("kernel::resource::NetworkModelIntf: Invalid smpi/lat-factor and smpi/bw-factor", "")
-{
-  for (const auto& model : std::vector<std::string>{"SMPI", "IB"}) {
-    _sg_cfg_init_status = 0; /* HACK: clear config global to be able to do set_config in UTs */
-    simgrid::s4u::Engine e("test");
-    simgrid::s4u::Engine::set_config("network/model:" + model);
-    simgrid::s4u::Engine::set_config(
-        "smpi/lat-factor:65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493");
-    simgrid::s4u::Engine::set_config("smpi/bw-factor:65472:11.6436;15424:3.48845");
-    simgrid::s4u::create_full_zone("root");
-
-    SECTION("Model: " + model)
-    {
-      simgrid::kernel::resource::NetworkModelIntf* m = e.get_netzone_root()->get_network_model();
-      REQUIRE_THROWS_AS(m->set_lat_factor_cb(factor_cb), std::invalid_argument);
-      REQUIRE_THROWS_AS(m->set_bw_factor_cb(factor_cb), std::invalid_argument);
-    }
-  }
-}
-#endif
index 0b67cdc..0fa1beb 100644 (file)
@@ -338,18 +338,7 @@ void sg_config_init(int *argc, char **argv)
                                                                 default_synchro_mode,
                                                                 &_sg_cfg_cb_contexts_parallel_mode};
 
-  // For smpi/bw-factor and smpi/lat-factor
   // SMPI model can be used without enable_smpi, so keep this out of the ifdef.
-  simgrid::config::declare_flag<std::string>("smpi/bw-factor",
-                                             "Bandwidth factors for smpi. Format: "
-                                             "'threshold0:value0;threshold1:value1;...;thresholdN:valueN', "
-                                             "meaning if(size >=thresholdN ) return valueN.",
-                                             "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;"
-                                             "1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
-
-  simgrid::config::declare_flag<std::string>("smpi/lat-factor", "Latency factors for smpi.",
-                                             "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;"
-                                             "1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
   static simgrid::config::Flag<std::string> cfg_smpi_IB_penalty_factors{
       "smpi/IB-penalty-factors",
       "Correction factor to communications using Infiniband model with "
index 3e47a60..4ca339f 100644 (file)
@@ -37,13 +37,19 @@ void surf_network_model_init_SMPI()
   engine->get_netzone_root()->set_network_model(net_model);
 
   simgrid::config::set_default<double>("network/weight-S", 8775);
+  simgrid::config::set_default<std::string>("network/bandwidth-factor",
+                                            "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;"
+                                            "1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
+  simgrid::config::set_default<std::string>("network/latency-factor",
+                                            "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;"
+                                            "1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
 }
 
 namespace simgrid::kernel::resource {
 
 void NetworkSmpiModel::check_lat_factor_cb()
 {
-  if (not simgrid::config::is_default("smpi/lat-factor")) {
+  if (not simgrid::config::is_default("network/latency-factor")) {
     throw std::invalid_argument(
         "NetworkModelIntf: Cannot mix network/latency-factor and callback configuration. Choose only one of them.");
   }
@@ -51,27 +57,10 @@ void NetworkSmpiModel::check_lat_factor_cb()
 
 void NetworkSmpiModel::check_bw_factor_cb()
 {
-  if (not simgrid::config::is_default("smpi/bw-factor")) {
+  if (not simgrid::config::is_default("network/bandwidth-factor")) {
     throw std::invalid_argument(
         "NetworkModelIntf: Cannot mix network/bandwidth-factor and callback configuration. Choose only one of them.");
   }
 }
 
-double NetworkSmpiModel::get_bandwidth_factor(double size)
-{
-  static smpi::utils::FactorSet smpi_bw_factor("smpi/bw-factor");
-  if (not smpi_bw_factor.is_initialized())
-    smpi_bw_factor.parse(config::get_value<std::string>("smpi/bw-factor"));
-
-  return smpi_bw_factor(size);
-}
-
-double NetworkSmpiModel::get_latency_factor(double size)
-{
-  static smpi::utils::FactorSet smpi_lat_factor("smpi/lat-factor");
-  if (not smpi_lat_factor.is_initialized())
-    smpi_lat_factor.parse(config::get_value<std::string>("smpi/lat-factor"));
-
-  return smpi_lat_factor(size);
-}
 } // namespace simgrid::kernel::resource
index a2c81fd..2d69dc4 100644 (file)
@@ -17,9 +17,6 @@ class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model {
 public:
   using NetworkCm02Model::NetworkCm02Model;
 
-  double get_latency_factor(double size) override;
-  double get_bandwidth_factor(double size) override;
-
 protected:
   void check_lat_factor_cb() override;
   void check_bw_factor_cb() override;