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

[other]: Access to the Performance Timers (Counters) #29

Open
bgin opened this issue Apr 4, 2024 · 5 comments
Open

[other]: Access to the Performance Timers (Counters) #29

bgin opened this issue Apr 4, 2024 · 5 comments
Assignees

Comments

@bgin
Copy link

bgin commented Apr 4, 2024

Other

Hello,
Does there exist a possibility to directly access the k230 performance timers or counters from the user space?
Just as in the case of x86_64 architecture where exists a dedicated instruction i.e. "RDPMC".

Thank your for help
Best regards
Bernard

@bgin
Copy link
Author

bgin commented Apr 16, 2024

@wuwentao , @zhangxiaojingCAN , @sunnycase
Can anyone answer my question!!

@wycwyhwyq
Copy link
Member

uint64_t get_cpu_times(void)
{
    uint64_t value;
    __asm__ __volatile__("rdtime %0" : "=r"(value));
    return value;
}

uint64_t get_cpu_cycles(void)
{
    uint64_t value;
    __asm__ __volatile__("rdcycle %0" : "=r"(value));
    return value;
}

The cpu timer frequency is 24M Hz.
The big core cpu default frequency is 1.6G Hz.
The little core cpu default frequency is 800M Hz.

@bgin
Copy link
Author

bgin commented Apr 17, 2024

uint64_t get_cpu_times(void)
{
    uint64_t value;
    __asm__ __volatile__("rdtime %0" : "=r"(value));
    return value;
}

uint64_t get_cpu_cycles(void)
{
    uint64_t value;
    __asm__ __volatile__("rdcycle %0" : "=r"(value));
    return value;
}

The cpu timer frequency is 24M Hz. The big core cpu default frequency is 1.6G Hz. The little core cpu default frequency is 800M Hz.

@wycwyhwyq
Thank you very much.

I have additional question and let me explain that more profoundly.
Why looking at perf-list output I have seen much greater number of hardware-events, that those presented by you.
Please have a look:
image
and this screenshot:
image

I would like to know if there is a possibility to read these hardware events from the user space, exactly just as your example shows the read-out of timer value and the cycle count.

I really appreciate your help!!

Bernard

@bgin
Copy link
Author

bgin commented Apr 30, 2024

@wuwentao @wycwyhwyq @zhangxiaojingCAN @sunnycase
Dear all,

Can [finally] anyone (of above-mentioned) answer my question?
Please offer a helping hand!!

Best regards
Bernard

@wycwyhwyq
Copy link
Member

For a detailed introduction and use of PMU, please refer to Chapter 14 of this XuanTie-C908-UserManual.pdf.

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

No branches or pull requests

4 participants