(edit: looks like this is not the timer I'm looking for; thanks for the boosts a...
derf @derf@social.skyshaper.org
(edit: looks like this is not the timer I'm looking for; thanks for the boosts and replies!)
Yo fedi! In case anyon on here happens to have a bare-metal aarch64 machine (e.g. RasPi4/5 with 64-bit OS), could you compile the following program and pass me its output?
I'd like to hand out an assignment related to high-resolution timestamps, and need a non-x86 alternative for x86intrin.h's __rdtsc() calls.
#include <stdio.h>
int main(void)
{
unsigned long long t0, t1;
asm volatile("mrs %0, cntfrq_el0" : "=r" (t0));
printf("%llu\n", t0);
printf("x y\n");
for (int i = 1; i <= 10000; i++) {
asm volatile("mrs %0, cntvct_el0" : "=r" (t0));
asm volatile("mrs %0, cntvct_el0" : "=r" (t1));
printf("%d %llu\n", i, t1 - t0);
}
return 0;
}