Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetic cleanups in network models
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 12 Apr 2019 11:26:51 +0000 (13:26 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 12 Apr 2019 11:26:51 +0000 (13:26 +0200)
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/network_ib.cpp
src/surf/network_ib.hpp
src/surf/network_ns3.cpp
src/surf/network_ns3.hpp
src/surf/network_smpi.cpp
src/surf/network_smpi.hpp

index 26ae955..6ec3a51 100644 (file)
@@ -21,12 +21,14 @@ void surf_network_model_init_Constant()
 namespace simgrid {
 namespace kernel {
 namespace resource {
 namespace simgrid {
 namespace kernel {
 namespace resource {
+
 NetworkConstantModel::NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::FULL)
 {
   all_existing_models.push_back(this);
 }
 
 NetworkConstantModel::NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::FULL)
 {
   all_existing_models.push_back(this);
 }
 
-LinkImpl* NetworkConstantModel::create_link(const std::string& name, double, double, s4u::Link::SharingPolicy)
+LinkImpl* NetworkConstantModel::create_link(const std::string& name, double /*bandwidth*/, double /*latency*/,
+                                            s4u::Link::SharingPolicy)
 {
 
   xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
 {
 
   xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
@@ -63,16 +65,16 @@ void NetworkConstantModel::update_actions_state(double /*now*/, double delta)
 
     if ((action.get_remains_no_update() <= 0) ||
         ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
 
     if ((action.get_remains_no_update() <= 0) ||
         ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
-      action.finish(kernel::resource::Action::State::FINISHED);
+      action.finish(Action::State::FINISHED);
     }
   }
 }
 
     }
   }
 }
 
-kernel::resource::Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double)
+Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double)
 {
   NetworkConstantAction* action = new NetworkConstantAction(this, size, sg_latency_factor);
 
 {
   NetworkConstantAction* action = new NetworkConstantAction(this, size, sg_latency_factor);
 
-  simgrid::s4u::Link::on_communicate(*action, src, dst);
+  s4u::Link::on_communicate(*action, src, dst);
   return action;
 }
 
   return action;
 }
 
@@ -93,6 +95,7 @@ void NetworkConstantAction::update_remains_lazy(double /*now*/)
 {
   THROW_IMPOSSIBLE;
 }
 {
   THROW_IMPOSSIBLE;
 }
-}
+
+} // namespace resource
 } // namespace kernel
 } // namespace kernel
-}
+} // namespace simgrid
index eed41ed..63a08d0 100644 (file)
@@ -17,7 +17,7 @@ namespace resource {
 class NetworkConstantModel : public NetworkModel {
 public:
   NetworkConstantModel();
 class NetworkConstantModel : public NetworkModel {
 public:
   NetworkConstantModel();
-  Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, double rate) override;
+  Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
   double next_occuring_event(double now) override;
   void update_actions_state(double now, double delta) override;
 
   double next_occuring_event(double now) override;
   void update_actions_state(double now, double delta) override;
 
index afdd570..50b200b 100644 (file)
@@ -103,7 +103,7 @@ NetworkIBModel::NetworkIBModel() : NetworkSmpiModel()
 {
   /* Do not add this into all_existing_models: our ancestor already does so */
 
 {
   /* Do not add this into all_existing_models: our ancestor already does so */
 
-  std::string IB_factors_string = simgrid::config::get_value<std::string>("smpi/IB-penalty-factors");
+  std::string IB_factors_string = config::get_value<std::string>("smpi/IB-penalty-factors");
   std::vector<std::string> radical_elements;
   boost::split(radical_elements, IB_factors_string, boost::is_any_of(";"));
 
   std::vector<std::string> radical_elements;
   boost::split(radical_elements, IB_factors_string, boost::is_any_of(";"));
 
@@ -234,6 +234,6 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode
   updateIBfactors_rec(from, updated);
   XBT_DEBUG("IB - Finished updating %d", from->id);
 }
   updateIBfactors_rec(from, updated);
   XBT_DEBUG("IB - Finished updating %d", from->id);
 }
-}
-}
+} // namespace resource
+} // namespace kernel
 } // namespace simgrid
 } // namespace simgrid
index f15fcfd..a90f8ab 100644 (file)
@@ -42,7 +42,9 @@ public:
 };
 
 class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
 };
 
 class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
-private:
+  double Bs;
+  double Be;
+  double ys;
   void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist);
   void computeIBfactors(IBNode* root);
 
   void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist);
   void computeIBfactors(IBNode* root);
 
@@ -57,11 +59,8 @@ public:
   std::unordered_map<std::string, IBNode*> active_nodes;
   std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
 
   std::unordered_map<std::string, IBNode*> active_nodes;
   std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
 
-  double Bs;
-  double Be;
-  double ys;
 };
 };
-}
+} // namespace resource
 } // namespace kernel
 } // namespace simgrid
 #endif
 } // namespace kernel
 } // namespace simgrid
 #endif
index 63c4a27..b481aae 100644 (file)
@@ -155,18 +155,18 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel(Model::UpdateAlgo::FULL)
 
   all_existing_models.push_back(this);
 
 
   all_existing_models.push_back(this);
 
-  NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create<NetPointNs3>();
+  NetPointNs3::EXTENSION_ID = routing::NetPoint::extension_create<NetPointNs3>();
 
   ns3_initialize(ns3_tcp_model.get().c_str());
 
 
   ns3_initialize(ns3_tcp_model.get().c_str());
 
-  simgrid::kernel::routing::NetPoint::on_creation.connect([](simgrid::kernel::routing::NetPoint& pt) {
+  routing::NetPoint::on_creation.connect([](routing::NetPoint& pt) {
     pt.extension_set<NetPointNs3>(new NetPointNs3());
     XBT_VERB("SimGrid's %s is known as node %d within NS3", pt.get_cname(), pt.extension<NetPointNs3>()->node_num);
   });
     pt.extension_set<NetPointNs3>(new NetPointNs3());
     XBT_VERB("SimGrid's %s is known as node %d within NS3", pt.get_cname(), pt.extension<NetPointNs3>()->node_num);
   });
-  simgrid::surf::on_cluster.connect(&clusterCreation_cb);
+  surf::on_cluster.connect(&clusterCreation_cb);
 
 
-  simgrid::s4u::on_platform_created.connect(&postparse_cb);
-  simgrid::s4u::NetZone::on_route_creation.connect(&routeCreation_cb);
+  s4u::on_platform_created.connect(&postparse_cb);
+  s4u::NetZone::on_route_creation.connect(&routeCreation_cb);
 }
 
 NetworkNS3Model::~NetworkNS3Model() {
 }
 
 NetworkNS3Model::~NetworkNS3Model() {
@@ -179,7 +179,7 @@ LinkImpl* NetworkNS3Model::create_link(const std::string& name, double bandwidth
   return new LinkNS3(this, name, bandwidth, latency);
 }
 
   return new LinkNS3(this, name, bandwidth, latency);
 }
 
-kernel::resource::Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
+Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
 {
   return new NetworkNS3Action(this, size, src, dst);
 }
 {
   return new NetworkNS3Action(this, size, src, dst);
 }
@@ -294,7 +294,7 @@ void LinkNS3::set_latency_profile(profile::Profile* profile)
  * Action *
  **********/
 
  * Action *
  **********/
 
-NetworkNS3Action::NetworkNS3Action(kernel::resource::Model* model, double totalBytes, s4u::Host* src, s4u::Host* dst)
+NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* src, s4u::Host* dst)
     : NetworkAction(model, totalBytes, false), src_(src), dst_(dst)
 {
   XBT_DEBUG("Communicate from %s to %s", src->get_cname(), dst->get_cname());
     : NetworkAction(model, totalBytes, false), src_(src), dst_(dst)
 {
   XBT_DEBUG("Communicate from %s to %s", src->get_cname(), dst->get_cname());
@@ -349,8 +349,8 @@ void NetworkNS3Action::update_remains_lazy(double /*now*/)
 }
 
 } // namespace resource
 }
 
 } // namespace resource
-}
-}
+} // namespace kernel
+} // namespace simgrid
 
 void ns3_simulator(double maxSeconds)
 {
 
 void ns3_simulator(double maxSeconds)
 {
index af200b8..ed65cac 100644 (file)
@@ -20,7 +20,7 @@ public:
   ~NetworkNS3Model();
   LinkImpl* create_link(const std::string& name, double bandwidth, double latency,
                         s4u::Link::SharingPolicy policy) override;
   ~NetworkNS3Model();
   LinkImpl* create_link(const std::string& name, double bandwidth, double latency,
                         s4u::Link::SharingPolicy policy) override;
-  kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
+  Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
   double next_occuring_event(double now) override;
   bool next_occuring_event_is_idempotent() override { return false; }
   void update_actions_state(double now, double delta) override;
   double next_occuring_event(double now) override;
   bool next_occuring_event_is_idempotent() override { return false; }
   void update_actions_state(double now, double delta) override;
@@ -34,7 +34,7 @@ public:
   explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency);
   ~LinkNS3();
 
   explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency);
   ~LinkNS3();
 
-  void apply_event(simgrid::kernel::profile::Event* event, double value) override;
+  void apply_event(profile::Event* event, double value) override;
   void set_bandwidth(double value) override { THROW_UNIMPLEMENTED; }
   void set_latency(double value) override { THROW_UNIMPLEMENTED; }
   void set_bandwidth_profile(profile::Profile* profile) override;
   void set_bandwidth(double value) override { THROW_UNIMPLEMENTED; }
   void set_latency(double value) override { THROW_UNIMPLEMENTED; }
   void set_bandwidth_profile(profile::Profile* profile) override;
@@ -46,7 +46,7 @@ public:
  **********/
 class XBT_PRIVATE NetworkNS3Action : public NetworkAction {
 public:
  **********/
 class XBT_PRIVATE NetworkNS3Action : public NetworkAction {
 public:
-  NetworkNS3Action(kernel::resource::Model* model, double cost, s4u::Host* src, s4u::Host* dst);
+  NetworkNS3Action(Model* model, double cost, s4u::Host* src, s4u::Host* dst);
 
   void suspend() override;
   void resume() override;
 
   void suspend() override;
   void resume() override;
@@ -60,7 +60,7 @@ public:
 };
 
 } // namespace resource
 };
 
 } // namespace resource
-}
-}
+} // namespace kernel
+} // namespace simgrid
 
 #endif /* NETWORK_NS3_HPP_ */
 
 #endif /* NETWORK_NS3_HPP_ */
index 9a14001..f96bc1a 100644 (file)
@@ -47,12 +47,10 @@ NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model()
   /* Do not add this into all_existing_models: our ancestor already does so */
 }
 
   /* Do not add this into all_existing_models: our ancestor already does so */
 }
 
-NetworkSmpiModel::~NetworkSmpiModel() = default;
-
 double NetworkSmpiModel::get_bandwidth_factor(double size)
 {
   if (smpi_bw_factor.empty())
 double NetworkSmpiModel::get_bandwidth_factor(double size)
 {
   if (smpi_bw_factor.empty())
-    smpi_bw_factor = parse_factor(simgrid::config::get_value<std::string>("smpi/bw-factor"));
+    smpi_bw_factor = parse_factor(config::get_value<std::string>("smpi/bw-factor"));
 
   double current = 1.0;
   for (auto const& fact : smpi_bw_factor) {
 
   double current = 1.0;
   for (auto const& fact : smpi_bw_factor) {
@@ -70,7 +68,7 @@ double NetworkSmpiModel::get_bandwidth_factor(double size)
 double NetworkSmpiModel::get_latency_factor(double size)
 {
   if (smpi_lat_factor.empty())
 double NetworkSmpiModel::get_latency_factor(double size)
 {
   if (smpi_lat_factor.empty())
-    smpi_lat_factor = parse_factor(simgrid::config::get_value<std::string>("smpi/lat-factor"));
+    smpi_lat_factor = parse_factor(config::get_value<std::string>("smpi/lat-factor"));
 
   double current = 1.0;
   for (auto const& fact : smpi_lat_factor) {
 
   double current = 1.0;
   for (auto const& fact : smpi_lat_factor) {
@@ -89,14 +87,6 @@ double NetworkSmpiModel::get_bandwidth_constraint(double rate, double bound, dou
 {
   return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size));
 }
 {
   return rate < 0 ? bound : std::min(bound, rate * get_bandwidth_factor(size));
 }
-
-/************
- * Resource *
- ************/
-
-/**********
- * Action *
- **********/
-}
-}
+} // namespace resource
+} // namespace kernel
 } // namespace simgrid
 } // namespace simgrid
index e92f784..2864fc1 100644 (file)
@@ -15,7 +15,7 @@ namespace resource {
 class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model {
 public:
   NetworkSmpiModel();
 class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model {
 public:
   NetworkSmpiModel();
-  ~NetworkSmpiModel();
+  ~NetworkSmpiModel() = default;
 
   double get_latency_factor(double size);
   double get_bandwidth_factor(double size);
 
   double get_latency_factor(double size);
   double get_bandwidth_factor(double size);