ffmpeg | branch: master | Martin Storsjö <mar...@martin.st> | Fri Jun  7 
11:39:08 2024 +0300| [ab8f7030bc46e5031d2ba438eddf0739098e3e5d] | committer: 
Martin Storsjö

aarch64: Use cntvct_el0 as timer register on Android and macOS

The default timer register pmccntr_el0 usually requires enabling
access with e.g. a kernel module (while it is accessible by
default on Windows). On Linux, the default for checkasm benchmarks
is to use perf (if suitable headers are available) though.

On macOS, using cntvct_el0 gives measurements with the same
magnitude as mach_absolute_time (which is used currently), but
possibly with a little less overhead/noise.

Signed-off-by: Martin Storsjö <mar...@martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab8f7030bc46e5031d2ba438eddf0739098e3e5d
---

 libavutil/aarch64/timer.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavutil/aarch64/timer.h b/libavutil/aarch64/timer.h
index fadc9568f8..922b0c5598 100644
--- a/libavutil/aarch64/timer.h
+++ b/libavutil/aarch64/timer.h
@@ -24,7 +24,7 @@
 #include <stdint.h>
 #include "config.h"
 
-#if HAVE_INLINE_ASM && !defined(__APPLE__)
+#if HAVE_INLINE_ASM
 
 #define AV_READ_TIME read_time
 
@@ -33,7 +33,16 @@ static inline uint64_t read_time(void)
     uint64_t cycle_counter;
     __asm__ volatile(
         "isb                   \t\n"
+#if defined(__ANDROID__) || defined(__APPLE__)
+        // cntvct_el0 has lower resolution than pmccntr_el0, but is usually
+        // accessible from user space by default.
+        "mrs %0, cntvct_el0        "
+#else
+        // pmccntr_el0 has higher resolution, but is usually not accessible
+        // from user space by default (but access can be enabled with a custom
+        // kernel module).
         "mrs %0, pmccntr_el0       "
+#endif
         : "=r"(cycle_counter) :: "memory" );
 
     return cycle_counter;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to