Various cleanups.
Этот коммит содержится в:
родитель
00300f464d
Коммит
5277fd5aa2
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
OPAL_DECLSPEC extern opal_timer_t opal_timer_linux_freq;
|
OPAL_DECLSPEC extern opal_timer_t opal_timer_linux_freq;
|
||||||
|
|
||||||
OPAL_DECLSPEC extern opal_timer_t *opal_timer_base_get_cycles(void);
|
OPAL_DECLSPEC extern opal_timer_t (*opal_timer_base_get_cycles)(void);
|
||||||
OPAL_DECLSPEC extern opal_timer_t *opal_timer_base_get_usec(void);
|
OPAL_DECLSPEC extern opal_timer_t (*opal_timer_base_get_usec)(void);
|
||||||
|
|
||||||
OPAL_DECLSPEC extern opal_timer_t opal_timer_base_get_freq(void);
|
OPAL_DECLSPEC extern opal_timer_t opal_timer_base_get_freq(void);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "opal/mca/timer/timer.h"
|
#include "opal/mca/timer/timer.h"
|
||||||
|
#include "opal/mca/timer/base/base.h"
|
||||||
#include "opal/mca/timer/linux/timer_linux.h"
|
#include "opal/mca/timer/linux/timer_linux.h"
|
||||||
#include "opal/constants.h"
|
#include "opal/constants.h"
|
||||||
|
|
||||||
@ -32,11 +33,11 @@ static opal_timer_t opal_timer_base_get_usec_sys_timer(void);
|
|||||||
#if OPAL_HAVE_CLOCK_GETTIME
|
#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_cycles_clock_gettime(void);
|
||||||
static opal_timer_t opal_timer_base_get_usec_clock_gettime(void);
|
static opal_timer_t opal_timer_base_get_usec_clock_gettime(void);
|
||||||
opal_timer_t *opal_timer_base_get_cycles = opal_timer_base_get_cycles_clock_gettime;
|
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_clock_gettime;
|
||||||
opal_timer_t *opal_timer_base_get_usec = opal_timer_base_get_usec_clock_gettime;
|
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_clock_gettime;
|
||||||
#else
|
#else
|
||||||
opal_timer_t *opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer;
|
opal_timer_t (*opal_timer_base_get_cycles)(void) = opal_timer_base_get_cycles_sys_timer;
|
||||||
opal_timer_t *opal_timer_base_get_usec = opal_timer_base_get_usec_sys_timer;
|
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_sys_timer;
|
||||||
#endif /* OPAL_HAVE_CLOCK_GETTIME */
|
#endif /* OPAL_HAVE_CLOCK_GETTIME */
|
||||||
|
|
||||||
opal_timer_t opal_timer_linux_freq;
|
opal_timer_t opal_timer_linux_freq;
|
||||||
@ -146,31 +147,33 @@ static int opal_timer_linux_find_freq(void)
|
|||||||
int opal_timer_linux_open(void)
|
int opal_timer_linux_open(void)
|
||||||
{
|
{
|
||||||
int ret = OPAL_SUCCESS;
|
int ret = OPAL_SUCCESS;
|
||||||
#if !OPAL_HAVE_CLOCK_GETTIME
|
|
||||||
ret = opal_timer_linux_find_freq();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(mca_timer_base_monotonic) {
|
if(mca_timer_base_monotonic) {
|
||||||
#if OPAL_HAVE_CLOCK_GETTIME
|
#if OPAL_HAVE_CLOCK_GETTIME
|
||||||
struct timespec *res;
|
struct timespec res;
|
||||||
if( 0 == clock_getres(CLOCK_MONOTONIC, &res)) {
|
if( 0 == clock_getres(CLOCK_MONOTONIC, &res)) {
|
||||||
opal_timer_linux_freq = res.tv_nsec;
|
opal_timer_linux_freq = res.tv_nsec;
|
||||||
return ret;
|
opal_timer_base_get_cycles = opal_timer_base_get_cycles_clock_gettime;
|
||||||
}
|
opal_timer_base_get_usec = opal_timer_base_get_usec_clock_gettime;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#if (0 == OPAL_TIMER_MONOTONIC)
|
#if (0 == OPAL_TIMER_MONOTONIC)
|
||||||
/* Monotonic time requested but cannot be found. Complain! */
|
/* 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", 1);
|
||||||
#endif /* (0 == OPAL_TIMER_MONOTONIC) */
|
#endif /* (0 == OPAL_TIMER_MONOTONIC) */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
ret = opal_timer_linux_find_freq();
|
||||||
|
opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer;
|
||||||
|
opal_timer_base_get_usec = opal_timer_base_get_usec_sys_timer;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OPAL_HAVE_CLOCK_GETTIME
|
#if OPAL_HAVE_CLOCK_GETTIME
|
||||||
opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
|
opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
|
||||||
{
|
{
|
||||||
struct timespec *tp;
|
struct timespec tp;
|
||||||
|
|
||||||
if( 0 == clock_gettime(CLOCK_MONOTONIC, &tp) ) {
|
if( 0 == clock_gettime(CLOCK_MONOTONIC, &tp) ) {
|
||||||
return (tp.tv_sec * 1e9 + tp.tv_nsec);
|
return (tp.tv_sec * 1e9 + tp.tv_nsec);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user