cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
leonardo_suriano
Participant
Participant
4,619 Views
Registered: ‎01-13-2017

"sds_clock_counter()" function

Jump to solution

In the UG1027 is described how to use the function unsigned long long sds_clock_counter(void);

The question is: are the function "clock()" and "sds_cloc_counter()" different in some way? if yes in what? After, using the variable CLOCKS_PER_SEC, it seems to give me not realistic value.

 

code snippet:

 

unsigned long long start_t, end_t;
start_t = sds_clock_counter();
for(int h=0;h<100;h++)
{sobel(352/*width*/,38/*height*/,output_93632__input__0,output__input_93632__0);} // Sobel_
end_t = sds_clock_counter();
double total_t_100;
total_t_100 = (double)(end_t - start_t) / CLOCKS_PER_SEC;

printf("\tSW= %20f - %20d\n",total_t_100/100,end_t - start_t);

 

However, how to use it for measuring hw? Is enough something like:

 

unsigned long long start_t, end_t;
start_t = sds_clock_counter();

 

#pragma SDS async(1)
#pragma SDS resource(1)
sobel_hw(output_26752__input__0,output__input_26752__0); // Sobel_2
// sobel(352/*width*/,38/*height*/,output_26752__input__0,output__input_26752__0);
sds_wait(1); // #pragma SDS wait(1)

end_t = sds_clock_counter();
double total_t_100;
total_t_100 = (double)(end_t - start_t) / CLOCKS_PER_SEC;

printf("\tSW= %20f - %20d\n",total_t_100/100,end_t - start_t);

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
wsun
Observer
Observer
7,459 Views
Registered: ‎05-26-2016

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.

View solution in original post

0 Kudos
3 Replies
wsun
Observer
Observer
7,460 Views
Registered: ‎05-26-2016

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.

View solution in original post

0 Kudos
leonardo_suriano
Participant
Participant
4,525 Views
Registered: ‎01-13-2017

That's great! I will use it. The question is: can I measure the hw function using something like:

start_t = sds_clock_counter();

#pragma SDS async(1)
#pragma SDS resource(1)
sobel_hw(input,output);
#pragma SDS wait(1)

end_t = sds_clock_counter();

Will this strategy work properly (maybe up on a big number of hardware calls)?

0 Kudos
sskalick
Xilinx Employee
Xilinx Employee
4,114 Views
Registered: ‎06-29-2015

Hi leonardo_suriano,

 

What you're suggesting:

start_t = sds_clock_counter();

#pragma SDS async(1)
#pragma SDS resource(1)
sobel_hw(input,output);
#pragma SDS wait(1)

end_t = sds_clock_counter();

Will work to measure the overall time to start and wait for the sobel_hw function to complete. If you want to measure the time to just start the accelerator, and separately the time you need to wait for the accelerator to finish you can do something like:

start_0 = sds_clock_counter();

#pragma SDS async(1)
#pragma SDS resource(1)
sobel_hw(input,output);
end_0 = sds_clock_counter();

start_1 = sds_clock_counter();
#pragma SDS wait(1)
end_1 = sds_clock_counter();

Or you can use the tracing feature in SDSoC to automatically instrument both the software and hardware. You can turn this on in the GUI by clicking the "Enable event tracing" in the SDx Project Setting page for your project. If you're not using the GUI, you can add "-trace" to the link line when you call sds++. You can read more about SDSoC trace in UG1027 and UG1028

 

Sam

0 Kudos