Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Hide cfg_latency_factor and bw, and change them into smpi::utils::FactorSet
[simgrid.git] / src / surf / network_constant.cpp
index fa25c66..957d8c7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2022. 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. */
@@ -23,11 +23,9 @@ void surf_network_model_init_Constant()
   engine->get_netzone_root()->set_network_model(net_model);
 }
 
-namespace simgrid {
-namespace kernel {
-namespace resource {
+namespace simgrid::kernel::resource {
 
-LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector<double>& /*bandwidth*/)
+StandardLinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector<double>& /*bandwidth*/)
 {
   xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
           "Please remove any link from your platform (and switch to routing='None')",
@@ -35,7 +33,7 @@ LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::
   return nullptr;
 }
 
-LinkImpl* NetworkConstantModel::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
+StandardLinkImpl* NetworkConstantModel::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
 {
   return create_link(name, bandwidths);
 }
@@ -63,7 +61,7 @@ void NetworkConstantModel::update_actions_state(double /*now*/, double delta)
         action.latency_ = 0.0;
       }
     }
-    action.update_remains(action.get_cost() * delta / sg_latency_factor);
+    action.update_remains(action.get_cost() * delta / get_latency_factor());
     action.update_max_duration(delta);
 
     if ((action.get_remains_no_update() <= 0) ||
@@ -75,10 +73,7 @@ void NetworkConstantModel::update_actions_state(double /*now*/, double delta)
 
 Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double /*rate*/)
 {
-  auto* action = new NetworkConstantAction(this, *src, *dst, size);
-
-  s4u::Link::on_communicate(*action);
-  return action;
+  return (new NetworkConstantAction(this, *src, *dst, size));
 }
 
 /**********
@@ -87,7 +82,7 @@ Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double
 NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size)
     : NetworkAction(model_, src, dst, size, false)
 {
-  latency_ = sg_latency_factor;
+  latency_ = model_->get_latency_factor();
   if (latency_ <= 0.0)
     set_state(Action::State::FINISHED);
 }
@@ -97,6 +92,4 @@ void NetworkConstantAction::update_remains_lazy(double /*now*/)
   THROW_IMPOSSIBLE;
 }
 
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::resource