Skip to content

Commit 2d8482c

Browse files
committed
timer: hack use of clock_gettime
better solution needed later workaround for #3003 Signed-off-by: Howard Pritchard <[email protected]>
1 parent 84bde50 commit 2d8482c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ompi/mpi/c/wtick.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ double MPI_Wtick(void)
6060
#elif OPAL_TIMER_USEC_NATIVE
6161
return 0.000001;
6262
#endif
63+
#else
64+
#if defined(__linux__) && OPAL_HAVE_CLOCK_GETTIME
65+
/* QAD no call clock_getres */
66+
return 1.0e-09;
6367
#else
6468
/* Otherwise, we already return usec precision. */
6569
return 0.000001;
6670
#endif
71+
#endif
6772
}

ompi/mpi/c/wtime.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <sys/time.h>
2626
#endif
2727
#include <stdio.h>
28+
#ifdef HAVE_TIME_H
29+
#include <time.h>
30+
#endif /* HAVE_TIME_H */
2831

2932
#include MCA_timer_IMPLEMENTATION_HEADER
3033
#include "ompi/mpi/c/bindings.h"
@@ -52,12 +55,18 @@ double MPI_Wtime(void)
5255
#elif OPAL_TIMER_USEC_NATIVE
5356
wtime = ((double) opal_timer_base_get_usec()) / 1000000.0;
5457
#endif
58+
#else
59+
#if defined(__linux__) && OPAL_HAVE_CLOCK_GETTIME
60+
struct timespec tp = {.tv_sec = 0, .tv_nsec = 0};
61+
(void) clock_gettime(CLOCK_MONOTONIC, &tp);
62+
return (tp.tv_sec + tp.tv_nsec/1.0e+9);
5563
#else
5664
/* Fall back to gettimeofday() if we have nothing else */
5765
struct timeval tv;
5866
gettimeofday(&tv, NULL);
5967
wtime = tv.tv_sec;
6068
wtime += (double)tv.tv_usec / 1000000.0;
69+
#endif
6170
#endif
6271

6372
OPAL_CR_NOOP_PROGRESS();

0 commit comments

Comments
 (0)