Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / surf / ptask_L07.hpp
index d13f3c9..a433611 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. */
@@ -12,7 +12,8 @@
 #define HOST_L07_HPP_
 
 namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
 
 /***********
  * Classes *
@@ -26,55 +27,52 @@ class XBT_PRIVATE CpuL07;
 class XBT_PRIVATE LinkL07;
 
 class XBT_PRIVATE L07Action;
-/*********
- * Tools *
- *********/
 
 /*********
  * Model *
  *********/
 class HostL07Model : public HostModel {
 public:
-  explicit HostL07Model(std::string name);
+  explicit HostL07Model(const std::string& name);
   HostL07Model(const HostL07Model&) = delete;
   HostL07Model& operator=(const HostL07Model&) = delete;
 
   double next_occurring_event(double now) override;
   void update_actions_state(double now, double delta) override;
-  kernel::resource::CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
-                                                const double* bytes_amount, double rate) override;
+  CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
+                              const double* bytes_amount, double rate) override;
 };
 
-class CpuL07Model : public kernel::resource::CpuModel {
+class CpuL07Model : public CpuModel {
 public:
-  CpuL07Model(std::string name, HostL07Model* hmodel, kernel::lmm::System* sys);
+  CpuL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys);
   CpuL07Model(const CpuL07Model&) = delete;
   CpuL07Model& operator=(const CpuL07Model&) = delete;
   ~CpuL07Model() override;
   void update_actions_state(double /*now*/, double /*delta*/) override{
       /* this action is done by HostL07Model which shares the LMM system with the CPU model
        * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
-       * method in surf_presolve */
+       * method in EngineImpl::presolve */
   };
 
-  kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
+  CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
   HostL07Model* hostModel_;
 };
 
-class NetworkL07Model : public kernel::resource::NetworkModel {
+class NetworkL07Model : public NetworkModel {
 public:
-  NetworkL07Model(std::string name, HostL07Model* hmodel, kernel::lmm::System* sys);
+  NetworkL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys);
   NetworkL07Model(const NetworkL07Model&) = delete;
   NetworkL07Model& operator=(const NetworkL07Model&) = delete;
   ~NetworkL07Model() override;
-  kernel::resource::LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths,
-                                          s4u::Link::SharingPolicy policy) override;
+  StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) final;
+  StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) 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;
   void update_actions_state(double /*now*/, double /*delta*/) override{
       /* this action is done by HostL07Model which shares the LMM system with the CPU model
        * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
-       * method in surf_presolve */
+       * method in EngineImpl::presolve */
   };
 
   HostL07Model* hostModel_;
@@ -84,42 +82,40 @@ public:
  * Resource *
  ************/
 
-class CpuL07 : public kernel::resource::Cpu {
+class CpuL07 : public CpuImpl {
 public:
-  using kernel::resource::Cpu::Cpu;
+  using CpuImpl::CpuImpl;
   CpuL07(const CpuL07&) = delete;
   CpuL07& operator=(const CpuL07&) = delete;
 
-  bool is_used() const override;
-  void apply_event(kernel::profile::Event* event, double value) override;
-  kernel::resource::CpuAction* execution_start(double size) override;
-  kernel::resource::CpuAction* execution_start(double, int) override
+  void apply_event(profile::Event* event, double value) override;
+  CpuAction* execution_start(double size, double user_bound) override;
+  CpuAction* execution_start(double, int, double) override
   {
     THROW_UNIMPLEMENTED;
     return nullptr;
   }
-  kernel::resource::CpuAction* sleep(double duration) override;
+  CpuAction* sleep(double duration) override;
 
 protected:
   void on_speed_change() override;
 };
 
-class LinkL07 : public kernel::resource::LinkImpl {
+class LinkL07 : public StandardLinkImpl {
 public:
-  LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, kernel::lmm::System* system);
+  LinkL07(const std::string& name, double bandwidth, lmm::System* system);
   LinkL07(const LinkL07&) = delete;
   LinkL07& operator=(const LinkL07&) = delete;
   ~LinkL07() override;
-  bool is_used() const override;
-  void apply_event(kernel::profile::Event* event, double value) override;
+  void apply_event(profile::Event* event, double value) override;
   void set_bandwidth(double value) override;
-  LinkImpl* set_latency(double value) override;
+  void set_latency(double value) override;
 };
 
 /**********
  * Action *
  **********/
-class L07Action : public kernel::resource::CpuAction {
+class L07Action : public CpuAction {
   std::vector<s4u::Host*> hostList_;
   bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
                              // exec and regular comms
@@ -130,15 +126,30 @@ class L07Action : public kernel::resource::CpuAction {
   double latency_;
   double rate_;
 
-  friend CpuAction* CpuL07::execution_start(double size);
+  friend CpuAction* CpuL07::execution_start(double size, double user_bound);
   friend CpuAction* CpuL07::sleep(double duration);
   friend CpuAction* HostL07Model::execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
                                                    const double* bytes_amount, double rate);
   friend Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
+  /**
+   * @brief Calculate the CPU bound for the parallel task
+   *
+   * The task is bounded by the slowest CPU running the ptask, considering the current pstate of each CPU.
+   * Return MAX_DOUBLE if ptask has no computation.
+   */
+  double calculateCpuBound();
+
+  /**
+   * @brief Calculate the network bound for the parallel task
+   *
+   * The network bound depends on the largest latency between the communication in the ptask.
+   * Return MAX_DOUBLE if latency is 0 (or ptask doesn't have any communication)
+   */
+  double calculateNetworkBound();
 
 public:
   L07Action() = delete;
-  L07Action(kernel::resource::Model* model, const std::vector<s4u::Host*>& host_list, const double* flops_amount,
+  L07Action(Model* model, const std::vector<s4u::Host*>& host_list, const double* flops_amount,
             const double* bytes_amount, double rate);
   L07Action(const L07Action&) = delete;
   L07Action& operator=(const L07Action&) = delete;
@@ -150,7 +161,8 @@ public:
   void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
 };
 
-} // namespace surf
+} // namespace resource
+} // namespace kernel
 } // namespace simgrid
 
 #endif /* HOST_L07_HPP_ */