Skip to content

Commit 464f328

Browse files
Merge pull request #89 from Xilinx-CNS/user/kieranm/ON-16400-rdtscp
ON-16400: switch zf*pingpong to use rdtscp for more accurate latency measurement
2 parents 1f1fb5b + 3716ae9 commit 464f328

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/tests/zf_apps/zf_timer.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,25 @@
99
#include <x86intrin.h>
1010
#include <stdint.h>
1111

12-
inline uint64_t get_frc64_time(void)
12+
/* Return measure of free running counter, using rdtsc, so may be reordered with other code */
13+
inline uint64_t get_frc64_time_standard(void)
1314
{
1415
return __rdtsc();
1516
}
1617

18+
/* Return measure of free running counter, using rdtscp, which gives higher accuracy when measuring
19+
* the duration of blocks of code as it can't be reordered with earlier instructions, but has
20+
* slightly higher overhead than get_frc64_time_standard() */
21+
inline uint64_t get_frc64_time_accurate(void)
22+
{
23+
unsigned int aux;
24+
return __rdtscp(&aux);
25+
}
26+
27+
/* Default to using the more accurate measure as all current uses of this function are using it to
28+
* measure ping pong deltas, and hence will benefit from the accuracy */
29+
#define get_frc64_time() get_frc64_time_accurate()
30+
1731
void init_tsc_frequency(void);
1832

1933
/* Given TSC ticks it will calculate and return number of nano seconds passed for it.

0 commit comments

Comments
 (0)