Skip to content

Commit a33f63d

Browse files
committed
On Windows use the high performance timers ... differently or lose
data in the conversion. This commit was SVN r11441.
1 parent 0e31728 commit a33f63d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

opal/mca/timer/windows/timer_windows.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,22 @@ extern "C" {
2828
#endif
2929

3030
OPAL_DECLSPEC extern opal_timer_t opal_timer_windows_freq;
31+
OPAL_DECLSPEC extern opal_timer_t opal_timer_windows_start;
3132

3233
static inline opal_timer_t
3334
opal_timer_base_get_cycles(void)
3435
{
3536
LARGE_INTEGER now;
3637
QueryPerformanceCounter( &now );
37-
return now.QuadPart;
38+
return (now.QuadPart - opal_timer_windows_start);
3839
}
3940

4041

4142
static inline opal_timer_t
4243
opal_timer_base_get_usec(void)
4344
{
44-
#if OPAL_HAVE_SYS_TIMER_GET_CYCLES
4545
/* freq is in Hz, so this gives usec */
4646
return opal_sys_timer_get_cycles() * 1000000 / opal_timer_windows_freq;
47-
#else
48-
return 0;
49-
#endif
5047
}
5148

5249

opal/mca/timer/windows/timer_windows_component.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "opal/constants.h"
2424

2525
opal_timer_t opal_timer_windows_freq;
26+
opal_timer_t opal_timer_windows_start;
2627

2728
static int opal_timer_windows_open(void);
2829

@@ -58,8 +59,11 @@ opal_timer_windows_open(void)
5859
{
5960
LARGE_INTEGER now;
6061

61-
QueryPerformanceFrequency( &now );
62-
opal_timer_windows_freq = now.QuadPart;
63-
62+
if( 0 != QueryPerformanceFrequency( &now ) ) {
63+
opal_timer_windows_freq = now.QuadPart;
64+
QueryPerformanceCounter( &now );
65+
opal_timer_windows_start = now.QuadPart;
66+
return OPAL_SUCCESS;
67+
}
6468
return OPAL_SUCCESS;
6569
}

0 commit comments

Comments
 (0)