Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give access to disk's read and write (nomimal) bandwidth values
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 9 Dec 2019 10:52:58 +0000 (11:52 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 9 Dec 2019 10:52:58 +0000 (11:52 +0100)
examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
examples/s4u/io-disk-raw/s4u-io-disk-raw.tesh
include/simgrid/s4u/Disk.hpp
src/kernel/resource/DiskImpl.cpp
src/kernel/resource/DiskImpl.hpp
src/s4u/s4u_Disk.cpp

index fadd0d8..d51781a 100644 (file)
@@ -19,7 +19,8 @@ static void host()
 
   /* - For each disk mounted on host, display disk name and mount point */
   for (auto disk : disk_list)
 
   /* - For each disk mounted on host, display disk name and mount point */
   for (auto disk : disk_list)
-    XBT_INFO("Disk name: %s", disk->get_cname());
+    XBT_INFO("Disk name: %s (read: %.0f B/s -- write: %.0f B/s ", disk->get_cname(), disk->get_read_bandwidth(),
+             disk->get_write_bandwidth());
 
   /* - Write 400,000 bytes on Disk1 */
   simgrid::s4u::Disk* disk = disk_list.front();
 
   /* - Write 400,000 bytes on Disk1 */
   simgrid::s4u::Disk* disk = disk_list.front();
index 1dcba40..f2eadab 100644 (file)
@@ -8,8 +8,8 @@ $ ${bindir}/s4u-io-disk-raw ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%1
 > [  0.000000] (0:maestro@) *** carl properties ****
 > [  0.000000] (0:maestro@)   remote_disk -> /scratch:Disk1:bob
 > [  0.000000] (1:@bob) *** Storage info on bob ***
 > [  0.000000] (0:maestro@) *** carl properties ****
 > [  0.000000] (0:maestro@)   remote_disk -> /scratch:Disk1:bob
 > [  0.000000] (1:@bob) *** Storage info on bob ***
-> [  0.000000] (1:@bob) Disk name: Disk1
-> [  0.000000] (1:@bob) Disk name: Disk2
+> [  0.000000] (1:@bob) Disk name: Disk1 (read: 100000000 B/s -- write: 40000000 B/s 
+> [  0.000000] (1:@bob) Disk name: Disk2 (read: 200000000 B/s -- write: 80000000 B/s 
 > [  0.010000] (1:@bob) Wrote 400000 bytes on 'Disk1'
 > [  0.012000] (1:@bob) Read 200000 bytes on 'Disk1'
 > [  0.012000] (1:@bob) *** Get/set data for storage element: Disk1 ***
 > [  0.010000] (1:@bob) Wrote 400000 bytes on 'Disk1'
 > [  0.012000] (1:@bob) Read 200000 bytes on 'Disk1'
 > [  0.012000] (1:@bob) *** Get/set data for storage element: Disk1 ***
index 106da72..78c4115 100644 (file)
@@ -26,17 +26,18 @@ namespace s4u {
  */
 
 class XBT_PUBLIC Disk : public xbt::Extendable<Disk> {
  */
 
 class XBT_PUBLIC Disk : public xbt::Extendable<Disk> {
+  kernel::resource::DiskImpl* const pimpl_;
+  std::string name_;
   friend Engine;
   friend Io;
   friend kernel::resource::DiskImpl;
 
   friend Engine;
   friend Io;
   friend kernel::resource::DiskImpl;
 
-public:
-  explicit Disk(const std::string& name, kernel::resource::DiskImpl* pimpl) : pimpl_(pimpl), name_(name) {}
-
 protected:
   virtual ~Disk() = default;
 
 public:
 protected:
   virtual ~Disk() = default;
 
 public:
+  explicit Disk(const std::string& name, kernel::resource::DiskImpl* pimpl) : pimpl_(pimpl), name_(name) {}
+
   /** @brief Callback signal fired when a new Disk is created */
   static xbt::signal<void(Disk&)> on_creation;
   /** @brief Callback signal fired when a Disk is destroyed */
   /** @brief Callback signal fired when a new Disk is created */
   static xbt::signal<void(Disk&)> on_creation;
   /** @brief Callback signal fired when a Disk is destroyed */
@@ -48,7 +49,8 @@ public:
   std::string const& get_name() const { return name_; }
   /** @brief Retrieves the name of that disk as a C string */
   const char* get_cname() const { return name_.c_str(); }
   std::string const& get_name() const { return name_; }
   /** @brief Retrieves the name of that disk as a C string */
   const char* get_cname() const { return name_.c_str(); }
-
+  double get_read_bandwidth() const;
+  double get_write_bandwidth();
   const std::unordered_map<std::string, std::string>* get_properties() const;
   const char* get_property(const std::string& key) const;
   void set_property(const std::string&, const std::string& value);
   const std::unordered_map<std::string, std::string>* get_properties() const;
   const char* get_property(const std::string& key) const;
   void set_property(const std::string&, const std::string& value);
@@ -62,10 +64,6 @@ public:
   IoPtr write_async(sg_size_t size);
   sg_size_t write(sg_size_t size);
   kernel::resource::DiskImpl* get_impl() const { return pimpl_; }
   IoPtr write_async(sg_size_t size);
   sg_size_t write(sg_size_t size);
   kernel::resource::DiskImpl* get_impl() const { return pimpl_; }
-
-private:
-  kernel::resource::DiskImpl* const pimpl_;
-  std::string name_;
 };
 
 } // namespace s4u
 };
 
 } // namespace s4u
index 7c759a7..18c7035 100644 (file)
@@ -37,10 +37,13 @@ DiskModel::~DiskModel()
 
 DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
                    double read_bw, double write_bw)
 
 DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
                    double read_bw, double write_bw)
