Skip to content

Commit

Permalink
Always use the best timer available
Browse files Browse the repository at this point in the history
If we have better timer than clock_gettime use it, even if it an
assembly timer.
  • Loading branch information
bosilca committed Sep 23, 2016
1 parent 93fa94f commit 45dcf1f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions opal/mca/timer/linux/timer_linux_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
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
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
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;
opal_timer_t (*opal_timer_base_get_usec)(void) = opal_timer_base_get_usec_clock_gettime;
#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 */
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */

opal_timer_t opal_timer_linux_freq = {0};

Expand Down Expand Up @@ -159,7 +159,7 @@ int opal_timer_linux_open(void)
int ret = OPAL_SUCCESS;

if(mca_timer_base_monotonic) {
#if OPAL_HAVE_CLOCK_GETTIME
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
struct timespec res;
if( 0 == clock_getres(CLOCK_MONOTONIC, &res)) {
opal_timer_linux_freq = 1.e9;
Expand All @@ -172,15 +172,15 @@ int opal_timer_linux_open(void)
/* Monotonic time requested but cannot be found. Complain! */
opal_show_help("help-opal-timer-linux.txt", "monotonic not supported", 1);
#endif /* (0 == OPAL_TIMER_MONOTONIC) */
#endif
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
}
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;
}

#if OPAL_HAVE_CLOCK_GETTIME
#if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES)
opal_timer_t opal_timer_base_get_usec_clock_gettime(void)
{
struct timespec tp;
Expand All @@ -200,7 +200,7 @@ opal_timer_t opal_timer_base_get_cycles_clock_gettime(void)
}
return 0;
}
#endif /* OPAL_HAVE_CLOCK_GETTIME */
#endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */

opal_timer_t opal_timer_base_get_cycles_sys_timer(void)
{
Expand Down

2 comments on commit 45dcf1f

@ggouaillardet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bosilca is the assembly timer always monotonic ?

@bosilca
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the timer. Mine was, but I noticed that I might have screwed up the RDTSC. I'll push a fix soon.

Please sign in to comment.