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.

time used in simulator is different from in c6678 EVM

hello:

I test a code with c6678 simulator and EVM.

I run a  code in simulator, and  calculate the time it used. Then i run  same code in c6678 EVM , and  also calculate the time it used . I find the latter is twice than  the former,  I

want to know why ? all the code and data in L2.  thanks!

  • Si Cheng,

    The C6678 device on the EVM is correct in its operation. But the configuration of cache or the clock settings or the method of time measurements may be wrong.

    Different simulators are more or less accurate than others. Generally, they are all more accurate than 50%, but that could depend on the memory model that was used. Which exact simulator did you use?

    How did you measure the time in each case?

    Regards,
    RandyP

  • RandyP,

    CplxAddCplx.asm is two float array add(X+Y), and output the Result (Z = X + Y). In  CplxAddCplx.asm , a loop  uses 7 cycle, and store 4 result, average one result is 1.75 cycle, in cycle approximate simulator,  in main:

    #define N (32*1024)

     nStart = clock();
      nEnd = clock();
      nClock = nEnd - nStart;
      nStart = clock();
      CplxAddCplx(X,Y,Z,N);
      nEnd = clock();
      nClock = nEnd - nStart - nClock;
      printf("nClock = %d\n",nClock);

    the time it used is about 1.75*32*1024.

    but when i run in c6678 EVM , the time is about twice than 1.75*32*1024. so i want to know why ?

     

    CplxAddCplx.asm code is :


    ;A4 = X
    ;B4 = Y
    ;A6 = Z
    ;B6 = N
      .global _CplxAddCplx

    _CplxAddCplx:

      mv  b6, b0
      shru b0, 2, b0
      sub  b0, 2, b0 
      sub  b0, 2, b0 

      mv  a4, b5 ;a4 = b5 = X
      mv  b4, a5 ;b4 = a5 = Y
      mv  a6, b7 ;b7 = a6 = Z

      lddw *a4++, a31:a30
     || add  8, b5, b5
      lddw *a5++, a29:a28
     || add  8, b4, b4
      lddw *b5++, b31:b30
     || add  8, a4, a4
      lddw *b4++, b29:b28
     || add  8, a5, a5
      lddw *a4++, a27:a26
     || add  8, b5, b5
      lddw *b4++, a25:a24
     || add  8, a5, a5
      lddw *b5++, b27:b26
     || add  8, a4, a4
     || daddsp a31:a30, a29:a28, a23:a22 ;1

      lddw *b4++, b25:b24
     || add  8, a5, a5
     || lddw *a4++, a31:a30
     || add  8, b5, b5

      daddsp b31:b30, b29:b28, b23:b22 ;2
     || lddw *a5++, a29:a28
     || add  8, b4, b4

    loop:
      stdw a23:a22, *a6++    ;1
     || add  8, b7, b7
     || lddw *b5++, b31:b30
     || add  8, a4, a4

      bdec loop, b0
     || daddsp a27:a26, a25:a24, a23:a22 ;3
     || lddw *b4++, b29:b28
     || add  8, a5, a5

      stdw b23:b22, *b7++    ;2
     || add  8, a6, a6
     || lddw *a4++, a27:a26
     || add  8, b5, b5

      daddsp b27:b26, b25:b24, b23:b22 ;4
     || lddw *b4++, a25:a24
     || add  8, a5, a5

      stdw a23:a22, *a6++    ;3
     || add  8, b7, b7
     || lddw *b5++, b27:b26
     || add  8, a4, a4
     || daddsp a31:a30, a29:a28, a23:a22 ;1

      lddw *b4++, b25:b24
     || add  8, a5, a5
     || lddw *a4++, a31:a30
     || add  8, b5, b5

      stdw b23:b22, *b7++    ;4
     || add  8, a6, a6
     || daddsp b31:b30, b29:b28, b23:b22 ;2
     || lddw *a5++, a29:a28
     || add  8, b4, b4


    ;out of loop
      stdw a23:a22, *a6++    ;1
     || add  8, b7, b7
     || lddw *b5++, b31:b30
     || add  8, a4, a4

      daddsp a27:a26, a25:a24, a23:a22 ;3
     || lddw *b4++, b29:b28
     || add  8, a5, a5

      stdw b23:b22, *b7++    ;2
     || add  8, a6, a6
     || lddw *a4++, a27:a26
     || add  8, b5, b5

      daddsp b27:b26, b25:b24, b23:b22 ;4
     || lddw *b4++, a25:a24
     || add  8, a5, a5

      stdw a23:a22, *a6++    ;3
     || add  8, b7, b7
     || lddw *b5++, b27:b26
     || add  8, a4, a4
     || daddsp a31:a30, a29:a28, a23:a22 ;1

      lddw *b4++, b25:b24
     || add  8, a5, a5

      stdw b23:b22, *b7++    ;4
     || add  8, a6, a6
     || daddsp b31:b30, b29:b28, b23:b22 ;2


      stdw a23:a22, *a6++    ;1
     || add  8, b7, b7

      daddsp a27:a26, a25:a24, a23:a22 ;3

      stdw b23:b22, *b7++    ;2
     || add  8, a6, a6

      daddsp b27:b26, b25:b24, b23:b22 ;4

      stdw a23:a22, *a6++    ;3
     || add  8, b7, b7

      nop

      stdw b23:b22, *b7++    ;4


      b  b3
      nop  5

  • and all code is in L2, L1P all cache, L1D all cache!

    thanks!

  • What is the clock() function? I am not familiar with it, but if it is a generic function then you should look at the disassembly to see if it reads the TSCL/TSCH registers (or at least TSCL) to get the accurate number of clock cycles.

    You can search the forum for TSCH to find some discussions on macros and methods for reading the TimeStamp Counter, but there are also functions available in SYS/BIOS to support that.

    Regards,
    RandyP

  •  clock () function is included in <time.h>, it is equal TSCL/TSCH, when i use TSCL,TSCH to get the time of the asm function consumed,  consumed time is the same with clock() function.  so i still don't konw why run in EVM is larger than in simulator?

    thanks!

  • Si Cheng,

    We will move this thread to the Code Composer Forum where they can address issues or questions on the simulator.

    Unless there are deficiencies in your EVM setup, the device on the EVM has the correct timing by definition of what accuracy means.

    Perhaps the CCS team will have comments to add to your question.

    Regards,
    RandyP