Skip to content

Commit 84bde50

Browse files
committed
Merge branch 'topic/timer-gettimeofday' of github.com:jjhursey/ompi into jjhursey-topic/timer-gettimeofday
2 parents 19b2454 + 48d13aa commit 84bde50

File tree

4 files changed

+40
-22
lines changed

4 files changed

+40
-22
lines changed

ompi/mpi/c/wtick.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015-2016 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1516
* $COPYRIGHT$
1617
*
1718
* Additional copyrights may follow
@@ -40,6 +41,12 @@ double MPI_Wtick(void)
4041
{
4142
OPAL_CR_NOOP_PROGRESS();
4243

44+
/*
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+
*/
49+
#if 0
4350
#if OPAL_TIMER_CYCLE_NATIVE
4451
{
4552
opal_timer_t freq = opal_timer_base_get_freq();
@@ -52,6 +59,7 @@ double MPI_Wtick(void)
5259
}
5360
#elif OPAL_TIMER_USEC_NATIVE
5461
return 0.000001;
62+
#endif
5563
#else
5664
/* Otherwise, we already return usec precision. */
5765
return 0.000001;

ompi/mpi/c/wtime.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1516
* $COPYRIGHT$
1617
*
1718
* Additional copyrights may follow
@@ -40,10 +41,17 @@ double MPI_Wtime(void)
4041
{
4142
double wtime;
4243

44+
/*
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+
*/
49+
#if 0
4350
#if OPAL_TIMER_CYCLE_NATIVE
4451
wtime = ((double) opal_timer_base_get_cycles()) / opal_timer_base_get_freq();
4552
#elif OPAL_TIMER_USEC_NATIVE
4653
wtime = ((double) opal_timer_base_get_usec()) / 1000000.0;
54+
#endif
4755
#else
4856
/* Fall back to gettimeofday() if we have nothing else */
4957
struct timeval tv;

opal/mca/timer/linux/timer_linux.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2017 Cisco Systems, Inc. All rights reserved
1213
* $COPYRIGHT$
1314
*
1415
* Additional copyrights may follow
@@ -22,8 +23,6 @@
2223
#include "opal_config.h"
2324
#include <opal/sys/timer.h>
2425

25-
OPAL_DECLSPEC extern opal_timer_t opal_timer_linux_freq;
26-
2726
OPAL_DECLSPEC extern opal_timer_t (*opal_timer_base_get_cycles)(void);
2827
OPAL_DECLSPEC extern opal_timer_t (*opal_timer_base_get_usec)(void);
2928

opal/mca/timer/linux/timer_linux_component.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights
1616
* reserved.
17-
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
17+
* Copyright (c) 2015-2017 Cisco Systems, Inc. All rights reserved
1818
* Copyright (c) 2016 Broadcom Limited. All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -33,23 +33,28 @@
3333
#include "opal/constants.h"
3434
#include "opal/util/show_help.h"
3535

36-
static opal_timer_t opal_timer_base_get_cycles_sys_timer(void);
37-
static opal_timer_t opal_timer_base_get_usec_sys_timer(void);
36+
static opal_timer_t opal_timer_linux_get_cycles_sys_timer(void);
37+
static opal_timer_t opal_timer_linux_get_usec_sys_timer(void);
3838

3939
/**
4040
* Define some sane defaults until we call the _init function.
4141
*/
4242
#if OPAL_HAVE_CLOCK_GETTIME
43-
static opal_timer_t opal_timer_base_get_cycles_clock_gettime(void);
44-
static opal_timer_t opal_timer_base_get_usec_clock_gettime(void);
45-
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_clock_gettime;
46-
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_clock_gettime;
43+
static opal_timer_t opal_timer_linux_get_cycles_clock_gettime(void);
44+
static opal_timer_t opal_timer_linux_get_usec_clock_gettime(void);
45+
46+
opal_timer_t (*opal_timer_base_get_cycles)(void) =
47+
opal_timer_linux_get_cycles_clock_gettime;
48+
opal_timer_t (*opal_timer_base_get_usec)(void) =
49+
opal_timer_linux_get_usec_clock_gettime;
4750
#else
48-
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_sys_timer;
49-
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_sys_timer;
51+
opal_timer_t (*opal_timer_base_get_cycles)(void) =
52+
opal_timer_linux_get_cycles_sys_timer;
53+
opal_timer_t (*opal_timer_base_get_usec)(void) =
54+
opal_timer_linux_get_usec_sys_timer;
5055
#endif /* OPAL_HAVE_CLOCK_GETTIME */
5156

52-
opal_timer_t opal_timer_linux_freq = {0};
57+
static opal_timer_t opal_timer_linux_freq = {0};
5358

5459
static int opal_timer_linux_open(void);
5560

@@ -171,8 +176,8 @@ int opal_timer_linux_open(void)
171176
struct timespec res;
172177
if( 0 == clock_getres(CLOCK_MONOTONIC, &res)) {
173178
opal_timer_linux_freq = 1.e3;
174-
opal_timer_base_get_cycles = opal_timer_base_get_cycles_clock_gettime;
175-
opal_timer_base_get_usec = opal_timer_base_get_usec_clock_gettime;
179+
opal_timer_base_get_cycles = opal_timer_linux_get_cycles_clock_gettime;
180+
opal_timer_base_get_usec = opal_timer_linux_get_usec_clock_gettime;
176181
return ret;
177182
}
178183
#else
@@ -181,13 +186,13 @@ int opal_timer_linux_open(void)
181186
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC) */
182187
}
183188
ret = opal_timer_linux_find_freq();
184-
opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer;
185-
opal_timer_base_get_usec = opal_timer_base_get_usec_sys_timer;
189+
opal_timer_base_get_cycles = opal_timer_linux_get_cycles_sys_timer;
190+
opal_timer_base_get_usec = opal_timer_linux_get_usec_sys_timer;
186191
return ret;
187192
}
188193

