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.

C6678 accurate clock cycle counting

Other Parts Discussed in Thread: SYSBIOS

Howdy!

I am curious if there is a known highly accurate method to count the time duration it takes to run my program.

My program is in c++ and I am using CCS v5 in Ubuntu.  My target hardware is the C6678, which I am successfully simulating in CCS at the moment.

The end goal for me here is to find the program execution duration in real-time (fractions of a second), as accurately as I can.  I'm thinking that after I count the number of clock cycles, I would like to try and 'convert' that to real-time (seconds) by multiplying it by my device's true clock speed (assuming that I can measure the clock speed somehow, and that the speed doesn't change over time based on how 'busy' the DSP is!).

Thank you!

  • Chris,

    The easiest way is to use the XDCTools' high-resolution timer from the xdc.runtime.Timestamp module. This is documented in the XDStools online documentation through the CCS Help menu.

    The Tinestamp Counter is part of the DSP core for all of the cores from the C64x+ and newer, including the C674x and C66x cores.

    You could also use the TSCL and TSCH registers directly, but it must be done in a particular way. You can search the DSP forums for posts with the TSCL and TSCH symbols mentioned. There have been some posts with examples for how to do this.

    But the use of the XDSTools version, available when you are using SYS/BIOS, is the easiest and overcomes any of the usage issues.

    The Timestamp counter, once it has been started, will count at the DSP core frequency. It will not pause when the DSP is loaded, and it will pause with the emulator stops the DSP during debug.

    There is a fancy function that can run in a GEL file that I have seen, but I do not know where it is documented. In the past, I have used the application DSPClockSpeed that is available on the TI Wiki Pages if you search for "DSP clock speed" (no quotes).

    Regards,
    RandyP

  • Thanks Randy!  I'm trying out the XDCTools right now... hoping it'll work.  I appreciate your suggestions.

    Should this method be functional for both the C66x simulator in CCSv5 and for running real-time on my actual hardware?  I just want to double check if there are any differences of which I should be made aware.

  • Any thoughts anyone?  Thank you in advance!

    Right now I am getting these 3 compile errors:

       #10010 errors encountered during linking; "ex1_sysbios_CJ.out" not built    ex1_sysbios_CJ             C/C++ Problem
       #10234-D unresolved symbols remain    ex1_sysbios_CJ             C/C++ Problem
       Unresolved symbol xdc_runtime_Timestamp_get32__E in file /data/opt/ti/bios_6_34_02_18/packages/ti/sysbios/lib/sysbios/instrumented/sysbios.ae66<BIOS.obj>    .xdchelp    /ex1_sysbios_CJ    0    C/C++ Problem

    Here's the code I'm running... most of it is from the example project for SYS/BIOS:


    #include <xdc/std.h>
    #include <math.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/BIOS.h>
    #include <xdc/runtime/Timestamp.h>
    #include <xdc/runtime/Types.h>

    /*
     *  ======== main ========
     */
    Void main()
    {
        System_printf("hello world\n");

        /*
         *  normal BIOS programs, would call BIOS_start() to enable interrupts
         *  and start the scheduler and kick BIOS into gear.  But, this program
         *  is a simple sanity test and calls BIOS_exit() instead.
         */

        int time1, time2, delta;
        time1 = Timestamp_get32();

    // Here just perform some computations to take up time
        double d = 5423;
        double r = 1;
        r = sqrt(d);
        r = sqrt(r);

        int a = 12;
        System_printf("Chris Jagielski\n"
                    "here's a number: %i\n",a);


        time2 = Timestamp_get32();
        delta = time2 - time1;

        BIOS_exit(0);  /* terminates program and dumps SysMin output */
    }

    The problems only show up when I added the Timestamp_get32() lines.  Thanks again!

  • Hi Chris,

    Add

    var Timestamp = xdc.useModule('xdc.runtime.Timestamp');

    to your .cfg. Link.

    BR

  • Thanks!

    Adding the line to the .cfg file did the trick.

  • Hello,

    How can I use the head file "csl_tmr.h" to get the time of my program?

    Regards

    S.

  • Yuanrui,

    In which C6678 software package do you find the csl_tmr.h file? I do not find it in a search on my PC, for the C6678 or MCSDK2

    Regards,
    RandyP

  • Hi, Johannes

    I met the same problem of " Unresolved symbol xdc_runtime_Timestamp_get32__E ".

    I added the line

    var Timestamp = xdc.useModule('xdc.runtime.Timestamp');

    to my .cfg file but it didn't work.

    Is there any other way to fix the problem?
  • Hi Yi Ding1,

    Sorry for the late response. Have you already solve your problem?

    To solve the linking problem of unresolved symbols the linker must find the symbol definitions. As long as I know, depending how you're building your project, this can be done through a .c/.cpp file that contains the definition or including a library that or, depending on the library, can also be done using the linker properties or via .cfg, like the example above. Another situation where this kind of problem can rise is when you use C code in a Cpp code, so you have to use a extern "C" in the function definition, check this .

    Regards

    J