google / google/CFU-Playground

Accuracy of perf_get_mcycle() or perf_get_mcycle64()

Open
#506 18 comments 0 reactions 0 assignees View on GitHub
Dominant language
Verilog
Stars
565
Forks
160
PR merge metrics
No merged PRs in 30d

Description

Hi, I just wanted to know if the perf_get_mcycle or mcycle64 function for profiling is accurate in giving cycle counts, because I tried it out with one of my custom hardware peripherals- which I know takes atleast around 80-90 cycles ( which also has a fp mul and add unit- which obviously takes quite a bit of time). However, via perf_get_mcycle it is showing around 7 cycles which seems to be off by a lot.

```
long start = perf_get_mcycle64();
cfu_op2(0,in_channel_count,out_channel); //7 cycles.
long end = perf_get_mcycle64();
printf("COMP time %ld\n" ,end-start);

```
Additionally, if there is some related issue regarding cycle accuracy in perf_get_mcycle64(), please let me know.

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementations of perf_get_mcycle() and perf_get_mcycle64(), then reproduce the measurement around cfu_op2 shown in the issue. Determine whether the reported cycle count is accurate for the custom peripheral and document or correct the behavior so the measured count is reliable.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.