From 71e92a54731567b2ae3decbd612e60e253098e3c Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 10 Sep 2018 13:02:22 +0200 Subject: [PATCH] move smpi_mpi_wtime near to the other time-related functions --- src/smpi/internals/smpi_bench.cpp | 26 +++++++++++++++++++++++++- src/smpi/internals/smpi_global.cpp | 23 ----------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 85191c7329..302050337c 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -28,6 +28,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi, "Logging specific to SMPI (benchmarking)"); +static simgrid::config::Flag smpi_wtime_sleep("smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", + 0.0); + double smpi_cpu_threshold = -1; double smpi_host_speed; @@ -177,7 +180,7 @@ void smpi_bench_end() smpi_total_benched_time += xbt_os_timer_elapsed(timer); } -/* Private sleep function used by smpi_sleep() and smpi_usleep() */ +/* Private sleep function used by smpi_sleep(), smpi_usleep() and friends */ static unsigned int private_sleep(double secs) { smpi_bench_end(); @@ -273,6 +276,27 @@ unsigned long long smpi_rastro_timestamp () return static_cast(sec) * smpi_rastro_resolution() + pre; } +double smpi_mpi_wtime() +{ + double time; + if (smpi_process()->initialized() && not smpi_process()->finalized() && not smpi_process()->sampling()) { + smpi_bench_end(); + time = SIMIX_get_clock(); + // to avoid deadlocks if used as a break condition, such as + // while (MPI_Wtime(...) < time_limit) { + // .... + // } + // because the time will not normally advance when only calls to MPI_Wtime + // are made -> deadlock (MPI_Wtime never reaches the time limit) + if (smpi_wtime_sleep > 0) + simcall_process_sleep(smpi_wtime_sleep); + smpi_bench_begin(); + } else { + time = SIMIX_get_clock(); + } + return time; +} + /* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/ namespace { class SampleLocation : public std::string { diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index e75aef976d..aaef32d548 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -95,8 +95,6 @@ MPI_Errhandler *MPI_ERRHANDLER_NULL = nullptr; // No instance gets manually created; check also the smpirun.in script as // this default name is used there as well (when the tag is generated). static const std::string smpi_default_instance_name("smpirun"); -static simgrid::config::Flag smpi_wtime_sleep( - "smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0); static simgrid::config::Flag smpi_init_sleep( "smpi/init", "Time to inject inside a call to MPI_Init", 0.0); @@ -745,24 +743,3 @@ void smpi_mpi_init() { if(smpi_init_sleep > 0) simcall_process_sleep(smpi_init_sleep); } - -double smpi_mpi_wtime(){ - double time; - if (smpi_process()->initialized() != 0 && smpi_process()->finalized() == 0 && smpi_process()->sampling() == 0) { - smpi_bench_end(); - time = SIMIX_get_clock(); - // to avoid deadlocks if used as a break condition, such as - // while (MPI_Wtime(...) < time_limit) { - // .... - // } - // because the time will not normally advance when only calls to MPI_Wtime - // are made -> deadlock (MPI_Wtime never reaches the time limit) - if(smpi_wtime_sleep > 0) - simcall_process_sleep(smpi_wtime_sleep); - smpi_bench_begin(); - } else { - time = SIMIX_get_clock(); - } - return time; -} - -- 2.20.1