zoukankan      html  css  js  c++  java
  • DSP 运行时间计算函数--_itoll(TSCH,TSCL);

    DSP OMAP 程序耗时测定 CPU周期 两种方法

    利用TSCL和TSCH来计算时钟周期,这两天看了一下如何他们

    DSP开发,测量某个函数或某段代码的cycles消耗是经常要做的 事情,常用的profiling和clock()一般在simulation下使用,真正到了板子上做emulation时,因为要考虑到数据和被测 code在板子上的存放位置和读取时间,用这种方法测结果就不那么可靠了。其实在c64x+ core上有两个计数寄存器TSCL/TSCH,它们与CPU同频,共同表示一个64-bit数,CPU运行一个cycle,该寄存器就加1,因此可以用 它们来准确的测量cpu在某个执行段中消耗的cycles。一般我们只会用到TSCL这个寄存器,594MHz下,32-bit可以测试到7s,而 TSCH是高32位,除非测试整个工程,一般用不到它。

    使用方法:长时间宽范围时钟测定

    unsigned long long t1,t2;

    t1=_itoll(TSCH,TSCL);

    code_wait_test;

    t2=_itoll(TSCH,TSCL);

    printf(“#cycle=%d”,t2-t1);

    短时间(7秒)窄范围时钟测定:

    T1=TSCL;

    …process code …

    T2=TSCL;

    Printf(“#cycle=%d”,t2-t1);

    方法二,也可以采用biosAPI方式

    LgUns time1=CLK_gethtime();

    …process code …

    LgUns time2=CLK_gethtime();

    Cpucycles=(time2-time1)*CLK_cpucyclePerhtime;

    Prinf(“#cycle=%d”,Cpucycle);

    关于测量CPU时钟周期中我们用的变量类型和函数我们都可以在C6000DSP/bios的API文档和BIOS提供的源码找到,可以详细去查阅。

    #include "c6x.h"


    void YourFunc (void)
    {
    unsigned long long start;
    unsigned long long end;

    start = _itoll (TSCH, TSCL);

    /* put your code here */

    end = _itoll (TSCH, TSCL);

    printf ("Hi mate, I just wasted %d DSP-cycles in your punny code.
    Optimize me! ", end-start);
    }

    inline long long read_time(void)
    {
    extern cregister volatile unsigned int TSCL;
    extern cregister volatile unsigned int TSCH;
    long long l = (TSCH << 32) | TSCL;
    return l;
    }
    在使用TSCL和TSCH时首先需要向TSCL中写入数据,使能TSC寄存器。
    在DSP手册中说明:
    The counter is enabled by writing to TSCL. The value written is ignored.

    转载自:http://blog.chinaunix.net/uid-24517893-id-3235121.html

  • 相关阅读:
    错题记录——关于Java中private的用法(类与封装)
    深度学习-人脸识别-数据集和制作
    UE4使用经验记录
    pycharm 一直索引或索引过大占用系统盘问题
    深度学习portoch笔记_概念随笔
    mysql 找不到请求的 .Net Framework Data Provider。可能没有安装。
    halcon崩溃/异常信号11 后文件临时存储路径
    halcon 错误记录
    visual studio 2012 C#exe嵌入到子窗口,程序退出后子exe文件仍然被占用
    文件操作
  • 原文地址:https://www.cnblogs.com/warmbeast/p/10299282.html
Copyright © 2011-2022 走看看