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.

Timestamp Calculation ISSUE!!!

Hi!

I calculated the time required for my program execution using the function Timestamp_get32(). I got negative values for time.

Time was calculated in the same way as given in the MCSDK image processing demo.

Here is my code snippet:

uint32_t ts1, ts2;

double delay=0.0f;

    Types_FreqHz freq;

 Timestamp_getFreq(&freq);

ts1 = (uint32_t) Timestamp_get32();

    if (filter((int*) gRxBuffer,number_of_detector_rows,number_of_detector_per_row, (int*) gTxImgBuffer, number_of_projections, &delay, &pixel_width) < 0)

       {

          send_error_page(htmlSock, "Error in running filter");

           return 1;

      }

    ts2 = (uint32_t) Timestamp_get32();

     ts2= ts2- ts1;

     delay = ((double)ts2 / (double)freq.lo) * 1000;

 

I also tried with the function Timestamp_get64. What does the .hi (MSB 16 bits) and .lo(LSB 16 bits) return?

double delay=0.0f;

 Types_FreqHz freq;

 Types_Timestamp64 ts1;

 Types_Timestamp64 ts2;

 Timestamp_getFreq(&freq);

Timestamp_get64(&ts1);

    if (filter((int*) gRxBuffer,number_of_detector_rows,number_of_detector_per_row, (int*) gTxImgBuffer, number_of_projections, &delay, &pixel_width) < 0)

       {

          send_error_page(htmlSock, "Error in running filter");

           return 1;

      }

      Timestamp_get64(&ts2);

    ts2.lo = ts2.lo - ts1.lo;

    delay = ((double)ts2.lo / (double)freq.lo) * 1000;

 

Regards,

Sohal

 

 

  • Hi Sohal,

    For DSP benchmarking, I suggest you use the TSC (time stamp counter) instead.

     

    Here is some reference :

    http://processors.wiki.ti.com/index.php/Porting_GPP_code_to_DSP_and_Codec_Engine#Benchmark_Code_on_DSP_using_the_Time_Stamp_Counter_.28TSC.29

     

    Hope this helps.

  • Sohal,

    With the C66x core and SYS/BIOS, the Timestamp_get32 and Timestamp_get64 functions use the CorePac's built-in cycle counter, called the Time Stamp Counter. This is the most reliable counter for benchmarking. It is a 64-bit counter, described in the CPU & Instruction Set Reference Guide.

    How long do you expect your filter function to take to execute? Is it several seconds?

    At 1GHz DSP clock speed, the lower 32 bits of the TSC will overflow every 4 seconds. It will start counting whenever SYS/BIOS starts it by writing to the TSCL register, and it will never reset until the DSP core is reset or the device is reset. If you have a lot of processing that happens before you get to your benchmarking code, the TSC could have counted far enough to contribute to a 32-bit overflow.

    The best starting place is to use the full 64-bit version of the function and use the full 64-bit data in your calculation. Do not simply use the lower 32 bits and do not convert to double-precision floating point. You can create an unsigned long long using _itoll( t64.hi, t64.lo ). Or you can just print out the top and bottom halves to see what you are working with using

    Types_Timestamp64 result;
    Timestamp_get64(&result);
    System_printf("Timestamp64 = %08u %08u\n", result.hi, result.lo);

    I just now added the "08", but I think the syntax is correct.

    By looking at the raw numbers, you take out the conversions and math functions that could be part of your problem. Once you have figured out why you are getting bad timing results, you can adjust your display functions to work the way you want them to work.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Hi!

    Thanks RandyP and Varada for the timely reply..

    The processing  takes about 1minute and 14 seconds  to complete.

    So how can I calculate the time and display it . Is there any other option other than the time stamp counter

    regards,

    Sohal

  • Sohal,

    It depends on the accuracy that you require. TSC will give the best accuracy possible.

    You could also use the BIOS timer functions to call a periodic function that increments a counter. If you want to do that extra work, please refer to the SYS/BIOS documentation and examples, or post to the BIOS forum for smarter people on BIOS.

    Why do you not want to use TSC? The 64-bit version will not overflow for 6,000 years if my math is correct, at 1GHz.

    Regards,
    RandyP