Go to the documentation of this file.
33 #if ARCH_AARCH64 && (!defined(_MSC_VER) || defined(__clang__))
35 static inline uint64_t checkasm_cntvct(
void)
37 uint64_t tick_counter;
42 __asm__ __volatile__(
"isb\nmrs %0, cntvct_el0" :
"=r"(tick_counter)::
"memory");
46 static inline uint64_t checkasm_cntfrq(
void)
49 __asm__ __volatile__(
"mrs %0, cntfrq_el0" :
"=r"(frequency));
53 static uint64_t perf_start(
void)
55 return checkasm_cntvct();
58 static uint64_t perf_stop(uint64_t t)
60 return checkasm_cntvct() - t;
69 uint64_t frequency = checkasm_cntfrq();
74 if (frequency < 100000000)
77 perf->
start = perf_start;
78 perf->
stop = perf_stop;
79 perf->
name =
"aarch64 (cntvct)";
80 if (frequency == 1000000000)
89 #elif ARCH_ARM && !defined(_MSC_VER) && defined(__ARM_ARCH) && __ARM_ARCH <= 6 \
90 && (!defined(__thumb__) || defined(__thumb2__))
92 static inline uint64_t checkasm_ccnt(
void)
94 uint32_t cycle_counter;
96 __asm__ __volatile__(
"mcr p15, 0, %0, c7, c5, 4" ::
"r"(0) :
"memory");
99 __asm__ __volatile__(
"mrc p15, 0, %0, c15, c12, 1" :
"=r"(cycle_counter)::
"memory");
100 return cycle_counter;
103 static inline void checkasm_ccnt_start(
void)
105 __asm__ __volatile__(
"mcr p15, 0, %0, c15, c12, 0" ::
"r"(1));
108 static uint64_t perf_start(
void)
110 return checkasm_ccnt();
113 static uint64_t perf_stop(uint64_t t)
115 return checkasm_ccnt() - t;
129 checkasm_ccnt_start();
136 perf->
start = perf_start;
137 perf->
stop = perf_stop;
138 perf->
name =
"armv6 (ccnt)";
139 perf->
unit =
"cycle";
144 fprintf(stderr,
"checkasm: unable to access ARM11 cycle counter\n");
int checkasm_perf_validate_start(const CheckasmPerf *perf)
checkasm_jmp_buf checkasm_context
uint64_t(* start)(void)
Start timing measurement.
#define checkasm_save_context(ctx)
COLD int checkasm_perf_init_arm(CheckasmPerf *perf)
int checkasm_run_on_all_cores(void(*func)(void))
uint64_t(* stop)(uint64_t start_time)
Stop timing measurement.
const char * name
Name of the timing mechanism (e.g., "clock_gettime")
CHECKASM_API void checkasm_set_signal_handler_state(int enabled)
Enable or disable signal handling.
const char * unit
Unit of measurement (e.g., "ns", "cycles")
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")