cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
377 Views
Registered: ‎06-20-2019

sdsoc hw counter usage

Jump to solution

Hello,

 

I am trying to develop fft application by using sdsoc. I am trying to measure time and to do that, I am using the class which can be utilized by including
"sds_lib.h" and provided below.  I am using the functions and getting count of clock cycles but I do not know the frequency. How am i supposed to know that? Yes, I can measure the time by using soft counters but they are not so accurate. Speed may change even in accordance with heat. Thus, soft counter is not good choice. It would be nice if you can guide. Thanks

 

#include "sds_lib.h"

#ifndef _PERF_COUNTER_
#define _PERF_COUNTER_

class perf_counter{

private:
uint64_t tot, cnt, calls;

public:

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); };
};

#endif

  

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Moderator
Moderator
279 Views
Registered: ‎08-20-2018

Hi @yhy.xilinx 

There is SDS utility perf_counter.

Please refer example below

https://github.com/Xilinx/SDSoC_Examples/blob/master/cpp/getting_started/shift_register/src/main.cpp

Best Regards,
Nutan
-------------------------------------------------------------------------------
Please don't forget to reply, kudo and accept as a solution

View solution in original post

2 Replies
Highlighted
Adventurer
Adventurer
342 Views
Registered: ‎06-20-2019
I have found sds_clock_frequency() function during checking the library and I am checking the elapsed time with (1000.0)*(1000.0)/sds_clock_frequency())*(double)(m_perf_counter.avg_cpu_cycles() in us. what do you think? is there anyway for me to get more accurate?
0 Kudos
Highlighted
Moderator
Moderator
280 Views
Registered: ‎08-20-2018

Hi @yhy.xilinx 

There is SDS utility perf_counter.

Please refer example below

https://github.com/Xilinx/SDSoC_Examples/blob/master/cpp/getting_started/shift_register/src/main.cpp

Best Regards,
Nutan
-------------------------------------------------------------------------------
Please don't forget to reply, kudo and accept as a solution

View solution in original post