aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/cycles.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/cycles.h')
-rw-r--r--test/monniaux/cycles.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/test/monniaux/cycles.h b/test/monniaux/cycles.h
index c7dc582b..1f7a991a 100644
--- a/test/monniaux/cycles.h
+++ b/test/monniaux/cycles.h
@@ -2,7 +2,7 @@
#include <inttypes.h>
#include <stdio.h>
-#ifdef __K1C__
+#ifdef __KVX__
typedef uint64_t cycle_t;
#define PRcycle PRId64
@@ -11,18 +11,18 @@ typedef uint64_t cycle_t;
static inline void cycle_count_config(void)
{
/* config pmc for cycle count */
- cycle_t pmc_value = __builtin_k1_get(COS_SFR_PMC);
+ cycle_t pmc_value = __builtin_kvx_get(COS_SFR_PMC);
pmc_value &= ~(0xfULL);
- __builtin_k1_set(COS_SFR_PMC, pmc_value);
+ __builtin_kvx_set(COS_SFR_PMC, pmc_value);
}
static inline cycle_t get_cycle(void)
{
- return __builtin_k1_get(COS_SFR_PM0);
+ return __builtin_kvx_get(COS_SFR_PM0);
}
-#else // not K1C
+#else // not KVX
static inline void cycle_count_config(void) { }
#if defined(__i386__) || defined( __x86_64__)
@@ -45,11 +45,16 @@ static inline cycle_t get_cycle(void) {
return cycles;
}
-#elif defined (__ARM_ARCH) && (__ARM_ARCH >= 6)
+#elif defined (__ARM_ARCH) // && (__ARM_ARCH >= 6)
#if (__ARM_ARCH < 8)
typedef uint32_t cycle_t;
#define PRcycle PRId32
+#ifdef ARM_NO_PRIVILEGE
+static inline cycle_t get_cycle(void) {
+ return 0;
+}
+#else
/* need this kernel module
https://github.com/zertyz/MTL/tree/master/cpp/time/kernel/arm */
static inline cycle_t get_cycle(void) {
@@ -57,14 +62,20 @@ static inline cycle_t get_cycle(void) {
__asm__ volatile ("mrc p15, 0, %0, c9, c13, 0":"=r" (cycles));
return cycles;
}
+#endif
#else
#define PRcycle PRId64
typedef uint64_t cycle_t;
+
+#ifdef ARM_NO_PRIVILEGE
+static inline cycle_t get_cycle(void) {
+ return 0;
+}
+#else
/* need this kernel module:
https://github.com/jerinjacobk/armv8_pmu_cycle_counter_el0
on 5+ kernels, remove first argument of access_ok macro */
-
static inline cycle_t get_cycle(void)
{
uint64_t val;
@@ -72,6 +83,7 @@ static inline cycle_t get_cycle(void)
return val;
}
#endif
+#endif
#else
#define PRcycle PRId32