From 1899066e3601b664d0d04e5205a4d2ef8ca73e4e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 26 Apr 2018 16:03:31 +0200 Subject: [PATCH] Read time from timer register on arm64. On ODROID C2 this change improves timer resolution from 250 ns to 41 ns. --- client/TracyProfiler.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 0e4488ea..66f947b8 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -23,6 +23,10 @@ # define TRACY_HW_TIMER #endif +#if defined __aarch64__ +# define TRACY_HW_TIMER +#endif + namespace tracy { @@ -64,7 +68,12 @@ public: static tracy_force_inline int64_t GetTime( uint32_t& cpu ) { #ifdef TRACY_HW_TIMER -# if defined _MSC_VER || defined __CYGWIN__ +# if defined __aarch64__ + int64_t t; + cpu = 0xFFFFFFFF; + asm volatile ( "mrs %0, cntvct_el0" : "=r" (t) ); + return t; +# elif defined _MSC_VER || defined __CYGWIN__ const auto t = int64_t( __rdtscp( &cpu ) ); return t; # elif defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 @@ -81,7 +90,11 @@ public: static tracy_force_inline int64_t GetTime() { #ifdef TRACY_HW_TIMER -# if defined _MSC_VER || defined __CYGWIN__ +# if defined __aarch64__ + int64_t t; + asm volatile ( "mrs %0, cntvct_el0" : "=r" (t) ); + return t; +# elif defined _MSC_VER || defined __CYGWIN__ static unsigned int dontcare; const auto t = int64_t( __rdtscp( &dontcare ) ); return t;