File tree 2 files changed +28
-5
lines changed
2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 25
25
#include <sys/time.h>
26
26
#endif
27
27
#include <stdio.h>
28
+ #ifdef HAVE_TIME_H
29
+ #include <time.h>
30
+ #endif
28
31
29
32
#include MCA_timer_IMPLEMENTATION_HEADER
30
33
#include "ompi/mpi/c/bindings.h"
@@ -43,8 +46,7 @@ double MPI_Wtick(void)
43
46
44
47
/*
45
48
* See https://github.com/open-mpi/ompi/issues/3003
46
- * For now we are forcing the use of gettimeofday() until we find a
47
- * more portable solution.
49
+ * to get an idea what's going on here.
48
50
*/
49
51
#if 0
50
52
#if OPAL_TIMER_CYCLE_NATIVE
@@ -60,8 +62,20 @@ double MPI_Wtick(void)
60
62
#elif OPAL_TIMER_USEC_NATIVE
61
63
return 0.000001 ;
62
64
#endif
65
+ #else
66
+ #if defined(__linux__ ) && OPAL_HAVE_CLOCK_GETTIME
67
+ struct timespec spec ;
68
+ double wtick = 0.0 ;
69
+ if (0 == clock_getres (CLOCK_MONOTONIC , & spec )){
70
+ wtick = spec .tv_sec + spec .tv_nsec * 1.0e-09 ;
71
+ } else {
72
+ /* guess */
73
+ wtick = 1.0e-09 ;
74
+ }
75
+ return wtick ;
63
76
#else
64
77
/* Otherwise, we already return usec precision. */
65
78
return 0.000001 ;
66
79
#endif
80
+ #endif
67
81
}
Original file line number Diff line number Diff line change 25
25
#include <sys/time.h>
26
26
#endif
27
27
#include <stdio.h>
28
+ #ifdef HAVE_TIME_H
29
+ #include <time.h>
30
+ #endif /* HAVE_TIME_H */
28
31
29
32
#include MCA_timer_IMPLEMENTATION_HEADER
30
33
#include "ompi/mpi/c/bindings.h"
@@ -42,22 +45,28 @@ double MPI_Wtime(void)
42
45
double wtime ;
43
46
44
47
/*
45
- * See https://github.com/open-mpi/ompi/issues/3003
46
- * For now we are forcing the use of gettimeofday() until we find a
47
- * more portable solution.
48
+ * See https://github.com/open-mpi/ompi/issues/3003 to find out
49
+ * what's happening here.
48
50
*/
49
51
#if 0
50
52
#if OPAL_TIMER_CYCLE_NATIVE
51
53
wtime = ((double ) opal_timer_base_get_cycles ()) / opal_timer_base_get_freq ();
52
54
#elif OPAL_TIMER_USEC_NATIVE
53
55
wtime = ((double ) opal_timer_base_get_usec ()) / 1000000.0 ;
54
56
#endif
57
+ #else
58
+ #if defined(__linux__ ) && OPAL_HAVE_CLOCK_GETTIME
59
+ struct timespec tp = {.tv_sec = 0 , .tv_nsec = 0 };
60
+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
61
+ wtime = tp .tv_sec ;
62
+ wtime += tp .tv_nsec /1.0e+9 ;
55
63
#else
56
64
/* Fall back to gettimeofday() if we have nothing else */
57
65
struct timeval tv ;
58
66
gettimeofday (& tv , NULL );
59
67
wtime = tv .tv_sec ;
60
68
wtime += (double )tv .tv_usec / 1000000.0 ;
69
+ #endif
61
70
#endif
62
71
63
72
OPAL_CR_NOOP_PROGRESS ();
You can’t perform that action at this time.
0 commit comments