diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-02-23 18:23:12 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-02-23 18:23:12 +0100 |
commit | 68eaefa5d4966d0130c64643b0554f05cec1ecf8 (patch) | |
tree | 8ba57c49dfdab06d01aa77f8bc9810f8431ee04a /bench | |
parent | 801440c5192d36967906a3a9639cf2f3f3a61784 (diff) |
update BTL (better timer, eigen2 => eigen3, etc)
Diffstat (limited to 'bench')
-rw-r--r-- | bench/btl/CMakeLists.txt | 2 | ||||
-rw-r--r-- | bench/btl/data/perlib_plot_settings.txt | 6 | ||||
-rw-r--r-- | bench/btl/generic_bench/bench_parameter.hh | 4 | ||||
-rw-r--r-- | bench/btl/generic_bench/timers/portable_perf_analyzer.hh | 29 | ||||
-rwxr-xr-x | bench/btl/generic_bench/timers/portable_timer.hh | 60 | ||||
-rw-r--r-- | bench/btl/libs/eigen2/CMakeLists.txt | 72 |
6 files changed, 90 insertions, 83 deletions
diff --git a/bench/btl/CMakeLists.txt b/bench/btl/CMakeLists.txt index af234624a..5855c0d9e 100644 --- a/bench/btl/CMakeLists.txt +++ b/bench/btl/CMakeLists.txt @@ -70,7 +70,7 @@ MACRO(BTL_ADD_BENCH targetname) IF(BUILD_${targetname}) ADD_EXECUTABLE(${targetname} ${_sources}) ADD_TEST(${targetname} "${targetname}") - target_link_libraries(${targetname} ${DEFAULT_LIBRARIES}) + target_link_libraries(${targetname} ${DEFAULT_LIBRARIES} rt) ENDIF(BUILD_${targetname}) ENDMACRO(BTL_ADD_BENCH) diff --git a/bench/btl/data/perlib_plot_settings.txt b/bench/btl/data/perlib_plot_settings.txt index d45f4ff98..4c253f450 100644 --- a/bench/btl/data/perlib_plot_settings.txt +++ b/bench/btl/data/perlib_plot_settings.txt @@ -1,6 +1,6 @@ -eigen2 ; with lines lw 4 lt 1 lc rgbcolor "black" -eigen2_novec ; with lines lw 2 lt 1 lc rgbcolor "#999999" -eigen2_nogccvec ; with lines lw 2 lt 2 lc rgbcolor "#991010" +eigen3 ; with lines lw 4 lt 1 lc rgbcolor "black" +eigen3_novec ; with lines lw 2 lt 1 lc rgbcolor "#999999" +eigen3_nogccvec ; with lines lw 2 lt 2 lc rgbcolor "#991010" INTEL_MKL ; with lines lw 3 lt 2 lc rgbcolor "#00b7ff" ATLAS ; with lines lw 3 lt 1 lc rgbcolor "#52e657" gmm ; with lines lw 3 lt 1 lc rgbcolor "#0000ff" diff --git a/bench/btl/generic_bench/bench_parameter.hh b/bench/btl/generic_bench/bench_parameter.hh index e9603e4fc..d14340037 100644 --- a/bench/btl/generic_bench/bench_parameter.hh +++ b/bench/btl/generic_bench/bench_parameter.hh @@ -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 diff --git a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh index 4298e61df..6b1f8e7d7 100644 --- a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh +++ b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh @@ -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; }; diff --git a/bench/btl/generic_bench/timers/portable_timer.hh b/bench/btl/generic_bench/timers/portable_timer.hh index 30fc4e883..42528d113 100755 --- a/bench/btl/generic_bench/timers/portable_timer.hh +++ b/bench/btl/generic_bench/timers/portable_timer.hh @@ -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 diff --git a/bench/btl/libs/eigen2/CMakeLists.txt b/bench/btl/libs/eigen2/CMakeLists.txt index 177247077..2d2f74ee2 100644 --- a/bench/btl/libs/eigen2/CMakeLists.txt +++ b/bench/btl/libs/eigen2/CMakeLists.txt @@ -1,57 +1,57 @@ -# find_package(MKL) + find_package(Eigen2) if (EIGEN2_FOUND) include_directories(${EIGEN2_INCLUDE_DIR}) - btl_add_bench(btl_eigen2_linear main_linear.cpp) - btl_add_bench(btl_eigen2_vecmat main_vecmat.cpp) - btl_add_bench(btl_eigen2_matmat main_matmat.cpp) - btl_add_bench(btl_eigen2_adv main_adv.cpp ) + btl_add_bench(btl_eigen3_linear main_linear.cpp) + btl_add_bench(btl_eigen3_vecmat main_vecmat.cpp) + btl_add_bench(btl_eigen3_matmat main_matmat.cpp) + btl_add_bench(btl_eigen3_adv main_adv.cpp ) - btl_add_target_property(btl_eigen2_linear COMPILE_FLAGS "-DBTL_PREFIX=eigen2") - btl_add_target_property(btl_eigen2_vecmat COMPILE_FLAGS "-DBTL_PREFIX=eigen2") - btl_add_target_property(btl_eigen2_matmat COMPILE_FLAGS "-DBTL_PREFIX=eigen2") - btl_add_target_property(btl_eigen2_adv COMPILE_FLAGS "-DBTL_PREFIX=eigen2") + btl_add_target_property(btl_eigen3_linear COMPILE_FLAGS "-fno-exceptions -DBTL_PREFIX=eigen3") + btl_add_target_property(btl_eigen3_vecmat COMPILE_FLAGS "-fno-exceptions -DBTL_PREFIX=eigen3") + btl_add_target_property(btl_eigen3_matmat COMPILE_FLAGS "-fno-exceptions -DBTL_PREFIX=eigen3") + btl_add_target_property(btl_eigen3_adv COMPILE_FLAGS "-fno-exceptions -DBTL_PREFIX=eigen3") option(BTL_BENCH_NOGCCVEC "also bench Eigen explicit vec without GCC's auto vec" OFF) if(CMAKE_COMPILER_IS_GNUCXX AND BTL_BENCH_NOGCCVEC) - btl_add_bench(btl_eigen2_nogccvec_linear main_linear.cpp) - btl_add_bench(btl_eigen2_nogccvec_vecmat main_vecmat.cpp) - btl_add_bench(btl_eigen2_nogccvec_matmat main_matmat.cpp) - btl_add_bench(btl_eigen2_nogccvec_adv main_adv.cpp ) - - btl_add_target_property(btl_eigen2_nogccvec_linear COMPILE_FLAGS "-fno-tree-vectorize -DBTL_PREFIX=eigen2_nogccvec") - btl_add_target_property(btl_eigen2_nogccvec_vecmat COMPILE_FLAGS "-fno-tree-vectorize -DBTL_PREFIX=eigen2_nogccvec") - btl_add_target_property(btl_eigen2_nogccvec_matmat COMPILE_FLAGS "-fno-tree-vectorize -DBTL_PREFIX=eigen2_nogccvec") - btl_add_target_property(btl_eigen2_nogccvec_adv COMPILE_FLAGS "-fno-tree-vectorize -DBTL_PREFIX=eigen2_nogccvec") + btl_add_bench(btl_eigen3_nogccvec_linear main_linear.cpp) + btl_add_bench(btl_eigen3_nogccvec_vecmat main_vecmat.cpp) + btl_add_bench(btl_eigen3_nogccvec_matmat main_matmat.cpp) + btl_add_bench(btl_eigen3_nogccvec_adv main_adv.cpp ) + + btl_add_target_property(btl_eigen3_nogccvec_linear COMPILE_FLAGS "-fno-exceptions -fno-tree-vectorize -DBTL_PREFIX=eigen3_nogccvec") + btl_add_target_property(btl_eigen3_nogccvec_vecmat COMPILE_FLAGS "-fno-exceptions -fno-tree-vectorize -DBTL_PREFIX=eigen3_nogccvec") + btl_add_target_property(btl_eigen3_nogccvec_matmat COMPILE_FLAGS "-fno-exceptions -fno-tree-vectorize -DBTL_PREFIX=eigen3_nogccvec") + btl_add_target_property(btl_eigen3_nogccvec_adv COMPILE_FLAGS "-fno-exceptions -fno-tree-vectorize -DBTL_PREFIX=eigen3_nogccvec") endif() if(NOT BTL_NOVEC) - btl_add_bench(btl_eigen2_novec_linear main_linear.cpp) - btl_add_bench(btl_eigen2_novec_vecmat main_vecmat.cpp) - btl_add_bench(btl_eigen2_novec_matmat main_matmat.cpp) - btl_add_bench(btl_eigen2_novec_adv main_adv.cpp ) - btl_add_target_property(btl_eigen2_novec_linear COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen2_novec") - btl_add_target_property(btl_eigen2_novec_vecmat COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen2_novec") - btl_add_target_property(btl_eigen2_novec_matmat COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen2_novec") - btl_add_target_property(btl_eigen2_novec_adv COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen2_novec") - -# if(BUILD_btl_eigen2_adv) -# target_link_libraries(btl_eigen2_adv ${MKL_LIBRARIES}) -# endif(BUILD_btl_eigen2_adv) + btl_add_bench(btl_eigen3_novec_linear main_linear.cpp) + btl_add_bench(btl_eigen3_novec_vecmat main_vecmat.cpp) + btl_add_bench(btl_eigen3_novec_matmat main_matmat.cpp) + btl_add_bench(btl_eigen3_novec_adv main_adv.cpp ) + btl_add_target_property(btl_eigen3_novec_linear COMPILE_FLAGS "-fno-exceptions -DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen3_novec") + btl_add_target_property(btl_eigen3_novec_vecmat COMPILE_FLAGS "-fno-exceptions -DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen3_novec") + btl_add_target_property(btl_eigen3_novec_matmat COMPILE_FLAGS "-fno-exceptions -DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen3_novec") + btl_add_target_property(btl_eigen3_novec_adv COMPILE_FLAGS "-fno-exceptions -DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen3_novec") + +# if(BUILD_btl_eigen3_adv) +# target_link_libraries(btl_eigen3_adv ${MKL_LIBRARIES}) +# endif(BUILD_btl_eigen3_adv) endif(NOT BTL_NOVEC) - btl_add_bench(btl_tiny_eigen2 btl_tiny_eigen2.cpp OFF) + btl_add_bench(btl_tiny_eigen3 btl_tiny_eigen3.cpp OFF) if(NOT BTL_NOVEC) - btl_add_bench(btl_tiny_eigen2_novec btl_tiny_eigen2.cpp OFF) - btl_add_target_property(btl_tiny_eigen2_novec COMPILE_FLAGS "-DBTL_PREFIX=eigen2_tiny") + btl_add_bench(btl_tiny_eigen3_novec btl_tiny_eigen3.cpp OFF) + btl_add_target_property(btl_tiny_eigen3_novec COMPILE_FLAGS "-DBTL_PREFIX=eigen3_tiny") - if(BUILD_btl_tiny_eigen2_novec) - btl_add_target_property(btl_tiny_eigen2_novec COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen2_tiny_novec") - endif(BUILD_btl_tiny_eigen2_novec) + if(BUILD_btl_tiny_eigen3_novec) + btl_add_target_property(btl_tiny_eigen3_novec COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE -DBTL_PREFIX=eigen3_tiny_novec") + endif(BUILD_btl_tiny_eigen3_novec) endif(NOT BTL_NOVEC) endif (EIGEN2_FOUND) |