-    : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw))), piface_(name, this)
+    : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw)))
+    , piface_(name, this)
+    , read_bw_(read_bw)
+    , write_bw_(write_bw)
 {
   DiskImpl::turn_on();
 {
   DiskImpl::turn_on();
-  XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw, write_bw);
+  XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_, write_bw_);
   constraint_read_  = maxminSystem->constraint_new(this, read_bw);
   constraint_write_ = maxminSystem->constraint_new(this, write_bw);
 }
   constraint_read_  = maxminSystem->constraint_new(this, read_bw);
   constraint_write_ = maxminSystem->constraint_new(this, write_bw);
 }
index c25b0a2..269a360 100644 (file)
@@ -51,6 +51,8 @@ class DiskImpl : public Resource, public surf::PropertyHolder {
   bool currently_destroying_ = false;
   s4u::Host* host_           = nullptr;
   s4u::Disk piface_;
   bool currently_destroying_ = false;
   s4u::Host* host_           = nullptr;
   s4u::Disk piface_;
+  double read_bw_;
+  double write_bw_;
 
 public:
   DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
 
 public:
   DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
@@ -61,6 +63,9 @@ public:
 
   /** @brief Public interface */
   s4u::Disk* get_iface() { return &piface_; }
 
   /** @brief Public interface */
   s4u::Disk* get_iface() { return &piface_; }
+  double get_read_bandwidth() { return read_bw_; }
+  double get_write_bandwidth() { return write_bw_; }
+
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool is_used() override;
 
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool is_used() override;
 
index 562e742..153a65c 100644 (file)
@@ -20,6 +20,16 @@ xbt::signal<void(Disk&)> Disk::on_creation;
 xbt::signal<void(Disk const&)> Disk::on_destruction;
 xbt::signal<void(Disk const&)> Disk::on_state_change;
 
 xbt::signal<void(Disk const&)> Disk::on_destruction;
 xbt::signal<void(Disk const&)> Disk::on_state_change;
 
+double Disk::get_read_bandwidth() const
+{
+  return this->pimpl_->get_read_bandwidth();
+}
+
+double Disk::get_write_bandwidth()
+{
+  return pimpl_->get_write_bandwidth();
+}
+
 Host* Disk::get_host()
 {
   return pimpl_->get_host();
 Host* Disk::get_host()
 {
   return pimpl_->get_host();