Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
refactor Resource::is_used()
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 26 Oct 2021 12:52:16 +0000 (14:52 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 26 Oct 2021 13:15:56 +0000 (15:15 +0200)
include/simgrid/kernel/resource/Resource.hpp
src/kernel/resource/DiskImpl.cpp
src/kernel/resource/DiskImpl.hpp
src/surf/LinkImpl.cpp
src/surf/LinkImpl.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp

index f1edd89..2c1bcc1 100644 (file)
@@ -52,13 +52,12 @@ public:
   /** @brief Apply an event of external load event to that resource */
   virtual void apply_event(profile::Event* event, double value) = 0;
 
-  /** @brief Check if the current Resource is used (if it currently serves an action) */
-  virtual bool is_used() const = 0;
-
   /** @brief Check if the current Resource is active */
   virtual bool is_on() const { return is_on_; }
   virtual bool is_sealed() const { return sealed_; }
 
+  /** @brief Check if the current Resource is used (if it currently serves an action) */
+  virtual bool is_used() const = 0;
   /** @brief Turn on the current Resource */
   virtual void turn_on() { is_on_ = true; }
   /** @brief Turn off the current Resource */
@@ -102,6 +101,8 @@ public:
    *
    * The load due to external usages modeled by profile files is ignored.*/
   virtual double get_load() const { return constraint_->get_usage(); }
+
+  bool is_used() const override { return model_->get_maxmin_system()->constraint_used(constraint_); }
 };
 
 } // namespace resource
index fe2e269..e3781ab 100644 (file)
@@ -68,11 +68,6 @@ void DiskImpl::destroy()
   delete this;
 }
 
-bool DiskImpl::is_used() const
-{
-  return get_model()->get_maxmin_system()->constraint_used(get_constraint());
-}
-
 void DiskImpl::turn_on()
 {
   if (not is_on()) {
index 0351e1d..5735d8d 100644 (file)
@@ -101,8 +101,6 @@ public:
   void set_factor_cb(const std::function<s4u::Disk::IoFactorCb>& cb);
   const std::function<s4u::Disk::IoFactorCb>& get_factor_cb() const { return factor_cb_; }
 
-  /** @brief Check if the Disk is used (if an action currently uses its resources) */
-  bool is_used() const override;
   void turn_on() override;
   void turn_off() override;
 
index d97bc34..43a24b2 100644 (file)
@@ -39,11 +39,6 @@ void LinkImpl::destroy()
   delete this;
 }
 
-bool LinkImpl::is_used() const
-{
-  return get_model()->get_maxmin_system()->constraint_used(get_constraint());
-}
-
 constexpr kernel::lmm::Constraint::SharingPolicy to_maxmin_policy(s4u::Link::SharingPolicy policy)
 {
   switch (policy) {
index d560879..bd67a52 100644 (file)
@@ -54,9 +54,6 @@ public:
   void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) override;
   s4u::Link::SharingPolicy get_sharing_policy() const override;
 
-  /** @brief Check if the Link is used */
-  bool is_used() const override;
-
   void turn_on() override;
   void turn_off() override;
 
index a17b5df..78a6573 100644 (file)
@@ -79,11 +79,6 @@ CpuImpl* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& s
 /************
  * Resource *
  ************/
-bool CpuCas01::is_used() const
-{
-  return get_model()->get_maxmin_system()->constraint_used(get_constraint());
-}
-
 /** @brief take into account changes of speed (either load or max) */
 void CpuCas01::on_speed_change()
 {
index 6656198..3a027b4 100644 (file)
@@ -51,8 +51,6 @@ public:
   CpuAction* sleep(double duration) override;
   void set_factor_cb(const std::function<s4u::Host::CpuFactorCb>& cb) override;
 
-  bool is_used() const override;
-
 protected:
   void on_speed_change() override;
 };
index 593ca1e..c2bb74f 100644 (file)
@@ -280,11 +280,6 @@ kernel::resource::CpuAction* CpuL07::sleep(double duration)
   return action;
 }
 
-bool CpuL07::is_used() const
-{
-  return get_model()->get_maxmin_system()->constraint_used(get_constraint());
-}
-
 /** @brief take into account changes of speed (either load or max) */
 void CpuL07::on_speed_change()
 {
@@ -306,11 +301,6 @@ LinkL07::LinkL07(const std::string& name, double bandwidth, kernel::lmm::System*
   bandwidth_.peak = bandwidth;
 }
 
-bool LinkL07::is_used() const
-{
-  return get_model()->get_maxmin_system()->constraint_used(get_constraint());
-}
-
 void CpuL07::apply_event(kernel::profile::Event* triggered, double value)
 {
   XBT_DEBUG("Updating cpu %s (%p) with value %g", get_cname(), this, value);
index 0b65d2b..9b52893 100644 (file)
@@ -90,7 +90,6 @@ public:
   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, double user_bound) override;
   kernel::resource::CpuAction* execution_start(double, int, double) override
@@ -110,7 +109,6 @@ public:
   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 set_bandwidth(double value) override;
   void set_latency(double value) override;