Closed Cuda-Chen closed 2 years ago
You don't have to implement _rdtsc
for x86/x86-64 since the intrinsic should be available via the inclusion of <x86intrin.h>
. Instead, header sse2neon.h
should provide Arm/Aarch64 counterpart.
For ARMv7-A implementation of _rdtsc
, you can check gperftools/src/base/cycleclock.h. Quoted:
V7 is the earliest arch that has a standard cyclecount
Related discussions: https://stackoverflow.com/questions/40454157/is-there-an-equivalent-instruction-to-rdtsc-in-arm
Thanks @jserv help, and I will work on ARMv7-A part!
Currently I am porting _rdtsc
x86 intrinsic onto ARMv7.
On ARMv7 platform, usually we can access PMCCNTR
to get cycle count. In order to access this register, the program has to run in PL1 or high mode, or running in user mode when PMUSERENR
.EN == 1. However, the PMUSERENR
is set to zero in the test suite qemu environment and I can't change the value because the test suite qemu environment is running in user mode.
As such, I come up with the following two solutions, and I would like to know which solution is acceptable to this project:
gettimeofday()
if we can't set the value of PMUSERENR
(in Linux kernel, this kind of syscall is able to access PMCCNTR
).As such, I come up with the following two solutions, and I would like to know which solution is acceptable to this project:
- Set test suite qemu environment to privilege mode.
- Fallback to call syscall such as
gettimeofday()
if we can't set the value ofPMUSERENR
(in Linux kernel, this kind of syscall is able to accessPMCCNTR
).
For Armv7-A targets, we can provide the OS-assisted fallback at first glance. Then, further exploration would be beneficial.
Currently I am implementing the
_rdtsc
Intel intrinsic function. I confirm I follow the instruction of adding test case. However, whenever I tried tomake check
on Intel platform, I always receive the following compile error:For your convenience, I attach the changed I have made:
elif defined(aarch64)
FORCE_INLINE uint64_t _rdtsc(void) { uint64_t val;
}
endif
tests/impl.cpp
At last, thanks for your help!