Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move smpi_mpi_wtime near to the other time-related functions
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 10 Sep 2018 11:02:22 +0000 (13:02 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 10 Sep 2018 11:02:22 +0000 (13:02 +0200)
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_global.cpp

index 85191c7..3020503 100644 (file)
@@ -28,6 +28,9 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi, "Logging specific to SMPI (benchmarking)");
 
+static simgrid::config::Flag<double> 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<unsigned long long>(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 {
index e75aef9..aaef32d 100644 (file)
@@ -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 <actor> tag is generated).
 static const std::string smpi_default_instance_name("smpirun");
-static simgrid::config::Flag<double> smpi_wtime_sleep(
-  "smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0);
 static simgrid::config::Flag<double> 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;
-}
-