189194
#if OPAL_HAVE_CLOCK_GETTIME
190-
opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
195+
opal_timer_t opal_timer_linux_get_usec_clock_gettime(void)
191196
{
192197
struct timespec tp = {.tv_sec = 0, .tv_nsec = 0};
193198

@@ -196,7 +201,7 @@ opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
196201
return (tp.tv_sec * 1e6 + tp.tv_nsec/1000);
197202
}
198203

199-
opal_timer_t opal_timer_base_get_cycles_clock_gettime(void)
204+
opal_timer_t opal_timer_linux_get_cycles_clock_gettime(void)
200205
{
201206
struct timespec tp = {.tv_sec = 0, .tv_nsec = 0};
202207

@@ -206,7 +211,7 @@ opal_timer_t opal_timer_base_get_cycles_clock_gettime(void)
206211
}
207212
#endif /* OPAL_HAVE_CLOCK_GETTIME */
208213

209-
opal_timer_t opal_timer_base_get_cycles_sys_timer(void)
214+
opal_timer_t opal_timer_linux_get_cycles_sys_timer(void)
210215
{
211216
#if OPAL_HAVE_SYS_TIMER_GET_CYCLES
212217
return opal_sys_timer_get_cycles();
@@ -216,7 +221,7 @@ opal_timer_t opal_timer_base_get_cycles_sys_timer(void)
216221
}
217222

218223

219-
opal_timer_t opal_timer_base_get_usec_sys_timer(void)
224+
opal_timer_t opal_timer_linux_get_usec_sys_timer(void)
220225
{
221226
#if OPAL_HAVE_SYS_TIMER_GET_CYCLES
222227
/* freq is in MHz, so this gives usec */
@@ -230,5 +235,3 @@ opal_timer_t opal_timer_base_get_freq(void)
230235
{
231236
return opal_timer_linux_freq * 1000000;
232237
}
233-
234-

0 commit comments

Comments
 (0)