From 1d09cf0753b10cbc28ae414f45919ee661da59b1 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Tue, 17 Jul 2018 13:56:33 +0200 Subject: [PATCH] [HostLoad] Add total idle time The 'normal' idle time can (and does) get reset, but it is interesting to know how much a host idled until now in total. --- include/simgrid/plugins/load.h | 1 + src/plugins/host_load.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/simgrid/plugins/load.h b/include/simgrid/plugins/load.h index 734752aa2a..eedabd4150 100644 --- a/include/simgrid/plugins/load.h +++ b/include/simgrid/plugins/load.h @@ -15,6 +15,7 @@ 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_avg_load(sg_host_t host); XBT_PUBLIC double sg_host_get_idle_time(sg_host_t host); +XBT_PUBLIC double sg_host_get_total_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/plugins/host_load.cpp b/src/plugins/host_load.cpp index f584bbad12..4d7f6441b0 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -44,6 +44,7 @@ public: double get_average_load() { return (theor_max_flops_ == 0) ? 0 : computed_flops_ / theor_max_flops_; }; double get_computed_flops() { return computed_flops_; } double get_idle_time() { return idle_time_; } /** Return idle time since last reset */ + double get_total_idle_time() { return total_idle_time_; } /** Return idle time over the whole simulation */ void update(); void reset(); @@ -62,6 +63,7 @@ private: double current_flops_ = 0; double computed_flops_ = 0; double idle_time_ = 0; + double total_idle_time_ = 0; /* This gets never reset */ double theor_max_flops_ = 0; bool was_prev_idle_ = true; /* A host is idle at the beginning */ }; @@ -81,6 +83,7 @@ void HostLoad::update() if (was_prev_idle_) { idle_time_ += (now - last_updated_); + total_idle_time_ += (now - last_updated_); } theor_max_flops_ += current_speed_ * host_->get_core_count() * (now - last_updated_); @@ -219,6 +222,14 @@ double sg_host_get_idle_time(sg_host_t host) return host->extension()->get_idle_time(); } +double sg_host_get_total_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()->get_total_idle_time(); +} + double sg_host_get_computed_flops(sg_host_t host) { xbt_assert(HostLoad::EXTENSION_ID.valid(), -- 2.20.1