[x264-devel] [PATCH 22/23] checkasm: add cycle counter read for aarch64

Janne Grunau janne-x264 at jannau.net
Thu Nov 27 08:56:50 CET 2014


Needs kernel support since user space access to the cycle counter is not
allowed on all available AArch64 systems (Android 5 and iOS).
---
 tools/checkasm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/checkasm.c b/tools/checkasm.c
index a0e8810..b6a1140 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -97,6 +97,10 @@ static inline uint32_t read_time(void)
     asm volatile( "mftb %0" : "=r"(a) :: "memory" );
 #elif ARCH_ARM     // ARMv7 only
     asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(a) :: "memory" );
+#elif ARCH_AARCH64
+    uint64_t b = 0;
+    asm volatile( "mrs %0, pmccntr_el0" : "=r"(b) :: "memory" );
+    a = b & 0xffffffffllu;
 #endif
     return a;
 }
@@ -2752,7 +2756,7 @@ int main(int argc, char *argv[])
 
     if( argc > 1 && !strncmp( argv[1], "--bench", 7 ) )
     {
-#if !ARCH_X86 && !ARCH_X86_64 && !ARCH_PPC && !ARCH_ARM
+#if !ARCH_X86 && !ARCH_X86_64 && !ARCH_PPC && !ARCH_ARM && !ARCH_AARCH64
         fprintf( stderr, "no --bench for your cpu until you port rdtsc\n" );
         return 1;
 #endif
-- 
2.1.3



More information about the x264-devel mailing list