Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2023.
[simgrid.git] / src / surf / network_cm02.cpp
index c0f1e0f..fe69c81 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. */
@@ -75,6 +75,34 @@ void surf_network_model_init_CM02()
   engine->get_netzone_root()->set_network_model(net_model);
 }
 
+/********************************************************************/
+/* Model based on LV08 and experimental results of MPI ping-pongs   */
+/********************************************************************/
+/* @Inproceedings{smpi_ipdps, */
+/*  author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and
+ * Martin Quinson}, */
+/*  title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
+/*  booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
+/*  address={Anchorage (Alaska) USA}, */
+/*  month=may, */
+/*  year={2011} */
+/*  } */
+void surf_network_model_init_SMPI()
+{
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_SMPI");
+  auto* engine   = simgrid::kernel::EngineImpl::get_instance();
+  engine->add_model(net_model);
+  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 {
 
 NetworkCm02Model::NetworkCm02Model(const std::string& name) : NetworkModel(name)
@@ -97,22 +125,6 @@ NetworkCm02Model::NetworkCm02Model(const std::string& name) : NetworkModel(name)
   loopback_->get_iface()->seal();
 }
 
-void NetworkCm02Model::check_lat_factor_cb()
-{
-  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.");
-  }
-}
-
-void NetworkCm02Model::check_bw_factor_cb()
-{
-  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.");
-  }
-}
-
 StandardLinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
 {
   xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
@@ -316,24 +328,20 @@ 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<StandardLinkImpl*>& route,
                                               const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones,
-                                              double rate)
+                                              double rate) const
 {
   std::vector<s4u::Link*> s4u_route;
   std::unordered_set<s4u::NetZone*> s4u_netzones;
 
   /* transform data to user structures if necessary */
-  if (lat_factor_cb_ || bw_factor_cb_) {
+  if (has_network_factor_cb()) {
     std::for_each(route.begin(), route.end(),
                   [&s4u_route](StandardLinkImpl* l) { s4u_route.push_back(l->get_iface()); });
     std::for_each(netzones.begin(), netzones.end(),
                   [&s4u_netzones](kernel::routing::NetZoneImpl* n) { s4u_netzones.insert(n->get_iface()); });
   }
-  double bw_factor;
-  if (bw_factor_cb_) {
-    bw_factor = bw_factor_cb_(size, src, dst, s4u_route, s4u_netzones);
-  } else {
-    bw_factor = get_bandwidth_factor(size);
-  }
+
+  double bw_factor = get_bandwidth_factor(size, src, dst, s4u_route, s4u_netzones);
   xbt_assert(bw_factor != 0, "Invalid param for comm %s -> %s. Bandwidth factor cannot be 0", src->get_cname(),
              dst->get_cname());
   action->set_rate_factor(bw_factor);
@@ -357,18 +365,20 @@ void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::H
   action->set_user_bound(bandwidth_bound);
 
   action->lat_current_ = action->latency_;
-  if (lat_factor_cb_) {
-    action->latency_ *= lat_factor_cb_(size, src, dst, s4u_route, s4u_netzones);
-  } else {
-    action->latency_ *= get_latency_factor(size);
-  }
+  action->latency_ *= get_latency_factor(size, src, dst, s4u_route, s4u_netzones);
 }
 
 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));
@@ -396,7 +406,7 @@ void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const
   }
 }
 
-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;
@@ -422,7 +432,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);