From 7b2fe943182bff869b3ae80333a4f2d2bf0fb7cf Mon Sep 17 00:00:00 2001 From: Henri Casanova Date: Wed, 7 May 2014 17:07:13 -1000 Subject: [PATCH 1/1] Added a smpi_usleep function and usleep -> smpi_usleep macro --- include/smpi/smpi.h | 2 ++ src/smpi/smpi_bench.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index c520980c0c..f9ebc00b78 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -7,6 +7,7 @@ #ifndef SMPI_H #define SMPI_H +#include #include #include #include @@ -708,6 +709,7 @@ XBT_PUBLIC(int) smpi_get_host_nb_pstates(void); XBT_PUBLIC(void) smpi_set_host_power_peak_at(int pstate_index); XBT_PUBLIC(double) smpi_get_host_consumed_energy(void); +XBT_PUBLIC(int) smpi_usleep(useconds_t usecs); XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs); XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, void* tz); XBT_PUBLIC(unsigned long long) smpi_rastro_resolution (void); diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 2cb5bb204a..15fdb676a4 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -227,6 +227,25 @@ unsigned int smpi_sleep(unsigned int secs) return secs; } +int smpi_usleep(useconds_t usecs) +{ + smx_action_t action; + + smpi_bench_end(); + + double flops = (double) (usecs/1000000.0)*simcall_host_get_speed(SIMIX_host_self()); + XBT_DEBUG("Sleep for: %f flops", flops); + action = simcall_host_execute("computation", SIMIX_host_self(), flops, 1, 0, 0); + #ifdef HAVE_TRACING + simcall_set_category (action, TRACE_internal_smpi_get_category()); + #endif + simcall_host_execution_wait(action); + + smpi_bench_begin(); + return 0; +} + + int smpi_gettimeofday(struct timeval *tv, void* tz) { double now; -- 2.20.1