Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Create Disk::set_readwrite_bandwidth
authorBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 27 Jul 2021 12:27:10 +0000 (14:27 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 30 Jul 2021 12:54:11 +0000 (14:54 +0200)
Allow user to change readwrite constraint bound

include/simgrid/s4u/Disk.hpp
src/kernel/resource/DiskImpl.cpp
src/kernel/resource/DiskImpl.hpp
src/s4u/s4u_Disk.cpp
src/surf/disk_s19.cpp
src/surf/disk_s19.hpp

index 5ba6306..6d8e00d 100644 (file)
@@ -57,6 +57,17 @@ public:
   Disk* set_write_bandwidth(double write_bw);
   double get_write_bandwidth() const;
 
+  /**
+   * @brief Set limit for read/write operations.
+   *
+   * This determines the limit for read and write operation in the same disk.
+   * Usually, it's configured to max(read_bw, write_bw).
+   * You can change this behavior using this method
+   *
+   * @param bw New bandwidth for the disk
+   */
+  Disk* set_readwrite_bandwidth(double bw);
+
   const std::unordered_map<std::string, std::string>* get_properties() const;
   const char* get_property(const std::string& key) const;
   Disk* set_property(const std::string&, const std::string& value);
index 7b1fca1..fe2e269 100644 (file)
@@ -113,9 +113,13 @@ void DiskImpl::seal()
 
   xbt_assert(this->get_model(), "Cannot seal Disk (%s) without setting the model first", get_cname());
   lmm::System* maxmin_system = get_model()->get_maxmin_system();
+  /* set readwrite constraint if not configured by user */
+  if (readwrite_bw_ == -1) {
+    readwrite_bw_ = std::max(read_bw_.peak, write_bw_.peak);
+  }
   this->set_read_constraint(maxmin_system->constraint_new(this, read_bw_.peak * read_bw_.scale))
       ->set_write_constraint(maxmin_system->constraint_new(this, write_bw_.peak * write_bw_.scale))
-      ->set_constraint(maxmin_system->constraint_new(this, std::max(read_bw_.peak, write_bw_.peak)));
+      ->set_constraint(maxmin_system->constraint_new(this, readwrite_bw_));
   apply_sharing_policy_cfg();
   XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_.peak, write_bw_.peak);
   Resource::seal();
index 80905f9..8cd0ca7 100644 (file)
@@ -66,6 +66,7 @@ protected:
 public:
   Metric read_bw_  = {0.0, 0, nullptr};
   Metric write_bw_ = {0.0, 0, nullptr};
+  double readwrite_bw_ = -1; /* readwrite constraint bound, usually max(read, write) */
 
   explicit DiskImpl(const std::string& name, double read_bandwidth, double write_bandwidth);
   DiskImpl(const DiskImpl&) = delete;
@@ -83,6 +84,8 @@ public:
   virtual void set_write_bandwidth(double write_bw) = 0;
   double get_write_bandwidth() const { return write_bw_.peak * write_bw_.scale; }
 
+  virtual void set_readwrite_bandwidth(double bw) = 0;
+
   DiskImpl* set_read_constraint(lmm::Constraint* constraint_read);
   lmm::Constraint* get_read_constraint() const { return constraint_read_; }
 
index d3f3a46..7ad08c3 100644 (file)
@@ -47,6 +47,12 @@ double Disk::get_read_bandwidth() const
   return pimpl_->get_read_bandwidth();
 }
 
+Disk* Disk::set_readwrite_bandwidth(double bw)
+{
+  kernel::actor::simcall([this, bw] { pimpl_->set_readwrite_bandwidth(bw); });
+  return this;
+}
+
 double Disk::get_write_bandwidth() const
 {
   return pimpl_->get_write_bandwidth();
index d84dfc3..6c2e68a 100644 (file)
@@ -104,6 +104,13 @@ void DiskS19::set_write_bandwidth(double value)
   update_penalties(delta);
 }
 
+void DiskS19::set_readwrite_bandwidth(double value)
+{
+  readwrite_bw_ = value;
+  if (get_constraint())
+    get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), readwrite_bw_);
+}
+
 void DiskS19::apply_event(kernel::profile::Event* triggered, double value)
 {
   /* Find out which of my iterators was triggered, and react accordingly */
index 5825311..f169c48 100644 (file)
@@ -47,6 +47,7 @@ public:
   using DiskImpl::DiskImpl;
   void set_read_bandwidth(double value) override;
   void set_write_bandwidth(double value) override;
+  void set_readwrite_bandwidth(double value) override;
   void apply_event(kernel::profile::Event* triggered, double value) override;
 };