Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

C64x+ simulator: clock function

Hello,

in SPRU198J (C6000 Programmer's Guide) in Sec. 2.3.1.1, the use of the clock() function for profiling is described. When I use this function with the C64x+ CPU cycle accurate simulator in CCS 4.2.1.00004, it always returns zero.

The Programmer's Guide speaks of the "standalone" simulator. Does that mean clock() cannot be used in CCS? Are there any compiler or other options that need to be set to specific values?

Thank you.

  • Alex,

    This question does not seem to be in any way BIOS related, so I am going to move this thread to the compiler forum (since the clock() function is from the RTS lib).

    As a side note, if you are using the SYS/BIOS v6.x RTOS, the xdc.runtime.Timestamp module provides timestamping services and can be used for benchmarking code and adding timestamps to logs.

    If you are using the DSP/BIOS v5.x RTOS, the same functionality is provided by CLK_gethtime().

    If you need further help with this, please go ahead and post questions to the BIOS forum.

    Dave

  • Please see this wiki article for more information on the clock function.

    Thanks and regards,

    -George

  • Alex said:

    When I use [clock] with the C64x+ CPU cycle accurate simulator in CCS 4.2.1.00004, it always returns zero.

    Not every simulator supports clock (but they should...); I'm not sure specifically about that simulator.  Does your test case work when you use one of the other simulators?

  • I tried several other simulators (C674x, C64xx among others), but none of them worked. In any case, the optimization is needed for the C64x+.

    Georgem, I read the Wiki article, but it didn't help with this problem.

    Dave, what do I need to include to be able to call CLK_gethtime()? I get an unresolved symbol error.

    Thank you all.

  • Alex said:

    I tried several other simulators (C674x, C64xx among others), but none of them worked. In any case, the optimization is needed for the C64x+.

    I don't propose you permanently change to a mismatching simulator, I'm just trying to diagnose the problem; since you've tried other simulators, I think it's highly unlikely that all of them fail to support clock, and I must now suspect it is something specific to your test case.   Please try this test case:

    #include <stdio.h>
    #include <time.h>
    
    int main()
    {
        clock_t start = clock();
        clock_t end = clock();
    
        printf("Elapsed cycles: %u\n", (unsigned int)end - (unsigned int)start);
        return 0;
    }

    Probably not your problem, but clock-related "gotchas:" if you call clock() on a typical host processor, the return value will only be an approximation, because there is typically no dedicated cycle counter. This is not a problem for a simulator, which can be exact. However, because the cycle time on C6x is so fast, you can easily get wrap-around on the 32-bit clock_t.

  • Screenshot attached. Still zero (also when I don't set a breakpoint).

  • Well, that's mighty surprising.  That test case works fine for me (although I'm not using that exact simulator), so I'm 99% sure this is not a compiler problem.  All signs point to this being a problem with clock not being implemented in the simulator, unlikely as that sounds.

  • I've encountered the same problem, the solution for me was to enable the clock manually before every simulation.

    In the File bar Target -> Clock -> Enable  

    in Code Composer Studio  Version: 4.2.3.00004

  • Even i had the same problem and i did the same by enabling clock.

  • But is the obtained clock cycle correct , will it be correct.