From: Bruno Donassolo Date: Tue, 27 Jul 2021 12:27:10 +0000 (+0200) Subject: Create Disk::set_readwrite_bandwidth X-Git-Tag: v3.29~176 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f2ecde6af20db46907714e04cee35408df5f5a10 Create Disk::set_readwrite_bandwidth Allow user to change readwrite constraint bound --- diff --git a/include/simgrid/s4u/Disk.hpp b/include/simgrid/s4u/Disk.hpp index 5ba6306774..6d8e00dcae 100644 --- a/include/simgrid/s4u/Disk.hpp +++ b/include/simgrid/s4u/Disk.hpp @@ -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* get_properties() const; const char* get_property(const std::string& key) const; Disk* set_property(const std::string&, const std::string& value); diff --git a/src/kernel/resource/DiskImpl.cpp b/src/kernel/resource/DiskImpl.cpp index 7b1fca1b4c..fe2e269513 100644 --- a/src/kernel/resource/DiskImpl.cpp +++ b/src/kernel/resource/DiskImpl.cpp @@ -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(); diff --git a/src/kernel/resource/DiskImpl.hpp b/src/kernel/resource/DiskImpl.hpp index 80905f909e..8cd0ca7c50 100644 --- a/src/kernel/resource/DiskImpl.hpp +++ b/src/kernel/resource/DiskImpl.hpp @@ -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_; } diff --git a/src/s4u/s4u_Disk.cpp b/src/s4u/s4u_Disk.cpp index d3f3a46100..7ad08c3a0b 100644 --- a/src/s4u/s4u_Disk.cpp +++ b/src/s4u/s4u_Disk.cpp @@ -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(); diff --git a/src/surf/disk_s19.cpp b/src/surf/disk_s19.cpp index d84dfc318e..6c2e68a5ad 100644 --- a/src/surf/disk_s19.cpp +++ b/src/surf/disk_s19.cpp @@ -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 */ diff --git a/src/surf/disk_s19.hpp b/src/surf/disk_s19.hpp index 5825311a21..f169c4810d 100644 --- a/src/surf/disk_s19.hpp +++ b/src/surf/disk_s19.hpp @@ -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; };