-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reenable high accuracy timers #285
Changes from 8 commits
e277599
18a916f
5f49a11
d4edd09
7f191f1
766cfec
b5574c1
1877dfd
b7fa0e3
2616848
fb44b03
43901fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana | ||
* University Research and Technology | ||
* Corporation. All rights reserved. | ||
* Copyright (c) 2004-2005 The University of Tennessee and The University | ||
* Copyright (c) 2004-2014 The University of Tennessee and The University | ||
* of Tennessee Research Foundation. All rights | ||
* reserved. | ||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, | ||
|
@@ -25,29 +25,32 @@ typedef uint64_t opal_timer_t; | |
|
||
#if OPAL_GCC_INLINE_ASSEMBLY | ||
|
||
#if 0 | ||
/** | ||
* http://www.intel.com/content/www/us/en/intelligent-systems/embedded-systems-training/ia-32-ia-64-benchmark-code-execution-paper.html | ||
*/ | ||
static inline opal_timer_t | ||
opal_sys_timer_get_cycles(void) | ||
{ | ||
opal_timer_t ret; | ||
|
||
__asm__ __volatile__("rdtsc" : "=A"(ret)); | ||
|
||
return ret; | ||
} | ||
|
||
unsigned a, d; | ||
#if 0 | ||
__asm__ __volatile__ ("cpuid\n\t" | ||
"rdtsc\n\t" | ||
: "=a" (a), "=d" (d) | ||
:: "%rax", "%rbx", "%rcx", "%rdx"); | ||
#else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code (in the context) that was in this |
||
|
||
static inline opal_timer_t | ||
opal_sys_timer_get_cycles(void) | ||
{ | ||
unsigned a, d; | ||
__asm__ __volatile__ ("rdtsc" : "=a" (a), "=d" (d)); | ||
/* If we need higher accuracy we should implement the algorithm proposed | ||
* on the Intel document referenced above. However, in the context of MPI | ||
* this function will be used as the backend for MPI_Wtime and as such | ||
* can afford a small inaccuracy. | ||
*/ | ||
__asm__ __volatile__ ("rdtscp\n\t" | ||
"cpuid" | ||
: "=a" (a), "=d" (d) | ||
:: "%rax", "%rbx", "%rcx", "%rdx"); | ||
#endif | ||
return ((opal_timer_t)a) | (((opal_timer_t)d) << 32); | ||
} | ||
|
||
#endif | ||
|
||
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1 | ||
|
||
#else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana | ||
* University Research and Technology | ||
* Corporation. All rights reserved. | ||
* Copyright (c) 2004-2005 The University of Tennessee and The University | ||
* Copyright (c) 2004-2014 The University of Tennessee and The University | ||
* of Tennessee Research Foundation. All rights | ||
* reserved. | ||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, | ||
|
@@ -26,15 +26,18 @@ typedef uint64_t opal_timer_t; | |
|
||
/* frequency in mhz */ | ||
OPAL_DECLSPEC extern opal_timer_t opal_timer_darwin_freq; | ||
|
||
OPAL_DECLSPEC extern mach_timebase_info_data_t opal_timer_darwin_info; | ||
|
||
static inline opal_timer_t | ||
opal_timer_base_get_cycles(void) | ||
{ | ||
if( opal_timer_darwin_info.denom == 0 ) { | ||
(void) mach_timebase_info(&opal_timer_darwin_info); | ||
} | ||
/* this is basically a wrapper around the "right" assembly to get | ||
the tick counter off the PowerPC Time Base. I believe it's | ||
something similar on x86 */ | ||
return mach_absolute_time(); | ||
return mach_absolute_time() * opal_timer_darwin_info.numer / opal_timer_darwin_info.denom / 1000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Watch out for integer overflow here. I think you want to convert the fraction to a |
||
} | ||
|
||
|
||
|
@@ -43,7 +46,7 @@ opal_timer_base_get_usec(void) | |
{ | ||
/* freq is in Hz, so this gives usec */ | ||
return mach_absolute_time() * 1000000 / opal_timer_darwin_freq; | ||
} | ||
} | ||
|
||
|
||
static inline opal_timer_t | ||
|
@@ -53,9 +56,9 @@ opal_timer_base_get_freq(void) | |
} | ||
|
||
|
||
#define OPAL_TIMER_CYCLE_NATIVE 1 | ||
#define OPAL_TIMER_CYCLE_NATIVE 0 | ||
#define OPAL_TIMER_CYCLE_SUPPORTED 1 | ||
#define OPAL_TIMER_USEC_NATIVE 0 | ||
#define OPAL_TIMER_USEC_NATIVE 1 | ||
#define OPAL_TIMER_USEC_SUPPORTED 1 | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to drop the
%
characters in the clobber list (two places in this file, once inia32/timer.h
). Untested, but that's my recollection of the syntax.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax seems to be correct. The problem is that I over-specified the
clobber list (rax and rdx) were already implied by the "=a" and "=d" one
line above.
George.
On Mon, Nov 24, 2014 at 3:29 PM, Dave Goodell notifications@github.com
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed all your concerns/suggestions. Thanks, they really make the
code cleaner and hopefully more robust. This is now ready to be merged.
On Mon, Nov 24, 2014 at 3:35 PM, George Bosilca bosilca@icl.utk.edu wrote: