mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
update BTL (better timer, eigen2 => eigen3, etc)
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// minimal time for each measurement
|
||||
#define REAL_TYPE float
|
||||
// minimal time for each measurement
|
||||
#define MIN_TIME 0.5
|
||||
#define MIN_TIME 0.2
|
||||
// nb of point on bench curves
|
||||
#define NB_POINT 100
|
||||
// min vector size for axpy bench
|
||||
@@ -48,6 +48,6 @@
|
||||
#define DEFAULT_NB_SAMPLE 1000
|
||||
|
||||
// how many times we run a single bench (keep the best perf)
|
||||
#define NB_TRIES 5
|
||||
#define NB_TRIES 3
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,41 +27,41 @@
|
||||
template <class Action>
|
||||
class Portable_Perf_Analyzer{
|
||||
public:
|
||||
Portable_Perf_Analyzer( void ):_nb_calc(1),_chronos(){
|
||||
Portable_Perf_Analyzer( ):_nb_calc(0), m_time_action(0), _chronos(){
|
||||
MESSAGE("Portable_Perf_Analyzer Ctor");
|
||||
};
|
||||
Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){
|
||||
INFOS("Copy Ctor not implemented");
|
||||
exit(0);
|
||||
};
|
||||
~Portable_Perf_Analyzer( void ){
|
||||
~Portable_Perf_Analyzer(){
|
||||
MESSAGE("Portable_Perf_Analyzer Dtor");
|
||||
};
|
||||
|
||||
BTL_DONT_INLINE double eval_mflops(int size)
|
||||
BTL_DONT_INLINE double eval_mflops(int size)
|
||||
{
|
||||
Action action(size);
|
||||
|
||||
double time_action = 0;
|
||||
action.initialize();
|
||||
time_action = time_calculate(action);
|
||||
while (time_action < MIN_TIME)
|
||||
// action.initialize();
|
||||
// time_action = time_calculate(action);
|
||||
while (m_time_action < MIN_TIME)
|
||||
{
|
||||
_nb_calc *= 2;
|
||||
if(_nb_calc==0) _nb_calc = 1;
|
||||
else _nb_calc *= 2;
|
||||
action.initialize();
|
||||
time_action = time_calculate(action);
|
||||
m_time_action = time_calculate(action);
|
||||
}
|
||||
|
||||
// optimize
|
||||
for (int i=1; i<NB_TRIES; ++i)
|
||||
{
|
||||
Action _action(size);
|
||||
std::cout << " " << _action.nb_op_base()*_nb_calc/(time_action*1e6) << " ";
|
||||
std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " ";
|
||||
_action.initialize();
|
||||
time_action = std::min(time_action, time_calculate(_action));
|
||||
m_time_action = std::min(m_time_action, time_calculate(_action));
|
||||
}
|
||||
|
||||
time_action = time_action / (double(_nb_calc));
|
||||
double time_action = m_time_action / (double(_nb_calc));
|
||||
|
||||
// check
|
||||
if (BtlConfig::Instance.checkResults && size<128)
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
action.calculate();
|
||||
action.check_result();
|
||||
}
|
||||
return action.nb_op_base()/(time_action*1000000.0);
|
||||
return action.nb_op_base()/(time_action*1e6);
|
||||
}
|
||||
|
||||
BTL_DONT_INLINE double time_calculate(Action & action)
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
return _chronos.user_time();
|
||||
}
|
||||
|
||||
unsigned long long get_nb_calc( void )
|
||||
unsigned long long get_nb_calc()
|
||||
{
|
||||
return _nb_calc;
|
||||
}
|
||||
@@ -94,6 +94,7 @@ public:
|
||||
|
||||
private:
|
||||
unsigned long long _nb_calc;
|
||||
double m_time_action;
|
||||
Portable_Timer _chronos;
|
||||
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
double LIToSecs(LARGE_INTEGER& L) {
|
||||
return ((double)L.QuadPart /(double)frequency.QuadPart) ;
|
||||
}
|
||||
@@ -98,34 +98,37 @@ class Portable_Timer
|
||||
{
|
||||
public:
|
||||
|
||||
Portable_Timer( void ):_utime_sec_start(-1),
|
||||
_utime_usec_start(-1),
|
||||
_utime_sec_stop(-1),
|
||||
_utime_usec_stop(-1)/*,
|
||||
m_prev_cs(-1)*/
|
||||
Portable_Timer( void )
|
||||
// :_utime_sec_start(-1),
|
||||
// _utime_usec_start(-1),
|
||||
// _utime_sec_stop(-1),
|
||||
// _utime_usec_stop(-1)/*,
|
||||
// m_prev_cs(-1)*/
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void start()
|
||||
{
|
||||
int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
|
||||
// _start_time = std::clock();
|
||||
_utime_sec_start = resourcesUsage.ru_utime.tv_sec ;
|
||||
_utime_usec_start = resourcesUsage.ru_utime.tv_usec ;
|
||||
// m_prev_cs = resourcesUsage.ru_nivcsw;
|
||||
// int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
|
||||
// _utime_sec_start = resourcesUsage.ru_utime.tv_sec ;
|
||||
// _utime_usec_start = resourcesUsage.ru_utime.tv_usec ;
|
||||
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
|
||||
m_start_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
|
||||
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
|
||||
// _stop_time = std::clock();
|
||||
_utime_sec_stop = resourcesUsage.ru_utime.tv_sec ;
|
||||
_utime_usec_stop = resourcesUsage.ru_utime.tv_usec ;
|
||||
// int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
|
||||
// _utime_sec_stop = resourcesUsage.ru_utime.tv_sec ;
|
||||
// _utime_usec_stop = resourcesUsage.ru_utime.tv_usec ;
|
||||
|
||||
// m_prev_cs = resourcesUsage.ru_nivcsw - m_prev_cs;
|
||||
// std::cerr << resourcesUsage.ru_nvcsw << " + " << resourcesUsage.ru_nivcsw << "\n";
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
|
||||
m_stop_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
|
||||
|
||||
}
|
||||
|
||||
@@ -137,26 +140,29 @@ class Portable_Timer
|
||||
double user_time()
|
||||
{
|
||||
// std::cout << m_prev_cs << "\n";
|
||||
long tot_utime_sec=_utime_sec_stop-_utime_sec_start;
|
||||
long tot_utime_usec=_utime_usec_stop-_utime_usec_start;
|
||||
return double(tot_utime_sec)+ double(tot_utime_usec)/double(USEC_IN_SEC) ;
|
||||
// long tot_utime_sec=_utime_sec_stop-_utime_sec_start;
|
||||
// long tot_utime_usec=_utime_usec_stop-_utime_usec_start;
|
||||
// return double(tot_utime_sec)+ double(tot_utime_usec)/double(USEC_IN_SEC) ;
|
||||
return m_stop_time - m_start_time;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
struct rusage resourcesUsage ;
|
||||
// struct rusage resourcesUsage ;
|
||||
|
||||
long _utime_sec_start ;
|
||||
long _utime_usec_start ;
|
||||
// long _utime_sec_start ;
|
||||
// long _utime_usec_start ;
|
||||
|
||||
long _utime_sec_stop ;
|
||||
long _utime_usec_stop ;
|
||||
// long _utime_sec_stop ;
|
||||
// long _utime_usec_stop ;
|
||||
|
||||
// long m_prev_cs;
|
||||
|
||||
std::clock_t _start_time;
|
||||
std::clock_t _stop_time;
|
||||
// std::clock_t _start_time;
|
||||
// std::clock_t _stop_time;
|
||||
|
||||
double m_stop_time, m_start_time;
|
||||
|
||||
}; // Portable_Timer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user