Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The tick counter on ARM is unrelated to the CPU clock #241

Open
pkhuong opened this issue Sep 11, 2022 · 0 comments
Open

The tick counter on ARM is unrelated to the CPU clock #241

pkhuong opened this issue Sep 11, 2022 · 0 comments
Assignees

Comments

@pkhuong
Copy link
Contributor

pkhuong commented Sep 11, 2022

I see Platform.h assumes asm volatile("mrs %0, cntvct_el0" : "=r" (pmccntr)); returns 1/64 of the clock cycle. We can actually read the tick frequency in Hz with

__inline__ uint64_t frequency()
{
  uint32_t freq;
  asm ("mrs %0, CNTFRQ_EL0" : "=r"(freq));
  return freq;
}

That value is unfortunately unrelated to the CPU clock, but maybe we can return a consistent value like byte/ns.

@rurban rurban self-assigned this Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants