Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
attempt to fix en issue when timing functions are called before initialization
[simgrid.git] / src / smpi / internals / smpi_bench.cpp
index 702ec1a..8eac4e7 100644 (file)
@@ -207,7 +207,7 @@ int smpi_nanosleep(const struct timespec* tp, struct timespec* t)
 
 int smpi_gettimeofday(struct timeval* tv, struct timezone* tz)
 {
 
 int smpi_gettimeofday(struct timeval* tv, struct timezone* tz)
 {
-  if (not smpi_process())
+  if (not smpi_process()->initialized() || smpi_process()->finalized() || smpi_process()->sampling())
     return gettimeofday(tv, tz);
 
   smpi_bench_end();
     return gettimeofday(tv, tz);
 
   smpi_bench_end();
@@ -233,7 +233,7 @@ int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp)
     errno = EFAULT;
     return -1;
   }
     errno = EFAULT;
     return -1;
   }
-  if (not smpi_process())
+  if (not smpi_process()->initialized() || smpi_process()->finalized() || smpi_process()->sampling())
     return clock_gettime(clk_id, tp);
   //there is only one time in SMPI, so clk_id is ignored.
   smpi_bench_end();
     return clock_gettime(clk_id, tp);
   //there is only one time in SMPI, so clk_id is ignored.
   smpi_bench_end();