Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s4u::Host->getLoad() returns the achieved speed in flops/s
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Dec 2017 23:44:54 +0000 (00:44 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Dec 2017 23:44:54 +0000 (00:44 +0100)
ChangeLog
include/simgrid/s4u/Host.hpp
src/s4u/s4u_host.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index 0df14da..83c32a9 100644 (file)
--- 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
index 6743001..889419c 100644 (file)
@@ -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<std::string, Storage*>* mounts = nullptr; // caching
index da99e12..9b4f49a 100644 (file)
@@ -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
index f61c84f..9c92c1d 100644 (file)
@@ -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_;
index b29e7c4..507c7ce 100644 (file)
@@ -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 */