使用硬件对策执行时间上的ARM Cortex-A8 [英] Measure executing time on ARM Cortex-A8 using hardware counter

查看:445
本文介绍了使用硬件对策执行时间上的ARM Cortex-A8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Exynos 3110处理器(1GHz的单核ARM Cortex-A8,例如,在Nexus S的使用),并试图衡量特定功能的执行时间。我对的Nexus S.运行的是Android 4.0.3我试图从

I'm using a Exynos 3110 processor (1 GHz Single-core ARM Cortex-A8, e.g. used in the Nexus S) and try to measure execution times of particular functions. I have an Android 4.0.3 running on the Nexus S. I tried the method from

[1] <一个href=\"http://stackoverflow.com/questions/3247373/how-to-measure-program-execution-time-in-arm-cortex-a8-processor?answertab=oldest#tab-top\">How测量的ARM Cortex-A8处理器的程序执行时间?

我装内核模块,以允许在用户模式下读取的寄存器值。我使用下面的程序来测试计数器:

I loaded the kernel module to allow reading the register values in user mode. I am using the following program to test the counter:

static inline unsigned int get_cyclecount (void)
{
    unsigned int value;
    // Read CCNT Register
    asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(value));
    return value;
}


static inline void init_perfcounters (int do_reset, int enable_divider)
{
    // in general enable all counters (including cycle counter)
    int value = 1;

    // peform reset:  
    if (do_reset)
    {
        value |= 2;     // reset all counters to zero.
        value |= 4;     // reset cycle counter to zero.
    } 

    if (enable_divider)
        value |= 8;     // enable "by 64" divider for CCNT.

    value |= 16;

    // program the performance-counter control-register:
    asm volatile ("MCR p15, 0, %0, c9, c12, 0\t\n" :: "r"(value));  

    // enable all counters:  
    asm volatile ("MCR p15, 0, %0, c9, c12, 1\t\n" :: "r"(0x8000000f));  

    // clear overflows:
    asm volatile ("MCR p15, 0, %0, c9, c12, 3\t\n" :: "r"(0x8000000f));
}


int main(int argc, char **argv)
{
    int i = 0;
    unsigned int start = 0;
    unsigned int end = 0;

    printf("Hello Counter\n");

    init_perfcounters(1,0);

    for(i=0;i<10;i++)
    {
        start = get_cyclecount();
        sleep(1); // sleep one second
        end = get_cyclecount();

        printf("%u %u %u\n", start, end, end - start);
    }

    return 0;
}

根据[1]所述计​​数器与每个时钟周期递增。我切换scaling_governor用户空间,并设置CPU主频达到1GHz,以确保时钟频率不被改变的Andr​​oid

According to [1] the counter is incremented with each clock cycle. I switched the scaling_governor to userspace and set the CPU frequency to 1GHz to make sure that the clock frequency is not change by Android.

如果我运行1秒睡觉被执行的程序,但计数器值在〜200e6的范围内,而不是预期的1E9。有什么具体的处理器,我在这里丢失?是处理器的时钟速度

If I run the program the sleeps of 1 second are executed, but the counter values are in the range of ~200e6, instead of the expected 1e9. Is there anything processor specific I am missing here? Is the clock rate of the counters different to the clock rate of the processor ?

推荐答案

看看这个教授的网页:的 http://users.ece.utexas.edu/~valvano/arm/
他说有时间/周期性定时器/测量,执行时间做多个完整的示例程序,它们是基于ARM Cortex-M3的微控制器开发的。我希望这不是从你的工作有很大不同。
我想你会感兴趣的 Performance.c

Check out this professor's page: http://users.ece.utexas.edu/~valvano/arm/ He has multiple full example programs that have to do with time/periodic-timers/measuring-execution-time, they are developed for ARM Cortex-M3 based microcontrollers. I hope this isn't very different from what you are working on. I think you would be interested in Performance.c

这篇关于使用硬件对策执行时间上的ARM Cortex-A8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