Skip to content

Commit 0663702

Browse files
committed
Support non-monotonic assembly timers.
If monotonic support has been required by the runtime and the assembly timers are unable to provide it, fall back to clock_gettime.
1 parent 45dcf1f commit 0663702

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

opal/mca/timer/linux/timer_linux_component.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2014 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -31,19 +31,23 @@
3131
#include "opal/mca/timer/base/base.h"
3232
#include "opal/mca/timer/linux/timer_linux.h"
3333
#include "opal/constants.h"
34+
#include "opal/util/show_help.h"
3435

3536
static opal_timer_t opal_timer_base_get_cycles_sys_timer(void);
3637
static opal_timer_t opal_timer_base_get_usec_sys_timer(void);
3738

38-
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
39+
/**
40+
* Define some sane defaults until we call the _init function.
41+
*/
42+
#if OPAL_HAVE_CLOCK_GETTIME
3943
static opal_timer_t opal_timer_base_get_cycles_clock_gettime(void);
4044
static opal_timer_t opal_timer_base_get_usec_clock_gettime(void);
4145
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_clock_gettime;
4246
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_clock_gettime;
4347
#else
4448
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_sys_timer;
4549
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_sys_timer;
46-
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
50+
#endif /* OPAL_HAVE_CLOCK_GETTIME */
4751

4852
opal_timer_t opal_timer_linux_freq = {0};
4953

@@ -159,7 +163,7 @@ int opal_timer_linux_open(void)
159163
int ret = OPAL_SUCCESS;
160164

161165
if(mca_timer_base_monotonic) {
162-
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
166+
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC)
163167
struct timespec res;
164168
if( 0 == clock_getres(CLOCK_MONOTONIC, &res)) {
165169
opal_timer_linux_freq = 1.e9;
@@ -170,17 +174,17 @@ int opal_timer_linux_open(void)
170174
#else
171175
#if (0 == OPAL_TIMER_MONOTONIC)
172176
/* Monotonic time requested but cannot be found. Complain! */
173-
opal_show_help("help-opal-timer-linux.txt", "monotonic not supported", 1);
177+
opal_show_help("help-opal-timer-linux.txt", "monotonic not supported", true);
174178
#endif /* (0 == OPAL_TIMER_MONOTONIC) */
175-
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
179+
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC) */
176180
}
177181
ret = opal_timer_linux_find_freq();
178182
opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer;
179183
opal_timer_base_get_usec = opal_timer_base_get_usec_sys_timer;
180184
return ret;
181185
}
182186

183-
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
187+
#if OPAL_HAVE_CLOCK_GETTIME
184188
opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
185189
{
186190
struct timespec tp;
@@ -200,7 +204,7 @@ opal_timer_t opal_timer_base_get_cycles_clock_gettime(void)
200204
}
201205
return 0;
202206
}
203-
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
207+
#endif /* OPAL_HAVE_CLOCK_GETTIME */
204208

205209
opal_timer_t opal_timer_base_get_cycles_sys_timer(void)
206210
{

0 commit comments

Comments
 (0)