k230_docs icon indicating copy to clipboard operation
k230_docs copied to clipboard

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

Open bgin opened this issue 1 year ago • 5 comments

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 avatar Apr 04 '24 12:04 bgin

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

bgin avatar Apr 16 '24 17:04 bgin

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 avatar Apr 17 '24 04:04 wycwyhwyq

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 avatar Apr 17 '24 10:04 bgin

@wuwentao @wycwyhwyq @zhangxiaojingCAN @sunnycase Dear all,

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

Best regards Bernard

bgin avatar Apr 30 '24 12:04 bgin

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

wycwyhwyq avatar May 06 '24 02:05 wycwyhwyq

as there is no any new response in current issue for a long time, so we will close it. if issue still exist or need more info, we still can reopen current issue. Thanks!

wuwentao avatar Jul 26 '24 03:07 wuwentao