From 0a450bbc6181cf8aa9af5c4190cf91fa85ef4df6 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Thu, 15 Feb 2018 15:08:19 +0100 Subject: [PATCH] [DVFS] Add function sg_host_get_idle_time(host) --- include/simgrid/plugins/load.h | 1 + src/surf/plugins/host_load.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/simgrid/plugins/load.h b/include/simgrid/plugins/load.h index 3d1c940f7b..2fb2a94c89 100644 --- a/include/simgrid/plugins/load.h +++ b/include/simgrid/plugins/load.h @@ -14,6 +14,7 @@ SG_BEGIN_DECL() XBT_PUBLIC(void) sg_host_load_plugin_init(); XBT_PUBLIC(double) sg_host_get_current_load(sg_host_t host); +XBT_PUBLIC(double) sg_host_get_idle_time(sg_host_t host); XBT_PUBLIC(double) sg_host_get_computed_flops(sg_host_t host); XBT_PUBLIC(void) sg_host_load_reset(sg_host_t host); diff --git a/src/surf/plugins/host_load.cpp b/src/surf/plugins/host_load.cpp index 6845b07130..f353661d25 100644 --- a/src/surf/plugins/host_load.cpp +++ b/src/surf/plugins/host_load.cpp @@ -37,6 +37,7 @@ public: double getCurrentLoad(); double getComputedFlops(); double getAverageLoad(); + double getIdleTime(); void update(); void reset(); @@ -86,6 +87,13 @@ double HostLoad::getCurrentLoad() return current_flops / static_cast(host->getSpeed() * host->getCoreCount()); } +/** + * Return idle time since last reset + */ +double HostLoad::getIdleTime() { + return idle_time; +} + double HostLoad::getAverageLoad() { return getComputedFlops() / (host->getSpeed() * host->getCoreCount() * (surf_get_clock() - last_reset)); @@ -177,6 +185,18 @@ double sg_host_get_current_load(sg_host_t host) return host->extension()->getCurrentLoad(); } +/** @brief Returns the time this host was idle since the last reset + * + * See also @ref plugin_load + */ +double sg_host_get_idle_time(sg_host_t host) +{ + xbt_assert(HostLoad::EXTENSION_ID.valid(), + "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + + return host->extension()->getIdleTime(); +} + double sg_host_get_computed_flops(sg_host_t host) { xbt_assert(HostLoad::EXTENSION_ID.valid(), -- 2.20.1