UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
3,435 Views
Registered: ‎04-19-2017

Execution time measurement in SDSoC

Hello,

 

I run an algorithm on Zybo PS using Linux platform. Some functions are accelerated in PL using SDSoC. I want to measure the execution time of my program. I use

 

clock_t start, end;
start = clock();

 

... some functions executed in PS

... some functions accelerated in PL

... some functions executed in PS

 

end = clock();

printf("The execution time is : %f\n", ((double)(end  - start)) / CLOCKS_PER_SEC);

 

Is this a good method to measure the execution time? I ask this because I obtain the same results if some functions are implemented in hardware or if there isn't any function implemented in hardware.

 

Thank you!

Tags (1)
0 Kudos
4 Replies
Participant leonardo_suriano
Participant
3,385 Views
Registered: ‎01-13-2017

Re: Execution time measurement in SDSoC

Just re-coping the same answer that I had for a similar question:

 

"Please use the sds_clock_counter(). This is the code in SDSoC release folder (samples/mmult_optimized)

 

class perf_counter
{
public:
  uint64_t tot, cnt, calls;
  perf_counter() : tot(0), cnt(0), calls(0) {};
  inline void reset() { tot = cnt = calls = 0; }
  inline void start() { cnt = sds_clock_counter(); calls++; };
  inline void stop() { tot += (sds_clock_counter() - cnt); };
  inline uint64_t avg_cpu_cycles() { return (tot / calls); };
};

Please refer to the platform information for CPU frequency."

 

answer by WSUN

0 Kudos
Contributor
Contributor
3,045 Views
Registered: ‎04-19-2017

Re: Execution time measurement in SDSoC

Thank you for the response. I tried sds_clock_counter() function. Although, something strange happen. The structure of my program is the following:

 

    unsigned long long startC = 0;
    unsigned long long endC = 0;

    startC = sds_clock_counter();

 

... some functions executed in PS

... some functions executed in PL

... some functions executed in PS

 

    endC = sds_clock_counter();

    printf("The execution time is : %ld\n", endC  - startC);

 

As I mentioned before I use Linux platform. First time when I run the program a value is printed: "7". Than if I run again the program this value is increased, 1st run 7, 2nd run 10, 3rd run 13 etc. What means this value?(cycles of processor?) Why is this value increased each time the application is run?

 

Thank you!

 

0 Kudos
Contributor
Contributor
3,022 Views
Registered: ‎04-19-2017

Re: Execution time measurement in SDSoC

I found this in the SDSoC Documentation:

sds_clock_counter(void):

- return value of free-running 64-bit Zynq(TM) global counter

- Returns the value associated with a free-running counter used for fine-grain time-interval measurements. The counter counts ARM CPU clock cycles, and wraps to zero.

 

I still don't know why the difference between two timestamps is not constant for consecutive program runs.

0 Kudos
Contributor
Contributor
297 Views
Registered: ‎06-20-2019

Re: Execution time measurement in SDSoC

Correct me if I am wrong but isn't it normal? shouldn't the period change? As a result, it is a hardware and there are many reasons for it not to be stable(such as heat). I believe that if you send some functions for no purpose before executing the main function of yours and then execute your main function, you get a more accurate result.  I believe that it is so normal for you to get different results since it is hardware.

0 Kudos