1
1

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.
Этот коммит содержится в:
George Bosilca 2016-09-23 21:51:34 -04:00
родитель 45dcf1f5d7
Коммит 066370202d

Просмотреть файл

@ -3,7 +3,7 @@
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2014 The University of Tennessee and The University
* Copyright (c) 2004-2016 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -31,11 +31,15 @@
#include "opal/mca/timer/base/base.h"
#include "opal/mca/timer/linux/timer_linux.h"
#include "opal/constants.h"
#include "opal/util/show_help.h"
static opal_timer_t opal_timer_base_get_cycles_sys_timer(void);
static opal_timer_t opal_timer_base_get_usec_sys_timer(void);
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
/**
* Define some sane defaults until we call the _init function.
*/
#if OPAL_HAVE_CLOCK_GETTIME
static opal_timer_t opal_timer_base_get_cycles_clock_gettime(void);
static opal_timer_t opal_timer_base_get_usec_clock_gettime(void);
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_clock_gettime;
@ -43,7 +47,7 @@ opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_clock_
#else
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_sys_timer;
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_sys_timer;
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
#endif /* OPAL_HAVE_CLOCK_GETTIME */
opal_timer_t opal_timer_linux_freq = {0};
@ -159,7 +163,7 @@ int opal_timer_linux_open(void)
int ret = OPAL_SUCCESS;
if(mca_timer_base_monotonic) {
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC)
struct timespec res;
if( 0 == clock_getres(CLOCK_MONOTONIC, &res)) {
opal_timer_linux_freq = 1.e9;
@ -170,9 +174,9 @@ int opal_timer_linux_open(void)
#else
#if (0 == OPAL_TIMER_MONOTONIC)
/* Monotonic time requested but cannot be found. Complain! */
opal_show_help("help-opal-timer-linux.txt", "monotonic not supported", 1);
opal_show_help("help-opal-timer-linux.txt", "monotonic not supported", true);
#endif /* (0 == OPAL_TIMER_MONOTONIC) */
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC) */
}
ret = opal_timer_linux_find_freq();
opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer;
@ -180,7 +184,7 @@ int opal_timer_linux_open(void)
return ret;
}
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
#if OPAL_HAVE_CLOCK_GETTIME
opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
{
struct timespec tp;
@ -200,7 +204,7 @@ opal_timer_t opal_timer_base_get_cycles_clock_gettime(void)
}
return 0;
}
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
#endif /* OPAL_HAVE_CLOCK_GETTIME */
opal_timer_t opal_timer_base_get_cycles_sys_timer(void)
{