This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to measure a portion of function running in cycles?

Hi,

I learn to use TSCL, TSCH in cycle counting, just as the following link shows. My problem is how to measure the start and end time of purticular points in Release mode. It has no problem in Debug mode as I know which line runs. As release mode, I have no idea which part of a function is running.

Could you tell me some ideas to measure a portion of a function?

 

Thanks,

.....................

http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/p/11526/44893.aspx#44893

  • Robert,

    The easiest way is to insert TSC reads into your code. These may take as much as 5-10 cycles for each read, but if that is not too much impact to your system it will work well. You can use a compile-time switch to enable or disable those reads, or just use them once and remove them after taking the measurements.

    The harder way is to examine the assembly code to determine where the code of interest starts and ends then use hardware breakpoints with cycle counting to get the benchmark you want.

    But some of this may depend on which DSP you are using. Which DSP are you using?

    Regards,
    RandyP

  • Thanks. It is C6678 dsp. I need the procedure to get cycle count for a part of function code.

  • Robert,

    Good. The C6678 will have all of the most advanced features available for your use, if you want.

    Is the embedded TSC "easiest" path acceptable to you? This is what I use since it is easiest to see and to setup.

    Regards,
    RandyP

  • I need an accurate cycle count. It seems TSCL,TSCH is the right choice. The difficulty is that I need to measure cycle count in the Release mode. It can find the function beginning in the disassembly window. I add each __asm("nop 5") at the beginning and the end of the desired portion, but I can only find one first "nop 5'. Do you have a method to test a portion of the function code? Do I have to move that portion to another sub function to measure the cycle count?

     

    Thanks,

  • Robert,

    Why do you insert the nop 5 into your code? Is it not a requirement to put a space or tab in the first character in the "quotes in the __asm() argument? I always thought it was a requirement.

    The thread here shows using embedded TSCL/H reads to get timing information. This should survive across the optimization. Be sure to make the long long variables volatile, which was not done in that example.

    The Compiler thread here has a discussion on optimized macros for getting the TSCL/H value into a long long variable. I think it was down to 5-9 cycles, if memory serves. That macro will make the code a little more readable.

    Is this a lot different from what you were doing with TSCL and TSCH?

    Regards,
    RandyP