Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions opal/mca/timer/linux/timer_linux_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
* Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2016 Broadcom Limited. All rights reserved.
Expand Down Expand Up @@ -155,6 +155,10 @@ static int opal_timer_linux_find_freq(void)

fclose(fp);

/* convert the timer frequency to MHz to avoid an extra operation when
* converting from cycles to usec */
opal_timer_linux_freq /= 1000000;

return OPAL_SUCCESS;
}

Expand All @@ -166,7 +170,7 @@ int opal_timer_linux_open(void)
#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;
opal_timer_linux_freq = 1.e3;
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;
Expand Down Expand Up @@ -215,16 +219,16 @@ opal_timer_t opal_timer_base_get_cycles_sys_timer(void)
opal_timer_t opal_timer_base_get_usec_sys_timer(void)
{
#if OPAL_HAVE_SYS_TIMER_GET_CYCLES
/* freq is in Hz, so this gives usec */
return opal_sys_timer_get_cycles() * 1000000 / opal_timer_linux_freq;
/* freq is in MHz, so this gives usec */
return opal_sys_timer_get_cycles() / opal_timer_linux_freq;
#else
return 0;
#endif
}

opal_timer_t opal_timer_base_get_freq(void)
{
return opal_timer_linux_freq;
return opal_timer_linux_freq * 1000000;
}