Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to set a concurrency limit on disks and hosts
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 12 Apr 2023 15:43:10 +0000 (17:43 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 12 Apr 2023 15:50:46 +0000 (17:50 +0200)
ChangeLog
include/simgrid/s4u/Disk.hpp
include/simgrid/s4u/Host.hpp
src/kernel/resource/LinkImpl.hpp
src/kernel/resource/Resource.hpp
src/kernel/resource/StandardLinkImpl.cpp
src/kernel/resource/StandardLinkImpl.hpp
src/s4u/s4u_Disk.cpp
src/s4u/s4u_Host.cpp

index 41bc62f..7cb4558 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@ S4U:
  - Full simDAG integration: Activity::start() actually starts only when all dependencies
    are fullfiled. If it cannot be started right away, it will start as soon as it becomes
    possible.
+ - Allow to set a concurrency limit on disks and hosts, as it was already the case for links.
 
 Kernel:
  - optimize an internal datastructure (use a set instead of a list for ongoing activities),
index 1f8c31d..fcba914 100644 (file)
@@ -79,6 +79,13 @@ public:
   Disk* set_state_profile(kernel::profile::Profile* profile);
   Disk* set_read_bandwidth_profile(kernel::profile::Profile* profile);
   Disk* set_write_bandwidth_profile(kernel::profile::Profile* profile);
+  /**
+   * @brief Set the max amount of operations (either read or write) that can take place on this disk at the same time
+   *
+   * Use -1 to set no limit.
+   */
+  Disk* set_concurrency_limit(int limit);
+  int get_concurrency_limit() const;
 
   IoPtr io_init(sg_size_t size, s4u::Io::OpType type) const;
 
index b13b561..df0511a 100644 (file)
@@ -133,6 +133,14 @@ public:
   Host* set_state_profile(kernel::profile::Profile* p);
   Host* set_speed_profile(kernel::profile::Profile* p);
 
+  /**
+   * @brief Set the max amount of executions that can take place on this host at the same time
+   *
+   * Use -1 to set no limit.
+   */
+  Host* set_concurrency_limit(int limit);
+  int get_concurrency_limit() const;
+
   /** @brief Convert the CPU's speed from string to double */
   static std::vector<double> convert_pstate_speed_vector(const std::vector<std::string>& speed_per_state);
   /**
index f7f269f..8b6ac8a 100644 (file)
@@ -38,10 +38,6 @@ public:
   /* setup the profile file with latency events (peak latency changes due to external load).
    * Profile must contain absolute values */
   virtual void set_latency_profile(kernel::profile::Profile* profile) = 0;
-  /** @brief Set the concurrency limit for this link */
-  virtual void set_concurrency_limit(int limit) const = 0;
-  /** @brief Get the concurrency limit of this link */
-  virtual int get_concurrency_limit() const = 0;
 };
 
 } // namespace simgrid::kernel::resource
index bf67c6a..6c864e3 100644 (file)
@@ -101,6 +101,17 @@ public:
 
   lmm::Constraint* get_constraint() const { return constraint_; }
 
+  /** @brief Set the concurrency limit for this resource */
+  virtual void set_concurrency_limit(int limit) const
+  {
+    if (limit != -1)
+      get_constraint()->reset_concurrency_maximum();
+    get_constraint()->set_concurrency_limit(limit);
+  }
+
+  /** @brief Get the concurrency limit of this resource */
+  virtual int get_concurrency_limit() const { return get_constraint()->get_concurrency_limit(); }
+
   /** @brief returns the current load due to activities (in flops per second, byte per second or similar)
    *
    * The load due to external usages modeled by profile files is ignored.*/
index 9e50e7a..59a07d1 100644 (file)
@@ -133,16 +133,4 @@ void StandardLinkImpl::set_latency_profile(profile::Profile* profile)
   }
 }
 
-void StandardLinkImpl::set_concurrency_limit(int limit) const
-{
-  if (limit != -1) {
-    get_constraint()->reset_concurrency_maximum();
-  }
-  get_constraint()->set_concurrency_limit(limit);
-}
-int StandardLinkImpl::get_concurrency_limit() const
-{
-  return get_constraint()->get_concurrency_limit();
-}
-
 } // namespace simgrid::kernel::resource
index 4a10210..d573fe1 100644 (file)
@@ -70,9 +70,6 @@ public:
   /* setup the profile file with latency events (peak latency changes due to external load).
    * Profile must contain absolute values */
   void set_latency_profile(kernel::profile::Profile* profile) override;
-
-  void set_concurrency_limit(int limit) const override;
-  int get_concurrency_limit() const override;
 };
 
 } // namespace simgrid::kernel::resource
index 9e3d59f..0fa8295 100644 (file)
@@ -112,6 +112,16 @@ Disk* Disk::set_write_bandwidth_profile(kernel::profile::Profile* profile)
                                        [this, profile]() { this->pimpl_->set_write_bandwidth_profile(profile); });
   return this;
 }
+int Disk::get_concurrency_limit() const
+{
+  return pimpl_->get_concurrency_limit();
+}
+
+Disk* Disk::set_concurrency_limit(int limit)
+{
+  kernel::actor::simcall_object_access(pimpl_, [this, limit] { pimpl_->set_concurrency_limit(limit); });
+  return this;
+}
 
 IoPtr Disk::io_init(sg_size_t size, Io::OpType type) const
 {
index ba4a844..af3a4ad 100644 (file)
@@ -207,6 +207,17 @@ Host* Host::set_properties(const std::unordered_map<std::string, std::string>& p
   return this;
 }
 
+int Host::get_concurrency_limit() const
+{
+  return pimpl_cpu_->get_concurrency_limit();
+}
+
+Host* Host::set_concurrency_limit(int limit)
+{
+  kernel::actor::simcall_object_access(pimpl_cpu_, [this, limit] { pimpl_cpu_->set_concurrency_limit(limit); });
+  return this;
+}
+
 /** Specify a profile turning the host on and off according to an exhaustive list or a stochastic law.
  * The profile must contain boolean values. */
 Host* Host::set_state_profile(kernel::profile::Profile* p)