kendryte / k230_docs

Kendryte K230 SDK Docs
BSD 2-Clause "Simplified" License
85 stars 11 forks source link

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

Closed bgin closed 1 month ago

bgin commented 5 months ago

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 commented 5 months ago

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

wycwyhwyq commented 4 months ago
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 commented 4 months ago
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 commented 4 months ago

@wuwentao @wycwyhwyq @zhangxiaojingCAN @sunnycase Dear all,

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

Best regards Bernard

wycwyhwyq commented 4 months ago

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

wuwentao commented 1 month ago

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!