From a4f850af455f783fefb0a719eef15d4d9dba2852 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 10 Dec 2017 00:44:54 +0100 Subject: [PATCH] s4u::Host->getLoad() returns the achieved speed in flops/s --- ChangeLog | 1 + include/simgrid/s4u/Host.hpp | 3 +++ src/s4u/s4u_host.cpp | 5 +++++ src/surf/surf_interface.cpp | 6 ++++++ src/surf/surf_interface.hpp | 3 +++ 5 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0df14dad50..83c32a949b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ SimGrid (3.18) NOT RELEASED YET (target: December 24 2017) - s4u::onDeadlock() signal, run before stopping the simulation. - s4u::Exec: asynchronous executions (abstraction of background threads) + - s4u::Host->getLoad() returns the achieved speed in flops/s S4U API changes - Link::name() is deprecated and will be removed in v3.21, use diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 6743001dbc..889419c1be 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -113,6 +113,9 @@ public: */ void execute(double flops); + /** @brief Returns the current computation load (in flops per second) */ + double getLoad(); + private: simgrid::xbt::string name_{"noname"}; std::unordered_map* mounts = nullptr; // caching diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index da99e12394..9b4f49ac65 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -261,5 +261,10 @@ void Host::execute(double flops) simcall_execution_wait(s); } +double Host::getLoad() +{ + return this->pimpl_cpu->getLoad(); +} + } // namespace simgrid } // namespace s4u diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index f61c84fb41..9c92c1da01 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -8,6 +8,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/sg_config.h" #include "src/instr/instr_private.hpp" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals +#include "src/kernel/lmm/maxmin.hpp" // Constraint #include "src/kernel/routing/NetPoint.hpp" #include "src/surf/HostImpl.hpp" #include "xbt/utility.hpp" @@ -540,6 +541,11 @@ void Resource::turnOff() isOn_ = false; } +double Resource::getLoad() +{ + return constraint_->get_usage(); +} + Model* Resource::model() const { return model_; diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index b29e7c4936..507c7ce916 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -433,6 +433,9 @@ public: /** @brief Check if the current Resource is used (if it currently serves an action) */ virtual bool isUsed()=0; + /** @brief returns the current load (in flops per second, byte per second or similar) */ + virtual double getLoad(); + /** @brief Check if the current Resource is active */ virtual bool isOn() const; /** @brief Check if the current Resource is shut down */ -- 2.20.1