Skip to content

Improve aarch64 timing - #778

Open
nicolas-bouton wants to merge 5 commits into
RRZE-HPC:masterfrom
SiPearl:nb/improve-aarch64-timing
Open

nicolas-bouton wants to merge 5 commits into
RRZE-HPC:masterfrom
SiPearl:nb/improve-aarch64-timing

Conversation

@nicolas-bouton

Copy link
Copy Markdown
Contributor

Following PR #776, this PR adds support for the ARMv8 hardware timer counter.

Timestamps are read from the cntvct_el0 system register, and the counter frequency is read from cntfrq_el0. Since the counter frequency cannot be changed, it is read only during timer initialization. Runtime in seconds is then calculated by dividing the timestamp by the counter frequency.

Before this change, several cleanup commits removed dead code, aligned the x86 and AArch64 CPU-frequency software estimates, handled gettimeofday() errors correctly, and removed redundant os_timer_*() functions.

The CPU-frequency lookup and `fixedFreq` initialization were commented
out. Remove that dead code and the remaining code that uses `fixedFreq`.

Signed-off-by: Nicolas Bouton <nicolas.bouton@sipearl.com>
x86 first retrieves the CPU frequency with CPUID and falls back to a
software estimate using a loop and an N-nanosecond sleep. AArch64 has no
userspace instruction for retrieving the frequency and uses a different,
less optimal software estimate.

Use the x86 fallback implementation as the shared software estimate for
both architectures.

Signed-off-by: Nicolas Bouton <nicolas.bouton@sipearl.com>
The return value of `gettimeofday()` was ignored on error. Terminate the program
when the call fails.

Signed-off-by: Nicolas Bouton <nicolas.bouton@sipearl.com>
The core logic in os_timer_start() and os_timer_stop() is the same. Remove these
functions.

Signed-off-by: Nicolas Bouton <nicolas.bouton@sipearl.com>
Timestamps are read from the `cntvct_el0` system register, and the counter
frequency is read from `cntfrq_el0`. Since the counter frequency cannot be
changed, it is read only during timer initialization. Runtime in seconds is then
calculated by dividing the timestamp by the counter frequency.

Signed-off-by: Nicolas Bouton <nicolas.bouton@sipearl.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant