From 28539e7597c643dbc2b8d4f49dd16bd86fb7251f Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 9 Jul 2008 14:04:48 +0000 Subject: [PATCH] imported a reworked version of BTL (Benchmark for Templated Libraries). the modifications to initial code follow: * changed build system from plain makefiles to cmake * added eigen2 (4 versions: vec/novec and fixed/dynamic), GMM++, MTL4 interfaces * added "transposed matrix * vector" product action * updated blitz interface to use condensed products instead of hand coded loops * removed some deprecated interfaces * changed default storage order to column major for all libraries * new generic bench timer strategy which is supposed to be more accurate * various code clean-up --- CMakeLists.txt | 13 +- bench/btl/CMakeLists.txt | 74 ++++ bench/btl/COPYING | 340 ++++++++++++++++++ bench/btl/README | 143 ++++++++ bench/btl/actions/action_aat_product.hh | 145 ++++++++ bench/btl/actions/action_ata_product.hh | 145 ++++++++ bench/btl/actions/action_atv_product.hh | 131 +++++++ bench/btl/actions/action_axpy.hh | 137 +++++++ bench/btl/actions/action_lu_solve.hh | 136 +++++++ .../actions/action_matrix_matrix_product.hh | 152 ++++++++ .../action_matrix_matrix_product_bis.hh | 152 ++++++++ .../actions/action_matrix_vector_product.hh | 154 ++++++++ bench/btl/cmake/FindBlitz.cmake | 40 +++ bench/btl/cmake/FindCBLAS.cmake | 34 ++ bench/btl/cmake/FindEigen.cmake | 30 ++ bench/btl/cmake/FindEigen2.cmake | 32 ++ bench/btl/cmake/FindGMM.cmake | 17 + .../cmake/MacroOptionalAddSubdirectory.cmake | 31 ++ bench/btl/data/CMakeLists.txt | 18 + bench/btl/data/aat.hh | 108 ++++++ bench/btl/data/ata.hh | 108 ++++++ bench/btl/data/axpy.hh | 108 ++++++ bench/btl/data/go_mean | 9 + bench/btl/data/matrix_matrix.hh | 108 ++++++ bench/btl/data/matrix_vector.hh | 108 ++++++ bench/btl/data/mean.cxx | 207 +++++++++++ bench/btl/data/mk_gnuplot_script.sh | 68 ++++ bench/btl/data/mk_mean_script.sh | 39 ++ bench/btl/data/mk_new_gnuplot.sh | 45 +++ bench/btl/data/order_lib | 8 + bench/btl/data/regularize.cxx | 131 +++++++ bench/btl/data/smooth.cxx | 198 ++++++++++ bench/btl/data/smooth_all.sh | 68 ++++ bench/btl/generic_bench/bench.hh | 90 +++++ bench/btl/generic_bench/bench_parameter.hh | 53 +++ bench/btl/generic_bench/init/init_function.hh | 55 +++ bench/btl/generic_bench/init/init_matrix.hh | 53 +++ bench/btl/generic_bench/init/init_vector.hh | 37 ++ .../btl/generic_bench/static/bench_static.hh | 75 ++++ .../static/intel_bench_fixed_size.hh | 66 ++++ .../static/static_size_generator.hh | 56 +++ .../generic_bench/timers/STL_perf_analyzer.hh | 82 +++++ bench/btl/generic_bench/timers/STL_timer.hh | 78 ++++ .../timers/mixed_perf_analyzer.hh | 73 ++++ .../timers/portable_perf_analyzer.hh | 98 +++++ .../timers/portable_perf_analyzer_old.hh | 134 +++++++ .../generic_bench/timers/portable_timer.hh | 103 ++++++ .../generic_bench/timers/x86_perf_analyzer.hh | 108 ++++++ bench/btl/generic_bench/timers/x86_timer.hh | 246 +++++++++++++ .../btl/generic_bench/utils/dump_file_x_y.hh | 47 +++ bench/btl/generic_bench/utils/size_lin_log.hh | 70 ++++ bench/btl/generic_bench/utils/size_log.hh | 54 +++ bench/btl/generic_bench/utils/utilities.h | 90 +++++ .../libs/ATLAS/ATLAS_LU_solve_interface.hh | 118 ++++++ bench/btl/libs/ATLAS/ATLAS_interface.hh | 120 +++++++ bench/btl/libs/ATLAS/CMakeLists.txt | 4 + bench/btl/libs/ATLAS/main.cpp | 49 +++ bench/btl/libs/ATLAS/titi.txt | 33 ++ bench/btl/libs/C/CMakeLists.txt | 2 + bench/btl/libs/C/C_interface.hh | 96 +++++ bench/btl/libs/C/main.cpp | 44 +++ bench/btl/libs/C_BLAS/CMakeLists.txt | 4 + bench/btl/libs/C_BLAS/C_BLAS_interface.hh | 131 +++++++ bench/btl/libs/C_BLAS/main.cpp | 49 +++ .../INTEL_BLAS_LU_solve_interface.hh | 127 +++++++ .../libs/INTEL_BLAS/INTEL_BLAS_interface.hh | 95 +++++ bench/btl/libs/INTEL_BLAS/config.sh | 2 + bench/btl/libs/INTEL_BLAS/main.cpp | 49 +++ bench/btl/libs/STL/CMakeLists.txt | 2 + bench/btl/libs/STL/STL_interface.hh | 190 ++++++++++ bench/btl/libs/STL/main.cpp | 43 +++ bench/btl/libs/STL_algo/CMakeLists.txt | 2 + bench/btl/libs/STL_algo/STL_algo_interface.hh | 138 +++++++ bench/btl/libs/STL_algo/main.cpp | 37 ++ bench/btl/libs/blitz/CMakeLists.txt | 4 + .../libs/blitz/blitz_LU_solve_interface.hh | 192 ++++++++++ bench/btl/libs/blitz/blitz_interface.hh | 147 ++++++++ bench/btl/libs/blitz/main.cpp | 49 +++ bench/btl/libs/eigen2/CMakeLists.txt | 8 + .../libs/eigen2/eigen2_LU_solve_interface.hh | 192 ++++++++++ bench/btl/libs/eigen2/eigen2_interface.hh | 128 +++++++ bench/btl/libs/eigen2/main.cpp | 49 +++ bench/btl/libs/f77/CMakeLists.txt | 3 + bench/btl/libs/f77/daat.f | 14 + bench/btl/libs/f77/data.f | 14 + bench/btl/libs/f77/daxpy.f | 18 + bench/btl/libs/f77/dmxm.f | 32 ++ bench/btl/libs/f77/dmxm.f.mfr | 36 ++ bench/btl/libs/f77/dmxv.f | 39 ++ bench/btl/libs/f77/f77_interface.hh | 145 ++++++++ bench/btl/libs/f77/f77_interface_base.hh | 91 +++++ bench/btl/libs/f77/main.cpp | 46 +++ bench/btl/libs/f77/saat.f | 14 + bench/btl/libs/f77/sata.f | 14 + bench/btl/libs/f77/saxpy.f | 16 + bench/btl/libs/f77/smxm.f | 32 ++ bench/btl/libs/f77/smxv.f | 38 ++ bench/btl/libs/f77/test_interface.hh | 36 ++ bench/btl/libs/gmm/CMakeLists.txt | 3 + bench/btl/libs/gmm/gmm_LU_solve_interface.hh | 192 ++++++++++ bench/btl/libs/gmm/gmm_interface.hh | 119 ++++++ bench/btl/libs/gmm/main.cpp | 44 +++ bench/btl/libs/mtl4/.kdbgrc.main | 12 + bench/btl/libs/mtl4/main.cpp | 42 +++ .../btl/libs/mtl4/mtl4_LU_solve_interface.hh | 192 ++++++++++ bench/btl/libs/mtl4/mtl4_interface.hh | 120 +++++++ bench/btl/libs/tiny_blitz/CMakeLists.txt | 4 + bench/btl/libs/tiny_blitz/main.cpp | 37 ++ .../libs/tiny_blitz/tiny_blitz_interface.hh | 106 ++++++ bench/btl/libs/tvmet/CMakeLists.txt | 4 + bench/btl/libs/tvmet/main.cpp | 36 ++ bench/btl/libs/tvmet/tvmet_interface.hh | 141 ++++++++ bench/btl/libs/ublas/CMakeLists.txt | 3 + bench/btl/libs/ublas/main.cpp | 44 +++ bench/btl/libs/ublas/ublas_interface.hh | 131 +++++++ 115 files changed, 8825 insertions(+), 2 deletions(-) create mode 100644 bench/btl/CMakeLists.txt create mode 100644 bench/btl/COPYING create mode 100644 bench/btl/README create mode 100644 bench/btl/actions/action_aat_product.hh create mode 100644 bench/btl/actions/action_ata_product.hh create mode 100644 bench/btl/actions/action_atv_product.hh create mode 100644 bench/btl/actions/action_axpy.hh create mode 100644 bench/btl/actions/action_lu_solve.hh create mode 100644 bench/btl/actions/action_matrix_matrix_product.hh create mode 100644 bench/btl/actions/action_matrix_matrix_product_bis.hh create mode 100644 bench/btl/actions/action_matrix_vector_product.hh create mode 100644 bench/btl/cmake/FindBlitz.cmake create mode 100644 bench/btl/cmake/FindCBLAS.cmake create mode 100644 bench/btl/cmake/FindEigen.cmake create mode 100644 bench/btl/cmake/FindEigen2.cmake create mode 100644 bench/btl/cmake/FindGMM.cmake create mode 100644 bench/btl/cmake/MacroOptionalAddSubdirectory.cmake create mode 100644 bench/btl/data/CMakeLists.txt create mode 100644 bench/btl/data/aat.hh create mode 100644 bench/btl/data/ata.hh create mode 100644 bench/btl/data/axpy.hh create mode 100755 bench/btl/data/go_mean create mode 100644 bench/btl/data/matrix_matrix.hh create mode 100644 bench/btl/data/matrix_vector.hh create mode 100644 bench/btl/data/mean.cxx create mode 100644 bench/btl/data/mk_gnuplot_script.sh create mode 100644 bench/btl/data/mk_mean_script.sh create mode 100755 bench/btl/data/mk_new_gnuplot.sh create mode 100644 bench/btl/data/order_lib create mode 100644 bench/btl/data/regularize.cxx create mode 100644 bench/btl/data/smooth.cxx create mode 100755 bench/btl/data/smooth_all.sh create mode 100644 bench/btl/generic_bench/bench.hh create mode 100644 bench/btl/generic_bench/bench_parameter.hh create mode 100644 bench/btl/generic_bench/init/init_function.hh create mode 100644 bench/btl/generic_bench/init/init_matrix.hh create mode 100644 bench/btl/generic_bench/init/init_vector.hh create mode 100644 bench/btl/generic_bench/static/bench_static.hh create mode 100644 bench/btl/generic_bench/static/intel_bench_fixed_size.hh create mode 100644 bench/btl/generic_bench/static/static_size_generator.hh create mode 100644 bench/btl/generic_bench/timers/STL_perf_analyzer.hh create mode 100644 bench/btl/generic_bench/timers/STL_timer.hh create mode 100644 bench/btl/generic_bench/timers/mixed_perf_analyzer.hh create mode 100644 bench/btl/generic_bench/timers/portable_perf_analyzer.hh create mode 100644 bench/btl/generic_bench/timers/portable_perf_analyzer_old.hh create mode 100755 bench/btl/generic_bench/timers/portable_timer.hh create mode 100644 bench/btl/generic_bench/timers/x86_perf_analyzer.hh create mode 100644 bench/btl/generic_bench/timers/x86_timer.hh create mode 100644 bench/btl/generic_bench/utils/dump_file_x_y.hh create mode 100644 bench/btl/generic_bench/utils/size_lin_log.hh create mode 100644 bench/btl/generic_bench/utils/size_log.hh create mode 100644 bench/btl/generic_bench/utils/utilities.h create mode 100644 bench/btl/libs/ATLAS/ATLAS_LU_solve_interface.hh create mode 100644 bench/btl/libs/ATLAS/ATLAS_interface.hh create mode 100644 bench/btl/libs/ATLAS/CMakeLists.txt create mode 100644 bench/btl/libs/ATLAS/main.cpp create mode 100644 bench/btl/libs/ATLAS/titi.txt create mode 100644 bench/btl/libs/C/CMakeLists.txt create mode 100755 bench/btl/libs/C/C_interface.hh create mode 100644 bench/btl/libs/C/main.cpp create mode 100644 bench/btl/libs/C_BLAS/CMakeLists.txt create mode 100644 bench/btl/libs/C_BLAS/C_BLAS_interface.hh create mode 100644 bench/btl/libs/C_BLAS/main.cpp create mode 100644 bench/btl/libs/INTEL_BLAS/INTEL_BLAS_LU_solve_interface.hh create mode 100644 bench/btl/libs/INTEL_BLAS/INTEL_BLAS_interface.hh create mode 100755 bench/btl/libs/INTEL_BLAS/config.sh create mode 100644 bench/btl/libs/INTEL_BLAS/main.cpp create mode 100644 bench/btl/libs/STL/CMakeLists.txt create mode 100644 bench/btl/libs/STL/STL_interface.hh create mode 100644 bench/btl/libs/STL/main.cpp create mode 100644 bench/btl/libs/STL_algo/CMakeLists.txt create mode 100644 bench/btl/libs/STL_algo/STL_algo_interface.hh create mode 100644 bench/btl/libs/STL_algo/main.cpp create mode 100644 bench/btl/libs/blitz/CMakeLists.txt create mode 100644 bench/btl/libs/blitz/blitz_LU_solve_interface.hh create mode 100644 bench/btl/libs/blitz/blitz_interface.hh create mode 100644 bench/btl/libs/blitz/main.cpp create mode 100644 bench/btl/libs/eigen2/CMakeLists.txt create mode 100644 bench/btl/libs/eigen2/eigen2_LU_solve_interface.hh create mode 100644 bench/btl/libs/eigen2/eigen2_interface.hh create mode 100644 bench/btl/libs/eigen2/main.cpp create mode 100644 bench/btl/libs/f77/CMakeLists.txt create mode 100644 bench/btl/libs/f77/daat.f create mode 100644 bench/btl/libs/f77/data.f create mode 100644 bench/btl/libs/f77/daxpy.f create mode 100644 bench/btl/libs/f77/dmxm.f create mode 100644 bench/btl/libs/f77/dmxm.f.mfr create mode 100644 bench/btl/libs/f77/dmxv.f create mode 100644 bench/btl/libs/f77/f77_interface.hh create mode 100644 bench/btl/libs/f77/f77_interface_base.hh create mode 100644 bench/btl/libs/f77/main.cpp create mode 100644 bench/btl/libs/f77/saat.f create mode 100644 bench/btl/libs/f77/sata.f create mode 100644 bench/btl/libs/f77/saxpy.f create mode 100644 bench/btl/libs/f77/smxm.f create mode 100644 bench/btl/libs/f77/smxv.f create mode 100644 bench/btl/libs/f77/test_interface.hh create mode 100644 bench/btl/libs/gmm/CMakeLists.txt create mode 100644 bench/btl/libs/gmm/gmm_LU_solve_interface.hh create mode 100644 bench/btl/libs/gmm/gmm_interface.hh create mode 100644 bench/btl/libs/gmm/main.cpp create mode 100644 bench/btl/libs/mtl4/.kdbgrc.main create mode 100644 bench/btl/libs/mtl4/main.cpp create mode 100644 bench/btl/libs/mtl4/mtl4_LU_solve_interface.hh create mode 100644 bench/btl/libs/mtl4/mtl4_interface.hh create mode 100644 bench/btl/libs/tiny_blitz/CMakeLists.txt create mode 100644 bench/btl/libs/tiny_blitz/main.cpp create mode 100644 bench/btl/libs/tiny_blitz/tiny_blitz_interface.hh create mode 100644 bench/btl/libs/tvmet/CMakeLists.txt create mode 100644 bench/btl/libs/tvmet/main.cpp create mode 100644 bench/btl/libs/tvmet/tvmet_interface.hh create mode 100644 bench/btl/libs/ublas/CMakeLists.txt create mode 100644 bench/btl/libs/ublas/main.cpp create mode 100644 bench/btl/libs/ublas/ublas_interface.hh diff --git a/CMakeLists.txt b/CMakeLists.txt index 033e45ae4..95d5ff1a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.4) OPTION(BUILD_TESTS "Build tests" OFF) OPTION(BUILD_DOC "Build documentation and examples" OFF) OPTION(BUILD_DEMOS "Build demos" OFF) -OPTION(TEST_LIB "Build the unit tests using the library (disable -pedantic)" OFF) +OPTION(BUILD_LIB "Build the binary shared library" OFF) +OPTION(BUILD_BTL "Build benchmark suite" OFF) + +IF(BUILD_LIB) + OPTION(TEST_LIB "Build the unit tests using the library (disable -pedantic)" OFF) +ENDIF(BUILD_LIB) SET(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -35,4 +40,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) ADD_SUBDIRECTORY(Eigen) ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(doc) -ADD_SUBDIRECTORY(demos) \ No newline at end of file +ADD_SUBDIRECTORY(demos) + +IF(BUILD_BTL) +ADD_SUBDIRECTORY(bench/btl) +ENDIF(BUILD_BTL) diff --git a/bench/btl/CMakeLists.txt b/bench/btl/CMakeLists.txt new file mode 100644 index 000000000..adcb62a52 --- /dev/null +++ b/bench/btl/CMakeLists.txt @@ -0,0 +1,74 @@ +PROJECT(BTL) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.4) + +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +include(MacroOptionalAddSubdirectory) + +OPTION(BTL_NOVEC "Disable SSE/Altivec optimizations when possible" OFF) + +SET(CMAKE_INCLUDE_CURRENT_DIR ON) + +IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS "-g0 -O3 -DNDEBUG") + IF(NOT BTL_NOVEC) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2") + ELSE(NOT BTL_NOVEC) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_VECTORIZE") + ENDIF(NOT BTL_NOVEC) +ENDIF(CMAKE_COMPILER_IS_GNUCXX) + +include_directories( + ${PROJECT_SOURCE_DIR}/actions + ${PROJECT_SOURCE_DIR}/generic_bench + ${PROJECT_SOURCE_DIR}/generic_bench/utils + ${PROJECT_SOURCE_DIR}/libs/STL) + + +MACRO(BTL_ADD_BENCH targetname) + ADD_EXECUTABLE(${ARGV}) + ADD_TEST(${targetname} "${targetname}") +ENDMACRO(BTL_ADD_BENCH) + +ENABLE_TESTING() + +# Eigen2 +find_package(Eigen2) +if (EIGEN2_FOUND) + macro_optional_add_subdirectory(libs/eigen2 ON) +endif (EIGEN2_FOUND) + +# GMM++ +find_package(GMM) +if (GMM_FOUND) + macro_optional_add_subdirectory(libs/gmm ON) +endif (GMM_FOUND) + +# Boost +find_package(Boost) +if (Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + macro_optional_add_subdirectory(libs/ublas ON) +endif (Boost_FOUND) + +# blitz +find_package(Blitz) +if (BLITZ_FOUND) + macro_optional_add_subdirectory(libs/blitz ON) + macro_optional_add_subdirectory(libs/tiny_blitz ON) +endif (BLITZ_FOUND) + +# cblas +find_package(CBLAS) +if (CBLAS_FOUND) + macro_optional_add_subdirectory(libs/C_BLAS ON) +endif (CBLAS_FOUND) + + +macro_optional_add_subdirectory(libs/f77 ON) +macro_optional_add_subdirectory(libs/C ON) +macro_optional_add_subdirectory(libs/STL ON) +macro_optional_add_subdirectory(libs/STL_algo ON) + +add_subdirectory(data) + diff --git a/bench/btl/COPYING b/bench/btl/COPYING new file mode 100644 index 000000000..486449cc3 --- /dev/null +++ b/bench/btl/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/bench/btl/README b/bench/btl/README new file mode 100644 index 000000000..6d5712bb6 --- /dev/null +++ b/bench/btl/README @@ -0,0 +1,143 @@ +Bench Template Library + +**************************************** +Introduction : + +The aim of this project is to compare the performance +of available numerical libraries. The code is designed +as generic and modular as possible. Thus, adding new +numerical libraries or new numerical tests should +require minimal effort. + + +***************************************** + +Installation : + +BTL uses cmake / ctest: + +1 - create a build directory: + + $ mkdir build + $ cd build + +2 - configure: + + $ ccmake .. + +3 - run the bench using ctest: + + $ ctest -V + +You can also run a single bench, e.g.: ctest -V -R eigen + +4 : Analyze the result. different data files (.dat) are produced in each libs directories. + If gnuplot is available, choose a directory name in the data directory to store the results and type + cd data + mkdir my_directory + cp ../libs/*/*.dat my_directory + Build the data utilities in this (data) directory + make + Then you can look the raw data, + go_mean my_directory + or smooth the data first : + smooth_all.sh my_directory + go_mean my_directory_smooth + + +************************************************* + +Files and directories : + + generic_bench : all the bench sources common to all libraries + + actions : sources for different action wrappers (axpy, matrix-matrix product) to be tested. + + libs/* : bench sources specific to each tested libraries. + + machine_dep : directory used to store machine specific Makefile.in + + data : directory used to store gnuplot scripts and data analysis utilities + +************************************************** + +Principles : the code modularity is achieved by defining two concepts : + + ****** Action concept : This is a class defining which kind + of test must be performed (e.g. a matrix_vector_product). + An Action should define the following methods : + + *** Ctor using the size of the problem (matrix or vector size) as an argument + Action action(size); + *** initialize : this method initialize the calculation (e.g. initialize the matrices and vectors arguments) + action.initialize(); + *** calculate : this method actually launch the calculation to be benchmarked + action.calculate; + *** nb_op_base() : this method returns the complexity of the calculate method (allowing the mflops evaluation) + *** name() : this method returns the name of the action (std::string) + + ****** Interface concept : This is a class or namespace defining how to use a given library and + its specific containers (matrix and vector). Up to now an interface should following types + + *** real_type : kind of float to be used (float or double) + *** stl_vector : must correspond to std::vector + *** stl_matrix : must correspond to std::vector + *** gene_vector : the vector type for this interface --> e.g. (real_type *) for the C_interface + *** gene_matrix : the matrix type for this interface --> e.g. (gene_vector *) for the C_interface + + + the following common methods + + *** free_matrix(gene_matrix & A, int N) dealocation of a N sized gene_matrix A + *** free_vector(gene_vector & B) dealocation of a N sized gene_vector B + *** matrix_from_stl(gene_matrix & A, stl_matrix & A_stl) copy the content of an stl_matrix A_stl into a gene_matrix A. + The allocation of A is done in this function. + *** vector_to_stl(gene_vector & B, stl_vector & B_stl) copy the content of an stl_vector B_stl into a gene_vector B. + The allocation of B is done in this function. + *** matrix_to_stl(gene_matrix & A, stl_matrix & A_stl) copy the content of an gene_matrix A into an stl_matrix A_stl. + The size of A_STL must corresponds to the size of A. + *** vector_to_stl(gene_vector & A, stl_vector & A_stl) copy the content of an gene_vector A into an stl_vector A_stl. + The size of B_STL must corresponds to the size of B. + *** copy_matrix(gene_matrix & source, gene_matrix & cible, int N) : copy the content of source in cible. Both source + and cible must be sized NxN. + *** copy_vector(gene_vector & source, gene_vector & cible, int N) : copy the content of source in cible. Both source + and cible must be sized N. + + and the following method corresponding to the action one wants to be benchmarked : + + *** matrix_vector_product(const gene_matrix & A, const gene_vector & B, gene_vector & X, int N) + *** matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N) + *** ata_product(const gene_matrix & A, gene_matrix & X, int N) + *** aat_product(const gene_matrix & A, gene_matrix & X, int N) + *** axpy(real coef, const gene_vector & X, gene_vector & Y, int N) + + The bench algorithm (generic_bench/bench.hh) is templated with an action itself templated with + an interface. A typical main.cpp source stored in a given library directory libs/A_LIB + looks like : + + bench< AN_ACTION < AN_INTERFACE > >( 10 , 1000 , 50 ) ; + + this function will produce XY data file containing measured mflops as a function of the size for 50 + sizes between 10 and 10000. + + This algorithm can be adapted by providing a given Perf_Analyzer object which determines how the time + measurements must be done. For example, the X86_Perf_Analyzer use the asm rdtsc function and provides + a very fast and accurate (but less portable) timing method. The default is the Portable_Perf_Analyzer + so + + bench< AN_ACTION < AN_INTERFACE > >( 10 , 1000 , 50 ) ; + + is equivalent to + + bench< Portable_Perf_Analyzer,AN_ACTION < AN_INTERFACE > >( 10 , 1000 , 50 ) ; + + If your system supports it we suggest to use a mixed implementation (X86_perf_Analyzer+Portable_Perf_Analyzer). + replace + bench(size_min,size_max,nb_point); + with + bench(size_min,size_max,nb_point); + in generic/bench.hh + +. + + + diff --git a/bench/btl/actions/action_aat_product.hh b/bench/btl/actions/action_aat_product.hh new file mode 100644 index 000000000..3d11e7d6f --- /dev/null +++ b/bench/btl/actions/action_aat_product.hh @@ -0,0 +1,145 @@ +//===================================================== +// File : action_aat_product.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_AAT_PRODUCT +#define ACTION_AAT_PRODUCT +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_aat_product { + +public : + + // Ctor + + Action_aat_product( int size ):_size(size) + { + MESSAGE("Action_aat_product Ctor"); + + // STL matrix and vector initialization + + init_matrix(A_stl,_size); + init_matrix(X_stl,_size); + init_matrix(resu_stl,_size); + + // generic matrix and vector initialization + + Interface::matrix_from_stl(A_ref,A_stl); + Interface::matrix_from_stl(X_ref,X_stl); + + Interface::matrix_from_stl(A,A_stl); + Interface::matrix_from_stl(X,X_stl); + + } + + // invalidate copy ctor + + Action_aat_product( const Action_aat_product & ) + { + INFOS("illegal call to Action_aat_product Copy Ctor"); + exit(0); + } + + // Dtor + + ~Action_aat_product( void ){ + + MESSAGE("Action_aat_product Dtor"); + + // deallocation + + Interface::free_matrix(A,_size); + Interface::free_matrix(X,_size); + + Interface::free_matrix(A_ref,_size); + Interface::free_matrix(X_ref,_size); + + } + + // action name + + static inline std::string name( void ) + { + return "aat_"+Interface::name(); + } + + double nb_op_base( void ){ + return 2.0*_size*_size*_size; + } + + inline void initialize( void ){ + + Interface::copy_matrix(A_ref,A,_size); + Interface::copy_matrix(X_ref,X,_size); + + } + + inline void calculate( void ) { + + Interface::aat_product(A,X,_size); + + } + + void check_result( void ){ + + // calculation check + + Interface::matrix_to_stl(X,resu_stl); + + STL_interface::aat_product(A_stl,X_stl,_size); + + typename Interface::real_type error= + STL_interface::norm_diff(X_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(1); + } + + } + +private : + + typename Interface::stl_matrix A_stl; + typename Interface::stl_matrix X_stl; + typename Interface::stl_matrix resu_stl; + + typename Interface::gene_matrix A_ref; + typename Interface::gene_matrix X_ref; + + typename Interface::gene_matrix A; + typename Interface::gene_matrix X; + + + int _size; + +}; + + +#endif + + + diff --git a/bench/btl/actions/action_ata_product.hh b/bench/btl/actions/action_ata_product.hh new file mode 100644 index 000000000..47531d607 --- /dev/null +++ b/bench/btl/actions/action_ata_product.hh @@ -0,0 +1,145 @@ +//===================================================== +// File : action_ata_product.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_ATA_PRODUCT +#define ACTION_ATA_PRODUCT +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_ata_product { + +public : + + // Ctor + + Action_ata_product( int size ):_size(size) + { + MESSAGE("Action_ata_product Ctor"); + + // STL matrix and vector initialization + + init_matrix(A_stl,_size); + init_matrix(X_stl,_size); + init_matrix(resu_stl,_size); + + // generic matrix and vector initialization + + Interface::matrix_from_stl(A_ref,A_stl); + Interface::matrix_from_stl(X_ref,X_stl); + + Interface::matrix_from_stl(A,A_stl); + Interface::matrix_from_stl(X,X_stl); + + } + + // invalidate copy ctor + + Action_ata_product( const Action_ata_product & ) + { + INFOS("illegal call to Action_ata_product Copy Ctor"); + exit(0); + } + + // Dtor + + ~Action_ata_product( void ){ + + MESSAGE("Action_ata_product Dtor"); + + // deallocation + + Interface::free_matrix(A,_size); + Interface::free_matrix(X,_size); + + Interface::free_matrix(A_ref,_size); + Interface::free_matrix(X_ref,_size); + + } + + // action name + + static inline std::string name( void ) + { + return "ata_"+Interface::name(); + } + + double nb_op_base( void ){ + return 2.0*_size*_size*_size; + } + + inline void initialize( void ){ + + Interface::copy_matrix(A_ref,A,_size); + Interface::copy_matrix(X_ref,X,_size); + + } + + inline void calculate( void ) { + + Interface::ata_product(A,X,_size); + + } + + void check_result( void ){ + + // calculation check + + Interface::matrix_to_stl(X,resu_stl); + + STL_interface::ata_product(A_stl,X_stl,_size); + + typename Interface::real_type error= + STL_interface::norm_diff(X_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(1); + } + + } + +private : + + typename Interface::stl_matrix A_stl; + typename Interface::stl_matrix X_stl; + typename Interface::stl_matrix resu_stl; + + typename Interface::gene_matrix A_ref; + typename Interface::gene_matrix X_ref; + + typename Interface::gene_matrix A; + typename Interface::gene_matrix X; + + + int _size; + +}; + + +#endif + + + diff --git a/bench/btl/actions/action_atv_product.hh b/bench/btl/actions/action_atv_product.hh new file mode 100644 index 000000000..9041885fc --- /dev/null +++ b/bench/btl/actions/action_atv_product.hh @@ -0,0 +1,131 @@ +//===================================================== +// File : action_atv_product.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_ATV_PRODUCT +#define ACTION_ATV_PRODUCT +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_atv_product { + +public : + + Action_atv_product( int size ) : _size(size) + { + MESSAGE("Action_atv_product Ctor"); + + // STL matrix and vector initialization + + init_matrix(A_stl,_size); + init_vector(B_stl,_size); + init_vector(X_stl,_size); + init_vector(resu_stl,_size); + + // generic matrix and vector initialization + + Interface::matrix_from_stl(A_ref,A_stl); + Interface::vector_from_stl(B_ref,B_stl); + Interface::vector_from_stl(X_ref,X_stl); + + Interface::matrix_from_stl(A,A_stl); + Interface::vector_from_stl(B,B_stl); + Interface::vector_from_stl(X,X_stl); + } + + // invalidate copy ctor + Action_atv_product( const Action_atv_product & ) + { + INFOS("illegal call to Action_atv_product Copy Ctor"); + exit(1); + } + + ~Action_atv_product( void ) + { + MESSAGE("Action_atv_product Dtor"); + + Interface::free_matrix(A,_size); + Interface::free_vector(B); + Interface::free_vector(X); + + Interface::free_matrix(A_ref,_size); + Interface::free_vector(B_ref); + Interface::free_vector(X_ref); + } + + static inline std::string name() { return "atv_" + Interface::name(); } + + double nb_op_base( void ) { return 2.0*_size*_size; } + + inline void initialize( void ){ + Interface::copy_matrix(A_ref,A,_size); + Interface::copy_vector(B_ref,B,_size); + Interface::copy_vector(X_ref,X,_size); + } + + inline void calculate( void ) { + Interface::atv_product(A,B,X,_size); + } + + void check_result( void ) + { + Interface::vector_to_stl(X,resu_stl); + + STL_interface::atv_product(A_stl,B_stl,X_stl,_size); + + typename Interface::real_type error= + STL_interface::norm_diff(X_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(0); + } + } + +private : + + typename Interface::stl_matrix A_stl; + typename Interface::stl_vector B_stl; + typename Interface::stl_vector X_stl; + typename Interface::stl_vector resu_stl; + + typename Interface::gene_matrix A_ref; + typename Interface::gene_vector B_ref; + typename Interface::gene_vector X_ref; + + typename Interface::gene_matrix A; + typename Interface::gene_vector B; + typename Interface::gene_vector X; + + + int _size; + +}; + + +#endif + + + diff --git a/bench/btl/actions/action_axpy.hh b/bench/btl/actions/action_axpy.hh new file mode 100644 index 000000000..8740e413d --- /dev/null +++ b/bench/btl/actions/action_axpy.hh @@ -0,0 +1,137 @@ +//===================================================== +// File : action_axpy.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_AXPY +#define ACTION_AXPY +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_axpy { + +public : + + // Ctor + + Action_axpy( int size ):_size(size),_coef(1.0) + { + MESSAGE("Action_axpy Ctor"); + + // STL vector initialization + + init_vector(X_stl,_size); + init_vector(Y_stl,_size); + init_vector(resu_stl,_size); + + // generic matrix and vector initialization + + Interface::vector_from_stl(X_ref,X_stl); + Interface::vector_from_stl(Y_ref,Y_stl); + + Interface::vector_from_stl(X,X_stl); + Interface::vector_from_stl(Y,Y_stl); + + + } + + // invalidate copy ctor + + Action_axpy( const Action_axpy & ) + { + INFOS("illegal call to Action_axpy Copy Ctor"); + exit(1); + } + + // Dtor + + ~Action_axpy( void ){ + + MESSAGE("Action_axpy Dtor"); + + // deallocation + + Interface::free_vector(X_ref); + Interface::free_vector(Y_ref); + + Interface::free_vector(X); + Interface::free_vector(Y); + } + + // action name + + static inline std::string name( void ) + { + return "axpy_"+Interface::name(); + } + + double nb_op_base( void ){ + return 2.0*_size; + } + + inline void initialize( void ){ + Interface::copy_vector(X_ref,X,_size); + Interface::copy_vector(Y_ref,Y,_size); + } + + inline void calculate( void ) { + Interface::axpy(_coef,X,Y,_size); + } + + void check_result( void ){ + + // calculation check + + Interface::vector_to_stl(Y,resu_stl); + + STL_interface::axpy(_coef,X_stl,Y_stl,_size); + + typename Interface::real_type error= + STL_interface::norm_diff(Y_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(0); + } + + } + +private : + + typename Interface::stl_vector X_stl; + typename Interface::stl_vector Y_stl; + typename Interface::stl_vector resu_stl; + + typename Interface::gene_vector X_ref; + typename Interface::gene_vector Y_ref; + + typename Interface::gene_vector X; + typename Interface::gene_vector Y; + + typename Interface::real_type _coef; + + int _size; +}; + +#endif diff --git a/bench/btl/actions/action_lu_solve.hh b/bench/btl/actions/action_lu_solve.hh new file mode 100644 index 000000000..5a81e6341 --- /dev/null +++ b/bench/btl/actions/action_lu_solve.hh @@ -0,0 +1,136 @@ +//===================================================== +// File : action_lu_solve.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_LU_SOLVE +#define ACTION_LU_SOLVE +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_lu_solve +{ + +public : + + static inline std::string name( void ) + { + return "lu_solve_"+Interface::name(); + } + + static double nb_op_base(int size){ + return 2.0*size*size*size/3.0; // questionable but not really important + } + + + static double calculate( int nb_calc, int size ) { + + // STL matrix and vector initialization + + typename Interface::stl_matrix A_stl; + typename Interface::stl_vector B_stl; + typename Interface::stl_vector X_stl; + + init_matrix(A_stl,size); + init_vector(B_stl,size); + init_vector(X_stl,size); + + // generic matrix and vector initialization + + typename Interface::gene_matrix A; + typename Interface::gene_vector B; + typename Interface::gene_vector X; + + typename Interface::gene_matrix LU; + + Interface::matrix_from_stl(A,A_stl); + Interface::vector_from_stl(B,B_stl); + Interface::vector_from_stl(X,X_stl); + Interface::matrix_from_stl(LU,A_stl); + + // local variable : + + typename Interface::Pivot_Vector pivot; // pivot vector + Interface::new_Pivot_Vector(pivot,size); + + // timer utilities + + Portable_Timer chronos; + + // time measurement + + chronos.start(); + + for (int ii=0;ii::matrix_vector_product(A_stl,X_stl,B_new_stl,size); + + typename Interface::real_type error= + STL_interface::norm_diff(B_stl,B_new_stl); + + if (error>1.e-5){ + INFOS("WRONG CALCULATION...residual=" << error); + STL_interface::display_vector(B_stl); + STL_interface::display_vector(B_new_stl); + exit(0); + } + + // deallocation and return time + + Interface::free_matrix(A,size); + Interface::free_vector(B); + Interface::free_vector(X); + Interface::free_Pivot_Vector(pivot); + + return time; + } + +}; + + +#endif + + + diff --git a/bench/btl/actions/action_matrix_matrix_product.hh b/bench/btl/actions/action_matrix_matrix_product.hh new file mode 100644 index 000000000..9de677a7f --- /dev/null +++ b/bench/btl/actions/action_matrix_matrix_product.hh @@ -0,0 +1,152 @@ +//===================================================== +// File : action_matrix_matrix_product.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_MATRIX_MATRIX_PRODUCT +#define ACTION_MATRIX_MATRIX_PRODUCT +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_matrix_matrix_product { + +public : + + // Ctor + + Action_matrix_matrix_product( int size ):_size(size) + { + MESSAGE("Action_matrix_matrix_product Ctor"); + + // STL matrix and vector initialization + + init_matrix(A_stl,_size); + init_matrix(B_stl,_size); + init_matrix(X_stl,_size); + init_matrix(resu_stl,_size); + + // generic matrix and vector initialization + + Interface::matrix_from_stl(A_ref,A_stl); + Interface::matrix_from_stl(B_ref,B_stl); + Interface::matrix_from_stl(X_ref,X_stl); + + Interface::matrix_from_stl(A,A_stl); + Interface::matrix_from_stl(B,B_stl); + Interface::matrix_from_stl(X,X_stl); + + } + + // invalidate copy ctor + + Action_matrix_matrix_product( const Action_matrix_matrix_product & ) + { + INFOS("illegal call to Action_matrix_matrix_product Copy Ctor"); + exit(0); + } + + // Dtor + + ~Action_matrix_matrix_product( void ){ + + MESSAGE("Action_matrix_matrix_product Dtor"); + + // deallocation + + Interface::free_matrix(A,_size); + Interface::free_matrix(B,_size); + Interface::free_matrix(X,_size); + + Interface::free_matrix(A_ref,_size); + Interface::free_matrix(B_ref,_size); + Interface::free_matrix(X_ref,_size); + + } + + // action name + + static inline std::string name( void ) + { + return "matrix_matrix_"+Interface::name(); + } + + double nb_op_base( void ){ + return 2.0*_size*_size*_size; + } + + inline void initialize( void ){ + + Interface::copy_matrix(A_ref,A,_size); + Interface::copy_matrix(B_ref,B,_size); + Interface::copy_matrix(X_ref,X,_size); + + } + + inline void calculate( void ) { + Interface::matrix_matrix_product(A,B,X,_size); + } + + void check_result( void ){ + + // calculation check + + Interface::matrix_to_stl(X,resu_stl); + + STL_interface::matrix_matrix_product(A_stl,B_stl,X_stl,_size); + + typename Interface::real_type error= + STL_interface::norm_diff(X_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(1); + } + + } + +private : + + typename Interface::stl_matrix A_stl; + typename Interface::stl_matrix B_stl; + typename Interface::stl_matrix X_stl; + typename Interface::stl_matrix resu_stl; + + typename Interface::gene_matrix A_ref; + typename Interface::gene_matrix B_ref; + typename Interface::gene_matrix X_ref; + + typename Interface::gene_matrix A; + typename Interface::gene_matrix B; + typename Interface::gene_matrix X; + + + int _size; + +}; + + +#endif + + + diff --git a/bench/btl/actions/action_matrix_matrix_product_bis.hh b/bench/btl/actions/action_matrix_matrix_product_bis.hh new file mode 100644 index 000000000..29c10a6e2 --- /dev/null +++ b/bench/btl/actions/action_matrix_matrix_product_bis.hh @@ -0,0 +1,152 @@ +//===================================================== +// File : action_matrix_matrix_product_bis.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_MATRIX_MATRIX_PRODUCT_BIS +#define ACTION_MATRIX_MATRIX_PRODUCT_BIS +#include "utilities.h" +#include "STL_interface.hh" +#include "STL_timer.hh" +#include +#include "init_function.hh" +#include "init_vector.hh" +#include "init_matrix.hh" + +using namespace std; + +template +class Action_matrix_matrix_product_bis { + +public : + + static inline std::string name( void ) + { + return "matrix_matrix_"+Interface::name(); + } + + static double nb_op_base(int size){ + return 2.0*size*size*size; + } + + static double calculate( int nb_calc, int size ) { + + // STL matrix and vector initialization + + typename Interface::stl_matrix A_stl; + typename Interface::stl_matrix B_stl; + typename Interface::stl_matrix X_stl; + + init_matrix(A_stl,size); + init_matrix(B_stl,size); + init_matrix(X_stl,size); + + // generic matrix and vector initialization + + typename Interface::gene_matrix A_ref; + typename Interface::gene_matrix B_ref; + typename Interface::gene_matrix X_ref; + + typename Interface::gene_matrix A; + typename Interface::gene_matrix B; + typename Interface::gene_matrix X; + + + Interface::matrix_from_stl(A_ref,A_stl); + Interface::matrix_from_stl(B_ref,B_stl); + Interface::matrix_from_stl(X_ref,X_stl); + + Interface::matrix_from_stl(A,A_stl); + Interface::matrix_from_stl(B,B_stl); + Interface::matrix_from_stl(X,X_stl); + + + // STL_timer utilities + + STL_timer chronos; + + // Baseline evaluation + + chronos.start_baseline(nb_calc); + + do { + + Interface::copy_matrix(A_ref,A,size); + Interface::copy_matrix(B_ref,B,size); + Interface::copy_matrix(X_ref,X,size); + + + // Interface::matrix_matrix_product(A,B,X,size); This line must be commented !!!! + } + while(chronos.check()); + + chronos.report(true); + + // Time measurement + + chronos.start(nb_calc); + + do { + + Interface::copy_matrix(A_ref,A,size); + Interface::copy_matrix(B_ref,B,size); + Interface::copy_matrix(X_ref,X,size); + + Interface::matrix_matrix_product(A,B,X,size); // here it is not commented !!!! + } + while(chronos.check()); + + chronos.report(true); + + double time=chronos.calculated_time/2000.0; + + // calculation check + + typename Interface::stl_matrix resu_stl(size); + + Interface::matrix_to_stl(X,resu_stl); + + STL_interface::matrix_matrix_product(A_stl,B_stl,X_stl,size); + + typename Interface::real_type error= + STL_interface::norm_diff(X_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(1); + } + + // deallocation and return time + + Interface::free_matrix(A,size); + Interface::free_matrix(B,size); + Interface::free_matrix(X,size); + + Interface::free_matrix(A_ref,size); + Interface::free_matrix(B_ref,size); + Interface::free_matrix(X_ref,size); + + return time; + } + +}; + + +#endif + + + diff --git a/bench/btl/actions/action_matrix_vector_product.hh b/bench/btl/actions/action_matrix_vector_product.hh new file mode 100644 index 000000000..ee9110d06 --- /dev/null +++ b/bench/btl/actions/action_matrix_vector_product.hh @@ -0,0 +1,154 @@ +//===================================================== +// File : action_matrix_vector_product.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ACTION_MATRIX_VECTOR_PRODUCT +#define ACTION_MATRIX_VECTOR_PRODUCT +#include "utilities.h" +#include "STL_interface.hh" +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +using namespace std; + +template +class Action_matrix_vector_product { + +public : + + // Ctor + + Action_matrix_vector_product( int size ):_size(size) + { + MESSAGE("Action_matrix_vector_product Ctor"); + + // STL matrix and vector initialization + + init_matrix(A_stl,_size); + init_vector(B_stl,_size); + init_vector(X_stl,_size); + init_vector(resu_stl,_size); + + // generic matrix and vector initialization + + Interface::matrix_from_stl(A_ref,A_stl); + Interface::vector_from_stl(B_ref,B_stl); + Interface::vector_from_stl(X_ref,X_stl); + + Interface::matrix_from_stl(A,A_stl); + Interface::vector_from_stl(B,B_stl); + Interface::vector_from_stl(X,X_stl); + + } + + // invalidate copy ctor + + Action_matrix_vector_product( const Action_matrix_vector_product & ) + { + INFOS("illegal call to Action_matrix_vector_product Copy Ctor"); + exit(1); + } + + // Dtor + + ~Action_matrix_vector_product( void ){ + + MESSAGE("Action_matrix_vector_product Dtor"); + + // deallocation + + Interface::free_matrix(A,_size); + Interface::free_vector(B); + Interface::free_vector(X); + + Interface::free_matrix(A_ref,_size); + Interface::free_vector(B_ref); + Interface::free_vector(X_ref); + + } + + // action name + + static inline std::string name( void ) + { + return "matrix_vector_"+Interface::name(); + } + + double nb_op_base( void ){ + return 2.0*_size*_size; + } + + inline void initialize( void ){ + + Interface::copy_matrix(A_ref,A,_size); + Interface::copy_vector(B_ref,B,_size); + Interface::copy_vector(X_ref,X,_size); + + } + + inline void calculate( void ) { + + Interface::matrix_vector_product(A,B,X,_size); + + } + + void check_result( void ){ + + // calculation check + + Interface::vector_to_stl(X,resu_stl); + + STL_interface::matrix_vector_product(A_stl,B_stl,X_stl,_size); + + typename Interface::real_type error= + STL_interface::norm_diff(X_stl,resu_stl); + + if (error>1.e-6){ + INFOS("WRONG CALCULATION...residual=" << error); + exit(0); + } + + } + +private : + + typename Interface::stl_matrix A_stl; + typename Interface::stl_vector B_stl; + typename Interface::stl_vector X_stl; + typename Interface::stl_vector resu_stl; + + typename Interface::gene_matrix A_ref; + typename Interface::gene_vector B_ref; + typename Interface::gene_vector X_ref; + + typename Interface::gene_matrix A; + typename Interface::gene_vector B; + typename Interface::gene_vector X; + + + int _size; + +}; + + +#endif + + + diff --git a/bench/btl/cmake/FindBlitz.cmake b/bench/btl/cmake/FindBlitz.cmake new file mode 100644 index 000000000..99795f475 --- /dev/null +++ b/bench/btl/cmake/FindBlitz.cmake @@ -0,0 +1,40 @@ +# - Try to find blitz lib +# Once done this will define +# +# BLITZ_FOUND - system has blitz lib +# BLITZ_INCLUDES - the blitz include directory +# BLITZ_LIBRARIES - The libraries needed to use blitz + +# Copyright (c) 2006, Montel Laurent, +# Copyright (c) 2007, Allen Winter, +# Copyright (C) 2008 Gael Guennebaud +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# include(FindLibraryWithDebug) + +if (BLITZ_INCLUDES AND BLITZ_LIBRARIES) + set(Blitz_FIND_QUIETLY TRUE) +endif (BLITZ_INCLUDES AND BLITZ_LIBRARIES) + +find_path(BLITZ_INCLUDES + NAMES + blitz/array.h + PATH_SUFFIXES blitz* + PATHS + $ENV{BLITZDIR}/include + ${INCLUDE_INSTALL_DIR} +) + +find_library(BLITZ_LIBRARIES + blitz + PATHS + $ENV{BLITZDIR}/lib + ${LIB_INSTALL_DIR} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Blitz DEFAULT_MSG + BLITZ_INCLUDES BLITZ_LIBRARIES) + +mark_as_advanced(BLITZ_INCLUDES BLITZ_LIBRARIES) diff --git a/bench/btl/cmake/FindCBLAS.cmake b/bench/btl/cmake/FindCBLAS.cmake new file mode 100644 index 000000000..554f0291b --- /dev/null +++ b/bench/btl/cmake/FindCBLAS.cmake @@ -0,0 +1,34 @@ +# include(FindLibraryWithDebug) + +if (CBLAS_INCLUDES AND CBLAS_LIBRARIES) + set(CBLAS_FIND_QUIETLY TRUE) +endif (CBLAS_INCLUDES AND CBLAS_LIBRARIES) + +find_path(CBLAS_INCLUDES + NAMES + cblas.h + PATHS + $ENV{CBLASDIR}/include + ${INCLUDE_INSTALL_DIR} +) + +find_library(CBLAS_LIBRARIES + cblas + PATHS + $ENV{CBLASDIR}/lib + ${LIB_INSTALL_DIR} +) + +find_file(CBLAS_LIBRARIES + libcblas.so.3 + PATHS + /usr/lib + $ENV{CBLASDIR}/lib + ${LIB_INSTALL_DIR} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CBLAS DEFAULT_MSG + CBLAS_INCLUDES CBLAS_LIBRARIES) + +mark_as_advanced(CBLAS_INCLUDES CBLAS_LIBRARIES) diff --git a/bench/btl/cmake/FindEigen.cmake b/bench/btl/cmake/FindEigen.cmake new file mode 100644 index 000000000..1a5fe34fd --- /dev/null +++ b/bench/btl/cmake/FindEigen.cmake @@ -0,0 +1,30 @@ +# - Try to find eigen lib +# Once done this will define +# +# EIGEN_FOUND - system has eigen lib +# EIGEN_INCLUDE_DIR - the eigen include directory + +# Copyright (c) 2006, 2007 Montel Laurent, +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +if (EIGEN_INCLUDE_DIR) + + # in cache already + set(EIGEN_FOUND TRUE) + +else (EIGEN_INCLUDE_DIR) + +find_path(EIGEN_INCLUDE_DIR NAMES eigen/matrix.h + PATHS + ${INCLUDE_INSTALL_DIR} + ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR ) + + +mark_as_advanced(EIGEN_INCLUDE_DIR) + +endif(EIGEN_INCLUDE_DIR) + diff --git a/bench/btl/cmake/FindEigen2.cmake b/bench/btl/cmake/FindEigen2.cmake new file mode 100644 index 000000000..a1b8a4645 --- /dev/null +++ b/bench/btl/cmake/FindEigen2.cmake @@ -0,0 +1,32 @@ +# - Try to find eigen2 headers +# Once done this will define +# +# EIGEN2_FOUND - system has eigen2 lib +# EIGEN2_INCLUDE_DIR - the eigen2 include directory +# +# Copyright (C) 2008 Gael Guennebaud +# Adapted from FindEigen.cmake: +# Copyright (c) 2006, 2007 Montel Laurent, +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +if (EIGEN2_INCLUDE_DIR) + + # in cache already + set(EIGEN2_FOUND TRUE) + +else (EIGEN2_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Eigen2 DEFAULT_MSG EIGEN2_INCLUDE_DIR) + +find_path(EIGEN2_INCLUDE_DIR NAMES Eigen/Core + PATHS + ${Eigen_SOURCE_DIR}/ + ${INCLUDE_INSTALL_DIR} + ) + +mark_as_advanced(EIGEN2_INCLUDE_DIR) + +endif(EIGEN2_INCLUDE_DIR) + diff --git a/bench/btl/cmake/FindGMM.cmake b/bench/btl/cmake/FindGMM.cmake new file mode 100644 index 000000000..5049c64ed --- /dev/null +++ b/bench/btl/cmake/FindGMM.cmake @@ -0,0 +1,17 @@ +if (GMM_INCLUDE_DIR) + # in cache already + set(GMM_FOUND TRUE) +else (GMM_INCLUDE_DIR) + +find_path(GMM_INCLUDE_DIR NAMES gmm/gmm.h + PATHS + ${INCLUDE_INSTALL_DIR} + ${GMM_INCLUDE_PATH} + ) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMM DEFAULT_MSG GMM_INCLUDE_DIR ) + +mark_as_advanced(GMM_INCLUDE_DIR) + +endif(GMM_INCLUDE_DIR) diff --git a/bench/btl/cmake/MacroOptionalAddSubdirectory.cmake b/bench/btl/cmake/MacroOptionalAddSubdirectory.cmake new file mode 100644 index 000000000..545048b68 --- /dev/null +++ b/bench/btl/cmake/MacroOptionalAddSubdirectory.cmake @@ -0,0 +1,31 @@ +# - MACRO_OPTIONAL_ADD_SUBDIRECTORY() combines ADD_SUBDIRECTORY() with an OPTION() +# MACRO_OPTIONAL_ADD_SUBDIRECTORY( ) +# If you use MACRO_OPTIONAL_ADD_SUBDIRECTORY() instead of ADD_SUBDIRECTORY(), +# this will have two effects +# 1 - CMake will not complain if the directory doesn't exist +# This makes sense if you want to distribute just one of the subdirs +# in a source package, e.g. just one of the subdirs in kdeextragear. +# 2 - If the directory exists, it will offer an option to skip the +# subdirectory. +# This is useful if you want to compile only a subset of all +# directories. + +# Copyright (c) 2007, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) + GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) + IF(EXISTS ${_fullPath}) + IF(${ARGC} EQUAL 2) + OPTION(BUILD_${_dir} "Build directory ${_dir}" ${ARGV1}) + ELSE(${ARGC} EQUAL 2) + OPTION(BUILD_${_dir} "Build directory ${_dir}" TRUE) + ENDIF(${ARGC} EQUAL 2) + IF(BUILD_${_dir}) + ADD_SUBDIRECTORY(${_dir}) + ENDIF(BUILD_${_dir}) + ENDIF(EXISTS ${_fullPath}) +ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY) diff --git a/bench/btl/data/CMakeLists.txt b/bench/btl/data/CMakeLists.txt new file mode 100644 index 000000000..365652ca9 --- /dev/null +++ b/bench/btl/data/CMakeLists.txt @@ -0,0 +1,18 @@ + +ADD_CUSTOM_TARGET(copy_scripts) + +SET(script_files go_mean aat.hh ata.hh axpy.hh order_lib mk_mean_script.sh mk_new_gnuplot.sh mk_gnuplot_script.sh matrix_matrix.hh matrix_vector.hh) + +FOREACH(script_file ${script_files}) +ADD_CUSTOM_COMMAND( + TARGET copy_scripts + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${script_file} ${CMAKE_CURRENT_BINARY_DIR}/ + ARGS +) +ENDFOREACH(script_file) + +add_executable(smooth smooth.cxx) +add_executable(regularize regularize.cxx) +add_executable(main mean.cxx) +add_dependencies(main copy_scripts) diff --git a/bench/btl/data/aat.hh b/bench/btl/data/aat.hh new file mode 100644 index 000000000..d91f4e3bf --- /dev/null +++ b/bench/btl/data/aat.hh @@ -0,0 +1,108 @@ +#!/usr/bin/gnuplot -persist +# +# +# G N U P L O T +# Linux version 3.7 +# patchlevel 0 +# last modified Thu Jan 14 19:34:53 BST 1999 +# +# Copyright(C) 1986 - 1993, 1998, 1999 +# Thomas Williams, Colin Kelley and many others +# +# Type `help` to access the on-line reference manual +# The gnuplot FAQ is available from +# +# +# Send comments and requests for help to +# Send bugs, suggestions and mods to +# +# set terminal postscript landscape noenhanced monochrome dashed defaultplex "Helvetica" 14 +# set output 'bench_gcc.ps' +set noclip points +set clip one +set noclip two +set bar 1.000000 +set border 31 lt -1 lw 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set boxwidth +set dummy x,y +set format x "%g" +set format y "%g" +set format x2 "%g" +set format y2 "%g" +set format z "%g" +set angles radians +set nogrid +set key title "" +set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 +set nolabel +set noarrow +set nolinestyle +set nologscale +set logscale x 10 +set offsets 0, 0, 0, 0 +set pointsize 1 +set encoding default +set nopolar +set noparametric +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +set nocontour +set clabel '%8.3g' +set mapping cartesian +set nohidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set data style linespoints +set function style lines +set xzeroaxis lt -2 lw 1.000 +set x2zeroaxis lt -2 lw 1.000 +set yzeroaxis lt -2 lw 1.000 +set y2zeroaxis lt -2 lw 1.000 +set tics in +set ticslevel 0.5 +set ticscale 1 0.5 +set mxtics default +set mytics default +set mx2tics default +set my2tics default +set xtics border mirror norotate autofreq +set ytics border mirror norotate autofreq +set ztics border nomirror norotate autofreq +set nox2tics +set noy2tics +set title "A x At product " 0.000000,0.000000 "" +set timestamp "" bottom norotate 0.000000,0.000000 "" +set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] ) +set trange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set urange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set xlabel "matrix size" 0.000000,0.000000 "" +set x2label "" 0.000000,0.000000 "" +set timefmt "%d/%m/%y\n%H:%M" +set xrange [ 10 : 1000 ] noreverse nowriteback +set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set ylabel "MFLOPS" 0.000000,0.000000 "" +set y2label "" 0.000000,0.000000 "" +set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zlabel "" 0.000000,0.000000 "" +set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set locale "C" +set xrange [10:1000] +##set yrange [0:400] diff --git a/bench/btl/data/ata.hh b/bench/btl/data/ata.hh new file mode 100644 index 000000000..d553f7000 --- /dev/null +++ b/bench/btl/data/ata.hh @@ -0,0 +1,108 @@ +#!/usr/bin/gnuplot -persist +# +# +# G N U P L O T +# Linux version 3.7 +# patchlevel 0 +# last modified Thu Jan 14 19:34:53 BST 1999 +# +# Copyright(C) 1986 - 1993, 1998, 1999 +# Thomas Williams, Colin Kelley and many others +# +# Type `help` to access the on-line reference manual +# The gnuplot FAQ is available from +# +# +# Send comments and requests for help to +# Send bugs, suggestions and mods to +# +# set terminal postscript landscape noenhanced monochrome dashed defaultplex "Helvetica" 14 +# set output 'bench_gcc.ps' +set noclip points +set clip one +set noclip two +set bar 1.000000 +set border 31 lt -1 lw 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set boxwidth +set dummy x,y +set format x "%g" +set format y "%g" +set format x2 "%g" +set format y2 "%g" +set format z "%g" +set angles radians +set nogrid +set key title "" +set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 +set nolabel +set noarrow +set nolinestyle +set nologscale +set logscale x 10 +set offsets 0, 0, 0, 0 +set pointsize 1 +set encoding default +set nopolar +set noparametric +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +set nocontour +set clabel '%8.3g' +set mapping cartesian +set nohidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set data style linespoints +set function style lines +set xzeroaxis lt -2 lw 1.000 +set x2zeroaxis lt -2 lw 1.000 +set yzeroaxis lt -2 lw 1.000 +set y2zeroaxis lt -2 lw 1.000 +set tics in +set ticslevel 0.5 +set ticscale 1 0.5 +set mxtics default +set mytics default +set mx2tics default +set my2tics default +set xtics border mirror norotate autofreq +set ytics border mirror norotate autofreq +set ztics border nomirror norotate autofreq +set nox2tics +set noy2tics +set title "At x A product " 0.000000,0.000000 "" +set timestamp "" bottom norotate 0.000000,0.000000 "" +set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] ) +set trange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set urange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set xlabel "matrix size" 0.000000,0.000000 "" +set x2label "" 0.000000,0.000000 "" +set timefmt "%d/%m/%y\n%H:%M" +set xrange [ 10 : 1000 ] noreverse nowriteback +set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set ylabel "MFLOPS" 0.000000,0.000000 "" +set y2label "" 0.000000,0.000000 "" +set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zlabel "" 0.000000,0.000000 "" +set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set locale "C" +set xrange [10:1000] +##set yrange [0:400] diff --git a/bench/btl/data/axpy.hh b/bench/btl/data/axpy.hh new file mode 100644 index 000000000..9f53397e3 --- /dev/null +++ b/bench/btl/data/axpy.hh @@ -0,0 +1,108 @@ +#!/usr/bin/gnuplot -persist +# +# +# G N U P L O T +# Linux version 3.7 +# patchlevel 0 +# last modified Thu Jan 14 19:34:53 BST 1999 +# +# Copyright(C) 1986 - 1993, 1998, 1999 +# Thomas Williams, Colin Kelley and many others +# +# Type `help` to access the on-line reference manual +# The gnuplot FAQ is available from +# +# +# Send comments and requests for help to +# Send bugs, suggestions and mods to +# +# set terminal postscript landscape noenhanced monochrome dashed defaultplex "Helvetica" 14 +# set output 'bench_gcc.ps' +set noclip points +set clip one +set noclip two +set bar 1.000000 +set border 31 lt -1 lw 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set boxwidth +set dummy x,y +set format x "%g" +set format y "%g" +set format x2 "%g" +set format y2 "%g" +set format z "%g" +set angles radians +set nogrid +set key title "" +set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 +set nolabel +set noarrow +set nolinestyle +set nologscale +set logscale x 10 +set offsets 0, 0, 0, 0 +set pointsize 1 +set encoding default +set nopolar +set noparametric +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +set nocontour +set clabel '%8.3g' +set mapping cartesian +set nohidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set data style linespoints +set function style lines +set xzeroaxis lt -2 lw 1.000 +set x2zeroaxis lt -2 lw 1.000 +set yzeroaxis lt -2 lw 1.000 +set y2zeroaxis lt -2 lw 1.000 +set tics in +set ticslevel 0.5 +set ticscale 1 0.5 +set mxtics default +set mytics default +set mx2tics default +set my2tics default +set xtics border mirror norotate autofreq +set ytics border mirror norotate autofreq +set ztics border nomirror norotate autofreq +set nox2tics +set noy2tics +set title "Y+=alpha*X " 0.000000,0.000000 "" +set timestamp "" bottom norotate 0.000000,0.000000 "" +set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] ) +set trange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set urange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set xlabel "vector size" 0.000000,0.000000 "" +set x2label "" 0.000000,0.000000 "" +set timefmt "%d/%m/%y\n%H:%M" +set xrange [ 10 : 1000 ] noreverse nowriteback +set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set ylabel "MFLOPS" 0.000000,0.000000 "" +set y2label "" 0.000000,0.000000 "" +set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zlabel "" 0.000000,0.000000 "" +set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set locale "C" +set xrange [1:1000000] +##set yrange [0:550] diff --git a/bench/btl/data/go_mean b/bench/btl/data/go_mean new file mode 100755 index 000000000..80203afc4 --- /dev/null +++ b/bench/btl/data/go_mean @@ -0,0 +1,9 @@ +mkdir $1 +##cp ../libs/*/*.dat $1 + +source mk_mean_script.sh axpy $1 11 2500 100000 250000 > $1/axpy.html +source mk_mean_script.sh matrix_vector $1 11 50 300 500 > $1/matrix_vector.html +source mk_mean_script.sh matrix_matrix $1 11 100 300 500 > $1/matrix_matrix.html +source mk_mean_script.sh aat $1 11 100 300 1000 > $1/aat.html +source mk_mean_script.sh ata $1 11 100 300 1000 > $1/ata.html + diff --git a/bench/btl/data/matrix_matrix.hh b/bench/btl/data/matrix_matrix.hh new file mode 100644 index 000000000..42e97d5c1 --- /dev/null +++ b/bench/btl/data/matrix_matrix.hh @@ -0,0 +1,108 @@ +#!/usr/bin/gnuplot -persist +# +# +# G N U P L O T +# Linux version 3.7 +# patchlevel 0 +# last modified Thu Jan 14 19:34:53 BST 1999 +# +# Copyright(C) 1986 - 1993, 1998, 1999 +# Thomas Williams, Colin Kelley and many others +# +# Type `help` to access the on-line reference manual +# The gnuplot FAQ is available from +# +# +# Send comments and requests for help to +# Send bugs, suggestions and mods to +# +# set terminal postscript landscape noenhanced monochrome dashed defaultplex "Helvetica" 14 +# set output 'bench_gcc.ps' +set noclip points +set clip one +set noclip two +set bar 1.000000 +set border 31 lt -1 lw 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set boxwidth +set dummy x,y +set format x "%g" +set format y "%g" +set format x2 "%g" +set format y2 "%g" +set format z "%g" +set angles radians +set nogrid +set key title "" +set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 +set nolabel +set noarrow +set nolinestyle +set nologscale +set logscale x 10 +set offsets 0, 0, 0, 0 +set pointsize 1 +set encoding default +set nopolar +set noparametric +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +set nocontour +set clabel '%8.3g' +set mapping cartesian +set nohidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set data style linespoints +set function style lines +set xzeroaxis lt -2 lw 1.000 +set x2zeroaxis lt -2 lw 1.000 +set yzeroaxis lt -2 lw 1.000 +set y2zeroaxis lt -2 lw 1.000 +set tics in +set ticslevel 0.5 +set ticscale 1 0.5 +set mxtics default +set mytics default +set mx2tics default +set my2tics default +set xtics border mirror norotate autofreq +set ytics border mirror norotate autofreq +set ztics border nomirror norotate autofreq +set nox2tics +set noy2tics +set title "matrix matrix product " 0.000000,0.000000 "" +set timestamp "" bottom norotate 0.000000,0.000000 "" +set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] ) +set trange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set urange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set xlabel "matrix size" 0.000000,0.000000 "" +set x2label "" 0.000000,0.000000 "" +set timefmt "%d/%m/%y\n%H:%M" +set xrange [ 10 : 1000 ] noreverse nowriteback +set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set ylabel "MFLOPS" 0.000000,0.000000 "" +set y2label "" 0.000000,0.000000 "" +set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zlabel "" 0.000000,0.000000 "" +set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set locale "C" +set xrange [1:1000] +##set yrange [0:400] diff --git a/bench/btl/data/matrix_vector.hh b/bench/btl/data/matrix_vector.hh new file mode 100644 index 000000000..00e8c7c33 --- /dev/null +++ b/bench/btl/data/matrix_vector.hh @@ -0,0 +1,108 @@ +#!/usr/bin/gnuplot -persist +# +# +# G N U P L O T +# Linux version 3.7 +# patchlevel 0 +# last modified Thu Jan 14 19:34:53 BST 1999 +# +# Copyright(C) 1986 - 1993, 1998, 1999 +# Thomas Williams, Colin Kelley and many others +# +# Type `help` to access the on-line reference manual +# The gnuplot FAQ is available from +# +# +# Send comments and requests for help to +# Send bugs, suggestions and mods to +# +# set terminal postscript landscape noenhanced monochrome dashed defaultplex "Helvetica" 14 +# set output 'bench_gcc.ps' +set noclip points +set clip one +set noclip two +set bar 1.000000 +set border 31 lt -1 lw 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set boxwidth +set dummy x,y +set format x "%g" +set format y "%g" +set format x2 "%g" +set format y2 "%g" +set format z "%g" +set angles radians +set nogrid +set key title "" +set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 +set nolabel +set noarrow +set nolinestyle +set nologscale +set logscale x 10 +set offsets 0, 0, 0, 0 +set pointsize 1 +set encoding default +set nopolar +set noparametric +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +set nocontour +set clabel '%8.3g' +set mapping cartesian +set nohidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set data style linespoints +set function style lines +set xzeroaxis lt -2 lw 1.000 +set x2zeroaxis lt -2 lw 1.000 +set yzeroaxis lt -2 lw 1.000 +set y2zeroaxis lt -2 lw 1.000 +set tics in +set ticslevel 0.5 +set ticscale 1 0.5 +set mxtics default +set mytics default +set mx2tics default +set my2tics default +set xtics border mirror norotate autofreq +set ytics border mirror norotate autofreq +set ztics border nomirror norotate autofreq +set nox2tics +set noy2tics +set title "matrix vector product " 0.000000,0.000000 "" +set timestamp "" bottom norotate 0.000000,0.000000 "" +set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] ) +set trange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set urange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] ) +set xlabel "matrix size" 0.000000,0.000000 "" +set x2label "" 0.000000,0.000000 "" +set timefmt "%d/%m/%y\n%H:%M" +set xrange [ 10 : 1000 ] noreverse nowriteback +set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set ylabel "MFLOPS" 0.000000,0.000000 "" +set y2label "" 0.000000,0.000000 "" +set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zlabel "" 0.000000,0.000000 "" +set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] ) +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set locale "C" +set xrange [1:1000] +##set yrange [0:400] diff --git a/bench/btl/data/mean.cxx b/bench/btl/data/mean.cxx new file mode 100644 index 000000000..96d37dc4a --- /dev/null +++ b/bench/btl/data/mean.cxx @@ -0,0 +1,207 @@ +//===================================================== +// File : mean.cxx +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include +#include +#include +#include +#include "bench_parameter.hh" +#include + +using namespace std; + +void read_xy_file(const string & filename, vector & tab_sizes, vector & tab_mflops); +double mean_calc(const vector & tab_sizes, const vector & tab_mflops, const int size_min, const int size_max); + +class Lib_Mean{ + +public: + Lib_Mean( void ):_lib_name(),_mean_in_cache(),_mean_out_of_cache(){ + MESSAGE("Lib_mean Default Ctor"); + MESSAGE("!!! should not be used"); + exit(0); + } + Lib_Mean(const string & name, const double & mic, const double & moc):_lib_name(name),_mean_in_cache(mic),_mean_out_of_cache(moc){ + MESSAGE("Lib_mean Ctor"); + } + Lib_Mean(const Lib_Mean & lm):_lib_name(lm._lib_name),_mean_in_cache(lm._mean_in_cache),_mean_out_of_cache(lm._mean_out_of_cache){ + MESSAGE("Lib_mean Copy Ctor"); + } + ~Lib_Mean( void ){ + MESSAGE("Lib_mean Dtor"); + } + + double _mean_in_cache; + double _mean_out_of_cache; + string _lib_name; + + bool operator < ( const Lib_Mean &right) const + { + //return ( this->_mean_out_of_cache > right._mean_out_of_cache) ; + return ( this->_mean_in_cache > right._mean_in_cache) ; + } + +}; + + +int main( int argc , char *argv[] ) +{ + + if (argc<6){ + INFOS("!!! Error ... usage : main what mic Mic moc Moc filename1 finename2..."); + exit(0); + } + INFOS(argc); + + int min_in_cache=atoi(argv[2]); + int max_in_cache=atoi(argv[3]); + int min_out_of_cache=atoi(argv[4]); + int max_out_of_cache=atoi(argv[5]); + + + multiset s_lib_mean ; + + for (int i=6;i tab_sizes; + vector tab_mflops; + + read_xy_file(filename,tab_sizes,tab_mflops); + + mic=mean_calc(tab_sizes,tab_mflops,min_in_cache,max_in_cache); + moc=mean_calc(tab_sizes,tab_mflops,min_out_of_cache,max_out_of_cache); + + Lib_Mean cur_lib_mean(filename,mic,moc); + + s_lib_mean.insert(cur_lib_mean); + + } + + } + + + cout << "" << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + + set::iterator is ; + + is=s_lib_mean.begin(); + Lib_Mean best(*is); + + + for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){ + + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + cout << " " << endl ; + + } + + cout << "
" << argv[1] << " in cache
mean perf
Mflops
in cache
% best
out of cache
mean perf
Mflops
out of cache
% best
details comments
" << is->_lib_name << " " << is->_mean_in_cache << " " << 100*(is->_mean_in_cache/best._mean_in_cache) << " " << is->_mean_out_of_cache << " " << 100*(is->_mean_out_of_cache/best._mean_out_of_cache) << " " << + "_lib_name<<"_"<snippet/" + "_lib_name<<"_flags\">flags " << + "_lib_name<<"_comments\">click here
" << endl ; + + ofstream output_file ("../order_lib",ios::out) ; + + for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){ + output_file << is->_lib_name << endl ; + } + + output_file.close(); + +} + +void read_xy_file(const string & filename, vector & tab_sizes, vector & tab_mflops){ + + ifstream input_file (filename.c_str(),ios::in) ; + + if (!input_file){ + INFOS("!!! Error opening "<> size >> mflops ){ + nb_point++; + tab_sizes.push_back(size); + tab_mflops.push_back(mflops); + } + SCRUTE(nb_point); + + input_file.close(); +} + +double mean_calc(const vector & tab_sizes, const vector & tab_mflops, const int size_min, const int size_max){ + + int size=tab_sizes.size(); + int nb_sample=0; + double mean=0.0; + + for (int i=0;i=size_min)&&(tab_sizes[i]<=size_max)){ + + nb_sample++; + mean+=tab_mflops[i]; + + } + + + } + + if (nb_sample==0){ + INFOS("no data for mean calculation"); + return 0.0; + } + + return mean/nb_sample; +} + + + + diff --git a/bench/btl/data/mk_gnuplot_script.sh b/bench/btl/data/mk_gnuplot_script.sh new file mode 100644 index 000000000..2ca7b5cb5 --- /dev/null +++ b/bench/btl/data/mk_gnuplot_script.sh @@ -0,0 +1,68 @@ +#! /bin/bash +WHAT=$1 +DIR=$2 +echo $WHAT script generation +cat $WHAT.hh > $WHAT.gnuplot + +DATA_FILE=`find $DIR -name "*.dat" | grep $WHAT` + +echo plot \\ >> $WHAT.gnuplot + +for FILE in $DATA_FILE +do + LAST=$FILE +done + +echo LAST=$LAST + +for FILE in $DATA_FILE +do + if [ $FILE != $LAST ] + then + BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} + echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot + fi +done +BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} +echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot + +#echo set term postscript color >> $WHAT.gnuplot +#echo set output "'"$WHAT.ps"'" >> $WHAT.gnuplot +echo set term pbm small color >> $WHAT.gnuplot +echo set output "'"$WHAT.ppm"'" >> $WHAT.gnuplot +echo plot \\ >> $WHAT.gnuplot + +for FILE in $DATA_FILE +do + if [ $FILE != $LAST ] + then + BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} + echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot + fi +done +BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} +echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot + +echo set term jpeg large >> $WHAT.gnuplot +echo set output "'"$WHAT.jpg"'" >> $WHAT.gnuplot +echo plot \\ >> $WHAT.gnuplot + +for FILE in $DATA_FILE +do + if [ $FILE != $LAST ] + then + BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} + echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot + fi +done +BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} +echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot + + +gnuplot -persist < $WHAT.gnuplot + +rm $WHAT.gnuplot + + + + diff --git a/bench/btl/data/mk_mean_script.sh b/bench/btl/data/mk_mean_script.sh new file mode 100644 index 000000000..bc6821cf1 --- /dev/null +++ b/bench/btl/data/mk_mean_script.sh @@ -0,0 +1,39 @@ +#! /bin/bash +WHAT=$1 +DIR=$2 +MINIC=$3 +MAXIC=$4 +MINOC=$5 +MAXOC=$6 + +WORK_DIR=tmp +mkdir $WORK_DIR + +DATA_FILE=`find $DIR -name "*.dat" | grep _${WHAT}` +echo +for FILE in $DATA_FILE +do + ##echo hello world + ##echo "mk_mean_script1" ${FILE} + BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat} + + ##echo "mk_mean_script1" ${TITLE} + cp $FILE ${WORK_DIR}/${TITLE} + +done + +cd $WORK_DIR +../main $1 $3 $4 $5 $6 * +../mk_new_gnuplot.sh $1 $2 +rm -f *.gnuplot +cd .. + +rm -R $WORK_DIR + + + + + + + + diff --git a/bench/btl/data/mk_new_gnuplot.sh b/bench/btl/data/mk_new_gnuplot.sh new file mode 100755 index 000000000..ba86b2884 --- /dev/null +++ b/bench/btl/data/mk_new_gnuplot.sh @@ -0,0 +1,45 @@ +#! /bin/bash +WHAT=$1 +DIR=$2 +cat ../${WHAT}.hh > ${WHAT}.gnuplot + +DATA_FILE=`cat ../order_lib` + +echo plot \\ >> $WHAT.gnuplot + +for FILE in $DATA_FILE +do + LAST=$FILE +done + + +for FILE in $DATA_FILE +do + if [ $FILE != $LAST ] + then + echo "'"$FILE"'" ",\\" >> $WHAT.gnuplot + fi +done +echo "'"$LAST"'" >> $WHAT.gnuplot + +echo set term postscript color >> $WHAT.gnuplot +echo set output "'"../${DIR}/$WHAT.ps"'" >> $WHAT.gnuplot +#echo set term pbm color >> $WHAT.gnuplot +#echo set output "'"../${DIR}/$WHAT.ppm"'" >> $WHAT.gnuplot +echo plot \\ >> $WHAT.gnuplot +for FILE in $DATA_FILE +do + if [ $FILE != $LAST ] + then + echo "'"$FILE"'" ",\\" >> $WHAT.gnuplot + fi +done +echo "'"$LAST"'" >> $WHAT.gnuplot + +gnuplot -persist < $WHAT.gnuplot + +rm $WHAT.gnuplot + + + + diff --git a/bench/btl/data/order_lib b/bench/btl/data/order_lib new file mode 100644 index 000000000..5ea998a2e --- /dev/null +++ b/bench/btl/data/order_lib @@ -0,0 +1,8 @@ +eigen2 +C_BLAS +STL +C +gmm +ublas +blitz +F77 diff --git a/bench/btl/data/regularize.cxx b/bench/btl/data/regularize.cxx new file mode 100644 index 000000000..eea2b8b85 --- /dev/null +++ b/bench/btl/data/regularize.cxx @@ -0,0 +1,131 @@ +//===================================================== +// File : regularize.cxx +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include +#include +#include +#include +#include "bench_parameter.hh" +#include + +using namespace std; + +void read_xy_file(const string & filename, vector & tab_sizes, vector & tab_mflops); +void regularize_curve(const string & filename, + const vector & tab_mflops, + const vector & tab_sizes, + int start_cut_size, int stop_cut_size); +///////////////////////////////////////////////////////////////////////////////////////////////// + +int main( int argc , char *argv[] ) +{ + + // input data + + if (argc<4){ + INFOS("!!! Error ... usage : main filename start_cut_size stop_cut_size regularize_filename"); + exit(0); + } + INFOS(argc); + + int start_cut_size=atoi(argv[2]); + int stop_cut_size=atoi(argv[3]); + + string filename=argv[1]; + string regularize_filename=argv[4]; + + INFOS(filename); + INFOS("start_cut_size="< tab_sizes; + vector tab_mflops; + + read_xy_file(filename,tab_sizes,tab_mflops); + + // regularizeing + + regularize_curve(regularize_filename,tab_mflops,tab_sizes,start_cut_size,stop_cut_size); + + +} + +////////////////////////////////////////////////////////////////////////////////////// + +void regularize_curve(const string & filename, + const vector & tab_mflops, + const vector & tab_sizes, + int start_cut_size, int stop_cut_size) +{ + int size=tab_mflops.size(); + ofstream output_file (filename.c_str(),ios::out) ; + + int i=0; + + while(tab_sizes[i] & tab_sizes, vector & tab_mflops){ + + ifstream input_file (filename.c_str(),ios::in) ; + + if (!input_file){ + INFOS("!!! Error opening "<> size >> mflops ){ + nb_point++; + tab_sizes.push_back(size); + tab_mflops.push_back(mflops); + } + SCRUTE(nb_point); + + input_file.close(); +} + diff --git a/bench/btl/data/smooth.cxx b/bench/btl/data/smooth.cxx new file mode 100644 index 000000000..e5270cc32 --- /dev/null +++ b/bench/btl/data/smooth.cxx @@ -0,0 +1,198 @@ +//===================================================== +// File : smooth.cxx +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include +#include +#include +#include +#include +#include "bench_parameter.hh" +#include + +using namespace std; + +void read_xy_file(const string & filename, vector & tab_sizes, vector & tab_mflops); +void write_xy_file(const string & filename, vector & tab_sizes, vector & tab_mflops); +void smooth_curve(const vector & tab_mflops, vector & smooth_tab_mflops,int window_half_width); +void centered_smooth_curve(const vector & tab_mflops, vector & smooth_tab_mflops,int window_half_width); + +///////////////////////////////////////////////////////////////////////////////////////////////// + +int main( int argc , char *argv[] ) +{ + + // input data + + if (argc<3){ + INFOS("!!! Error ... usage : main filename window_half_width smooth_filename"); + exit(0); + } + INFOS(argc); + + int window_half_width=atoi(argv[2]); + + string filename=argv[1]; + string smooth_filename=argv[3]; + + INFOS(filename); + INFOS("window_half_width="< tab_sizes; + vector tab_mflops; + + read_xy_file(filename,tab_sizes,tab_mflops); + + // smoothing + + vector smooth_tab_mflops; + + //smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width); + centered_smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width); + + // output result + + write_xy_file(smooth_filename,tab_sizes,smooth_tab_mflops); + + +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +template +double weighted_mean(const VECTOR & data) +{ + + double mean=0.0; + + for (int i=0 ; i & tab_mflops, vector & smooth_tab_mflops,int window_half_width){ + + int window_width=2*window_half_width+1; + + int size=tab_mflops.size(); + + vector sample(window_width); + + for (int i=0 ; i < size ; i++){ + + for ( int j=0 ; j < window_width ; j++ ){ + + int shifted_index=i+j-window_half_width; + if (shifted_index<0) shifted_index=0; + if (shifted_index>size-1) shifted_index=size-1; + sample[j]=tab_mflops[shifted_index]; + + } + + smooth_tab_mflops.push_back(weighted_mean(sample)); + + } + +} + +void centered_smooth_curve(const vector & tab_mflops, vector & smooth_tab_mflops,int window_half_width){ + + int max_window_width=2*window_half_width+1; + + int size=tab_mflops.size(); + + + for (int i=0 ; i < size ; i++){ + + deque sample; + + + sample.push_back(tab_mflops[i]); + + for ( int j=1 ; j <= window_half_width ; j++ ){ + + int before=i-j; + int after=i+j; + + if ((before>=0)&&(after & tab_sizes, vector & tab_mflops){ + + ofstream output_file (filename.c_str(),ios::out) ; + + for (int i=0 ; i < tab_sizes.size() ; i++) + { + output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ; + } + + output_file.close(); + +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void read_xy_file(const string & filename, vector & tab_sizes, vector & tab_mflops){ + + ifstream input_file (filename.c_str(),ios::in) ; + + if (!input_file){ + INFOS("!!! Error opening "<> size >> mflops ){ + nb_point++; + tab_sizes.push_back(size); + tab_mflops.push_back(mflops); + } + SCRUTE(nb_point); + + input_file.close(); +} + diff --git a/bench/btl/data/smooth_all.sh b/bench/btl/data/smooth_all.sh new file mode 100755 index 000000000..3e5bfdf47 --- /dev/null +++ b/bench/btl/data/smooth_all.sh @@ -0,0 +1,68 @@ +#! /bin/bash +ORIG_DIR=$1 +SMOOTH_DIR=${ORIG_DIR}_smooth +mkdir ${SMOOTH_DIR} + +AXPY_FILE=`find ${ORIG_DIR} -name "*.dat" | grep axpy` +for FILE in ${AXPY_FILE} +do + echo $FILE + BASE=${FILE##*/} + ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}_tmp + ./regularize ${SMOOTH_DIR}/${BASE}_tmp 2500 15000 ${SMOOTH_DIR}/${BASE} + rm -f ${SMOOTH_DIR}/${BASE}_tmp +done + + +MATRIX_VECTOR_FILE=`find ${ORIG_DIR} -name "*.dat" | grep matrix_vector` +for FILE in ${MATRIX_VECTOR_FILE} +do + echo $FILE + BASE=${FILE##*/} + ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}_tmp + ./regularize ${SMOOTH_DIR}/${BASE}_tmp 50 180 ${SMOOTH_DIR}/${BASE} + rm -f ${SMOOTH_DIR}/${BASE}_tmp +done + +MATRIX_MATRIX_FILE=`find ${ORIG_DIR} -name "*.dat" | grep matrix_matrix` +for FILE in ${MATRIX_MATRIX_FILE} +do + echo $FILE + BASE=${FILE##*/} + ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE} +done + +AAT_FILE=`find ${ORIG_DIR} -name "*.dat" | grep _aat` +for FILE in ${AAT_FILE} +do + echo $FILE + BASE=${FILE##*/} + ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE} +done + + +ATA_FILE=`find ${ORIG_DIR} -name "*.dat" | grep _ata` +for FILE in ${ATA_FILE} +do + echo $FILE + BASE=${FILE##*/} + ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE} +done + +### no smoothing for tinyvector and matrices libs + +TINY_BLITZ_FILE=`find ${ORIG_DIR} -name "*.dat" | grep tiny_blitz` +for FILE in ${TINY_BLITZ_FILE} +do + echo $FILE + BASE=${FILE##*/} + cp ${ORIG_DIR}/${BASE} ${SMOOTH_DIR}/${BASE} +done + +TVMET_FILE=`find ${ORIG_DIR} -name "*.dat" | grep tvmet` +for FILE in ${TVMET_FILE} +do + echo $FILE + BASE=${FILE##*/} + cp ${ORIG_DIR}/${BASE} ${SMOOTH_DIR}/${BASE} +done diff --git a/bench/btl/generic_bench/bench.hh b/bench/btl/generic_bench/bench.hh new file mode 100644 index 000000000..f46965c2f --- /dev/null +++ b/bench/btl/generic_bench/bench.hh @@ -0,0 +1,90 @@ +//===================================================== +// File : bench.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:16 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BENCH_HH +#define BENCH_HH +#include "bench_parameter.hh" +#include +#include "utilities.h" +#include "size_lin_log.hh" +#include "dump_file_x_y.hh" +#include +#include +#include "timers/portable_perf_analyzer.hh" +//#include "timers/mixed_perf_analyzer.hh" +//#include "timers/x86_perf_analyzer.hh" +//#include "timers/STL_perf_analyzer.hh" + +using namespace std; + +template class Perf_Analyzer, class Action> +void bench( int size_min, int size_max, int nb_point ){ + + // bench name + + string filename="bench_"+Action::name()+".dat"; + + INFOS("starting " < tab_mflops(nb_point); + std::vector tab_sizes(nb_point); + + // matrices and vector size calculations + + size_lin_log(nb_point,size_min,size_max,tab_sizes); + + // loop on matrix size + + Perf_Analyzer perf_action; + + for (int i=nb_point-1;i>=0;i--) + { + //INFOS("size=" < +void bench( int size_min, int size_max, int nb_point ){ + + // if the rdtsc is not available : + bench(size_min,size_max,nb_point); + // if the rdtsc is available : +// bench(size_min,size_max,nb_point); + + + // Only for small problem size. Otherwize it will be too long + //bench(size_min,size_max,nb_point); + //bench(size_min,size_max,nb_point); + +} + +#endif diff --git a/bench/btl/generic_bench/bench_parameter.hh b/bench/btl/generic_bench/bench_parameter.hh new file mode 100644 index 000000000..e2db997fd --- /dev/null +++ b/bench/btl/generic_bench/bench_parameter.hh @@ -0,0 +1,53 @@ +//===================================================== +// File : bench_parameter.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:16 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BENCH_PARAMETER_HH +#define BENCH_PARAMETER_HH + +// minimal time for each measurement +#define REAL_TYPE float +// minimal time for each measurement +#define MIN_TIME 1.0 +// nb of point on bench curves +#define NB_POINT 100 +// min vector size for axpy bench +#define MIN_AXPY 2 +// max vector size for axpy bench +#define MAX_AXPY 1000000 +// min matrix size for matrix vector product bench +#define MIN_MV 2 +// max matrix size for matrix vector product bench +#define MAX_MV 1024 +// min matrix size for matrix matrix product bench +#define MIN_MM 2 +// max matrix size for matrix matrix product bench +#define MAX_MM 1024 +// min matrix size for LU bench +#define MIN_LU 10 +// max matrix size for LU bench +#define MAX_LU 1000 +// max size for tiny vector and matrix +#define TINY_MV_MAX_SIZE 16 +// default nb_sample for x86 timer +#define DEFAULT_NB_SAMPLE 1000 + +// how many times we run a single bench (keep the best perf) +#define NB_TRIES 3 + +#endif diff --git a/bench/btl/generic_bench/init/init_function.hh b/bench/btl/generic_bench/init/init_function.hh new file mode 100644 index 000000000..c7b348957 --- /dev/null +++ b/bench/btl/generic_bench/init/init_function.hh @@ -0,0 +1,55 @@ +//===================================================== +// File : init_function.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:18 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef INIT_FUNCTION_HH +#define INIT_FUNCTION_HH + +double simple_function(int index) +{ + return index; +} + +double simple_function(int index_i, int index_j) +{ + return index_i+index_j; +} + +double pseudo_random(int index) +{ + // INFOS("random="<<(std::rand()/double(RAND_MAX))); + return std::rand()/double(RAND_MAX); +} + +double pseudo_random(int index_i, int index_j) +{ + return std::rand()/double(RAND_MAX); +} + + +double null_function(int index) +{ + return 0.0; +} + +double null_function(int index_i, int index_j) +{ + return 0.0; +} + +#endif diff --git a/bench/btl/generic_bench/init/init_matrix.hh b/bench/btl/generic_bench/init/init_matrix.hh new file mode 100644 index 000000000..27f8b42aa --- /dev/null +++ b/bench/btl/generic_bench/init/init_matrix.hh @@ -0,0 +1,53 @@ +//===================================================== +// File : init_matrix.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef INIT_MATRIX_HH +#define INIT_MATRIX_HH + +// The Vector class must satisfy the following part of STL vector concept : +// resize() method +// [] operator for setting element +// value_type defined +template +void init_row(Vector & X, int size, int row){ + + X.resize(size); + + for (int j=0;j +void init_matrix(Vector & A, int size){ + + A.resize(size); + for (int row=0; row(A[row],size,row); + } + + +} + +#endif diff --git a/bench/btl/generic_bench/init/init_vector.hh b/bench/btl/generic_bench/init/init_vector.hh new file mode 100644 index 000000000..faf14f953 --- /dev/null +++ b/bench/btl/generic_bench/init/init_vector.hh @@ -0,0 +1,37 @@ +//===================================================== +// File : init_vector.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:18 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef INIT_VECTOR_HH +#define INIT_VECTOR_HH + +// The Vector class must satisfy the following part of STL vector concept : +// resize() method +// [] operator for setting element +// value_type defined +template +void init_vector(Vector & X, int size){ + + X.resize(size); + + for (int i=0;i +// Copyright (C) EDF R&D, lun sep 30 14:23:16 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BENCH_STATIC_HH +#define BENCH_STATIC_HH +#include "bench_parameter.hh" +#include +#include "utilities.h" +#include "dump_file_x_y.hh" +#include "static/static_size_generator.hh" +#include "timers/portable_perf_analyzer.hh" +#include "timers/mixed_perf_analyzer.hh" +#include "timers/x86_perf_analyzer.hh" + +using namespace std; + + +template class Perf_Analyzer, template class Action, template class Interface> +void bench_static(void) +{ + string filename = "bench_" + Action >::name() + ".dat"; + + INFOS("starting " << filename); + + const int max_size = TINY_MV_MAX_SIZE; + + std::vector tab_mflops; + std::vector tab_sizes; + + static_size_generator::go(tab_sizes,tab_mflops); + + dump_file_x_y(tab_sizes,tab_mflops,filename); +} + +// default Perf Analyzer +template class Action, template class Interface> +void bench_static(void) +{ + bench_static(); + //bench_static(); + //bench_static(); +} + +#endif + + + + + + + + + + + + + + + diff --git a/bench/btl/generic_bench/static/intel_bench_fixed_size.hh b/bench/btl/generic_bench/static/intel_bench_fixed_size.hh new file mode 100644 index 000000000..b4edcbc46 --- /dev/null +++ b/bench/btl/generic_bench/static/intel_bench_fixed_size.hh @@ -0,0 +1,66 @@ +//===================================================== +// File : intel_bench_fixed_size.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, mar déc 3 18:59:37 CET 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef _BENCH_FIXED_SIZE_HH_ +#define _BENCH_FIXED_SIZE_HH_ + +#include "utilities.h" +#include "function_time.hh" + +template +double bench_fixed_size(int size, unsigned long long & nb_calc,unsigned long long & nb_init) +{ + + Action action(size); + + double time_baseline=time_init(nb_init,action); + + while (time_baseline < MIN_TIME) { + + //INFOS("nb_init="< +class STL_Perf_Analyzer{ +public: + STL_Perf_Analyzer(unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos() + { + MESSAGE("STL_Perf_Analyzer Ctor"); + }; + STL_Perf_Analyzer( const STL_Perf_Analyzer & ){ + INFOS("Copy Ctor not implemented"); + exit(0); + }; + ~STL_Perf_Analyzer( void ){ + MESSAGE("STL_Perf_Analyzer Dtor"); + }; + + + inline double eval_mflops(int size) + { + + ACTION action(size); + + _chronos.start_baseline(_nb_sample); + + do { + + action.initialize(); + } while (_chronos.check()); + + double baseline_time=_chronos.get_time(); + + _chronos.start(_nb_sample); + do { + action.initialize(); + action.calculate(); + } while (_chronos.check()); + + double calculate_time=_chronos.get_time(); + + double corrected_time=calculate_time-baseline_time; + + // cout << size <<" "< +// Copyright (C) EDF R&D, mar déc 3 18:59:35 CET 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// STL Timer Class. Adapted (L.P.) from the timer class by Musser et Al +// described int the Book : STL Tutorial and reference guide. +// Define a timer class for analyzing algorithm performance. +#include +#include +#include +#include +#include +using namespace std; + +class STL_Timer { +public: + STL_Timer(){ baseline = false; }; // Default constructor + // Start a series of r trials: + void start(unsigned int r){ + reps = r; + count = 0; + iterations.clear(); + iterations.reserve(reps); + initial = time(0); + }; + // Start a series of r trials to determine baseline time: + void start_baseline(unsigned int r) + { + baseline = true; + start(r); + } + // Returns true if the trials have been completed, else false + bool check() + { + ++count; + final = time(0); + if (initial < final) { + iterations.push_back(count); + initial = final; + count = 0; + } + return (iterations.size() < reps); + }; + // Returns the results for external use + double get_time( void ) + { + sort(iterations.begin(), iterations.end()); + return 1.0/iterations[reps/2]; + }; +private: + unsigned int reps; // Number of trials + // For storing loop iterations of a trial + vector iterations; + // For saving initial and final times of a trial + time_t initial, final; + // For counting loop iterations of a trial + unsigned long count; + // true if this is a baseline computation, false otherwise + bool baseline; + // For recording the baseline time + double baseline_time; +}; + diff --git a/bench/btl/generic_bench/timers/mixed_perf_analyzer.hh b/bench/btl/generic_bench/timers/mixed_perf_analyzer.hh new file mode 100644 index 000000000..e190236e0 --- /dev/null +++ b/bench/btl/generic_bench/timers/mixed_perf_analyzer.hh @@ -0,0 +1,73 @@ +//===================================================== +// File : mixed_perf_analyzer.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, mar déc 3 18:59:36 CET 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef _MIXED_PERF_ANALYSER_HH +#define _MIXED_PERF_ANALYSER_HH + +#include "x86_perf_analyzer.hh" +#include "portable_perf_analyzer.hh" + +// choose portable perf analyzer for long calculations and x86 analyser for short ones + + +template +class Mixed_Perf_Analyzer{ + +public: + Mixed_Perf_Analyzer( void ):_x86pa(),_ppa(),_use_ppa(true) + { + MESSAGE("Mixed_Perf_Analyzer Ctor"); + }; + Mixed_Perf_Analyzer( const Mixed_Perf_Analyzer & ){ + INFOS("Copy Ctor not implemented"); + exit(0); + }; + ~Mixed_Perf_Analyzer( void ){ + MESSAGE("Mixed_Perf_Analyzer Dtor"); + }; + + + inline double eval_mflops(int size) + { + + double result=0.0; + if (_use_ppa){ + result=_ppa.eval_mflops(size); + if (_ppa.get_nb_calc()>DEFAULT_NB_SAMPLE){_use_ppa=false;} + } + else{ + result=_x86pa.eval_mflops(size); + } + + return result; + } + +private: + + Portable_Perf_Analyzer _ppa; + X86_Perf_Analyzer _x86pa; + bool _use_ppa; + +}; + +#endif + + + + diff --git a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh new file mode 100644 index 000000000..709f0de5d --- /dev/null +++ b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh @@ -0,0 +1,98 @@ +//===================================================== +// File : portable_perf_analyzer.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002 +// Copyright (C) 2008 Gael Guennebaud +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef _PORTABLE_PERF_ANALYZER_HH +#define _PORTABLE_PERF_ANALYZER_HH + +#include "utilities.h" +#include "timers/portable_timer.hh" + +template +class Portable_Perf_Analyzer{ +public: + Portable_Perf_Analyzer( void ):_nb_calc(1),_chronos(){ + MESSAGE("Portable_Perf_Analyzer Ctor"); + }; + Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){ + INFOS("Copy Ctor not implemented"); + exit(0); + }; + ~Portable_Perf_Analyzer( void ){ + MESSAGE("Portable_Perf_Analyzer Dtor"); + }; + + + + inline double eval_mflops(int size) + { + Action action(size); + + + double time_action = time_calculate(action); + while (time_action < MIN_TIME) + { + _nb_calc *= 2; + action.initialize(); + time_action = time_calculate(action); + } + + // optimize + for (int i=1; i +// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef _PORTABLE_PERF_ANALYZER_HH +#define _PORTABLE_PERF_ANALYZER_HH + +#include "utilities.h" +#include "timers/portable_timer.hh" + +template +class Portable_Perf_Analyzer{ +public: + Portable_Perf_Analyzer( void ):_nb_calc(1),_nb_init(1),_chronos(){ + MESSAGE("Portable_Perf_Analyzer Ctor"); + }; + Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){ + INFOS("Copy Ctor not implemented"); + exit(0); + }; + ~Portable_Perf_Analyzer( void ){ + MESSAGE("Portable_Perf_Analyzer Dtor"); + }; + + + + inline double eval_mflops(int size) + { + + Action action(size); + +// double time_baseline = time_init(action); +// while (time_baseline < MIN_TIME_INIT) +// { +// _nb_init *= 2; +// time_baseline = time_init(action); +// } +// +// // optimize +// for (int i=1; i +class X86_Perf_Analyzer{ +public: + X86_Perf_Analyzer( unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos() + { + MESSAGE("X86_Perf_Analyzer Ctor"); + _chronos.find_frequency(); + }; + X86_Perf_Analyzer( const X86_Perf_Analyzer & ){ + INFOS("Copy Ctor not implemented"); + exit(0); + }; + ~X86_Perf_Analyzer( void ){ + MESSAGE("X86_Perf_Analyzer Dtor"); + }; + + + inline double eval_mflops(int size) + { + + ACTION action(size); + + int nb_loop=5; + double calculate_time=0.0; + double baseline_time=0.0; + + for (int j=0 ; j < nb_loop ; j++){ + + _chronos.clear(); + + for(int i=0 ; i < _nb_sample ; i++) + { + _chronos.start(); + action.initialize(); + action.calculate(); + _chronos.stop(); + _chronos.add_get_click(); + } + + calculate_time += double(_chronos.get_shortest_clicks())/_chronos.frequency(); + + if (j==0) action.check_result(); + + _chronos.clear(); + + for(int i=0 ; i < _nb_sample ; i++) + { + _chronos.start(); + action.initialize(); + _chronos.stop(); + _chronos.add_get_click(); + + } + + baseline_time+=double(_chronos.get_shortest_clicks())/_chronos.frequency(); + + } + + double corrected_time = (calculate_time-baseline_time)/double(nb_loop); + + +// INFOS("_nb_sample="<<_nb_sample); +// INFOS("baseline_time="< +// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef _X86_TIMER_HH +#define _X86_TIMER_HH + +#include +#include +#include +#include +//#include "system_time.h" +#define u32 unsigned int +#include +#include "utilities.h" +#include +#include +#include +#include + +// frequence de la becanne en Hz +//#define FREQUENCY 648000000 +//#define FREQUENCY 1400000000 +#define FREQUENCY 1695000000 + +using namespace std; + + +class X86_Timer { + +public : + + X86_Timer( void ):_frequency(FREQUENCY),_nb_sample(0) + { + MESSAGE("X86_Timer Default Ctor"); + } + + inline void start( void ){ + + rdtsc(_click_start.n32[0],_click_start.n32[1]); + + } + + + inline void stop( void ){ + + rdtsc(_click_stop.n32[0],_click_stop.n32[1]); + + } + + + inline double frequency( void ){ + return _frequency; + } + + double get_elapsed_time_in_second( void ){ + + return (_click_stop.n64-_click_start.n64)/double(FREQUENCY); + + + } + + unsigned long long get_click( void ){ + + return (_click_stop.n64-_click_start.n64); + + } + + inline void find_frequency( void ){ + + time_t initial, final; + int dummy=2; + + initial = time(0); + start(); + do { + dummy+=2; + } + while(time(0)==initial); + // On est au debut d'un cycle d'une seconde !!! + initial = time(0); + start(); + do { + dummy+=2; + } + while(time(0)==initial); + final=time(0); + stop(); + // INFOS("fine grained time : "<< get_elapsed_time_in_second()); + // INFOS("coarse grained time : "<< final-initial); + _frequency=_frequency*get_elapsed_time_in_second()/double(final-initial); + /// INFOS("CPU frequency : "<< _frequency); + + } + + void add_get_click( void ){ + + _nb_sample++; + _counted_clicks[get_click()]++; + fill_history_clicks(); + + } + + void dump_statistics(string filemane){ + + ofstream outfile (filemane.c_str(),ios::out) ; + + std::map::iterator itr; + for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++) + { + outfile << (*itr).first << " " << (*itr).second << endl ; + } + + outfile.close(); + + } + + void dump_history(string filemane){ + + ofstream outfile (filemane.c_str(),ios::out) ; + + + + for(int i=0 ; i<_history_mean_clicks.size() ; i++) + { + outfile << i << " " + << _history_mean_clicks[i] << " " + << _history_shortest_clicks[i] << " " + << _history_most_occured_clicks[i] << endl ; + } + + outfile.close(); + + } + + + + double get_mean_clicks( void ){ + + std::map::iterator itr; + + unsigned long long mean_clicks=0; + + for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++) + { + + mean_clicks+=(*itr).second*(*itr).first; + } + + return mean_clicks/double(_nb_sample); + + } + + double get_shortest_clicks( void ){ + + return double((*_counted_clicks.begin()).first); + + } + + void fill_history_clicks( void ){ + + _history_mean_clicks.push_back(get_mean_clicks()); + _history_shortest_clicks.push_back(get_shortest_clicks()); + _history_most_occured_clicks.push_back(get_most_occured_clicks()); + + } + + + double get_most_occured_clicks( void ){ + + unsigned long long moc=0; + unsigned long long max_occurence=0; + + std::map::iterator itr; + + for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++) + { + + if (max_occurence<=(*itr).second){ + max_occurence=(*itr).second; + moc=(*itr).first; + } + } + + return double(moc); + + } + + void clear( void ) + { + _counted_clicks.clear(); + + _history_mean_clicks.clear(); + _history_shortest_clicks.clear(); + _history_most_occured_clicks.clear(); + + _nb_sample=0; + } + + + +private : + + union + { + unsigned long int n32[2] ; + unsigned long long n64 ; + } _click_start; + + union + { + unsigned long int n32[2] ; + unsigned long long n64 ; + } _click_stop; + + double _frequency ; + + map _counted_clicks; + + vector _history_mean_clicks; + vector _history_shortest_clicks; + vector _history_most_occured_clicks; + + unsigned long long _nb_sample; + + + +}; + + +#endif diff --git a/bench/btl/generic_bench/utils/dump_file_x_y.hh b/bench/btl/generic_bench/utils/dump_file_x_y.hh new file mode 100644 index 000000000..6b99dcb10 --- /dev/null +++ b/bench/btl/generic_bench/utils/dump_file_x_y.hh @@ -0,0 +1,47 @@ +//===================================================== +// File : dump_file_x_y.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:20 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef DUMP_FILE_X_Y_HH +#define DUMP_FILE_X_Y_HH +#include +#include + +// The Vector class must satisfy the following part of STL vector concept : +// resize() method +// [] operator for seting element +// the vector element must have the << operator define + +using namespace std; + +template +void dump_file_x_y(const Vector_A & X, const Vector_B & Y, const std::string & filename){ + + ofstream outfile (filename.c_str(),ios::out) ; + int size=X.size(); + + for (int i=0;i +// Copyright (C) EDF R&D, mar déc 3 18:59:37 CET 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef SIZE_LIN_LOG +#define SIZE_LIN_LOG + +#include "size_log.hh" + +template +void size_lin_log(const int nb_point, const int size_min, const int size_max, Vector & X) +{ + int ten=10; + int nine=9; + + X.resize(nb_point); + + if (nb_point>ten){ + + for (int i=0;i +void size_log(const int nb_point, const int size_min, const int size_max, Vector & X) +{ + X.resize(nb_point); + + float ls_min=log(float(size_min)); + float ls_max=log(float(size_max)); + + float ls=0.0; + + float delta_ls=(ls_max-ls_min)/(float(nb_point-1)); + + int size=0; + + for (int i=0;i +//# include ok for gcc3.01 +# include + +/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ + +# define HEREWEARE cout< +// Copyright (C) EDF R&D, lun sep 30 14:23:22 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ATLAS_LU_solve_interface_HH +#define ATLAS_LU_solve_interface_HH +#include "ATLAS_interface.hh" +extern "C" +{ +#include +#include +#include +#include "cblas.h" +#include + +} + +template +class ATLAS_LU_solve_interface : public ATLAS_interface +{ +public : + + typedef typename ATLAS_interface::gene_matrix gene_matrix; + typedef typename ATLAS_interface::gene_vector gene_vector; + + typedef int * Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot, int N) + { + + pivot = new int[N]; + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + delete pivot; + + } + + + inline static void LU_factor(gene_matrix & LU, Pivot_Vector & pivot, int N) + { + + int error=ATL_dgetrf(CblasColMajor,N,N,LU,N,pivot); + + } + + inline static void LU_solve(const gene_matrix & LU, const Pivot_Vector pivot, const gene_vector &B, gene_vector X, int N) + { + + copy_vector(B,X,N); + ATL_dgetrs(CblasColMajor,CblasNoTrans,N,1,LU,N,pivot,X,N); + + } + +}; + +template<> +class ATLAS_LU_solve_interface : public ATLAS_interface +{ +public : + + typedef int * Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot, int N) + { + + pivot = new int[N]; + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + delete pivot; + + } + + + inline static void LU_factor(gene_matrix & LU, Pivot_Vector & pivot, int N) + { + + int error=ATL_sgetrf(CblasColMajor,N,N,LU,N,pivot); + + } + + inline static void LU_solve(const gene_matrix & LU, const Pivot_Vector pivot, const gene_vector &B, gene_vector X, int N) + { + + copy_vector(B,X,N); + ATL_sgetrs(CblasColMajor,CblasNoTrans,N,1,LU,N,pivot,X,N); + + } + +}; + + +#endif + + + diff --git a/bench/btl/libs/ATLAS/ATLAS_interface.hh b/bench/btl/libs/ATLAS/ATLAS_interface.hh new file mode 100644 index 000000000..a0e93854b --- /dev/null +++ b/bench/btl/libs/ATLAS/ATLAS_interface.hh @@ -0,0 +1,120 @@ +//===================================================== +// File : ATLAS_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:21 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef ATLAS_PRODUIT_MATRICE_VECTEUR_HH +#define ATLAS_PRODUIT_MATRICE_VECTEUR_HH +#include "f77_interface_base.hh" +#include +extern "C" +{ +#include +#include +#include +#include "cblas.h" + +} + +template +class ATLAS_interface : public f77_interface_base +{ +public : + + typedef typename f77_interface_base::gene_matrix gene_matrix; + typedef typename f77_interface_base::gene_vector gene_vector; + + static inline std::string name( void ) + { + return "ATLAS"; + } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + + ATL_dgemv(CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + ATL_dgemm(CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) + { + ATL_dgemm(CblasTrans,CblasNoTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) + { + ATL_dgemm(CblasNoTrans,CblasTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + + + static inline void axpy(real coef, const gene_vector & X, gene_vector & Y, int N) + { + ATL_daxpy(N,coef,X,1,Y,1); + } +}; + +template<> +class ATLAS_interface : public f77_interface_base +{ +public : + + static inline std::string name( void ) + { + return "ATLAS"; + } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + + ATL_sgemv(CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + ATL_sgemm(CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) + { + ATL_sgemm(CblasTrans,CblasNoTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) + { + ATL_sgemm(CblasNoTrans,CblasTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + + static inline void axpy(float coef, const gene_vector & X, gene_vector & Y, int N) + { + ATL_saxpy(N,coef,X,1,Y,1); + } +}; + + +#endif + + + diff --git a/bench/btl/libs/ATLAS/CMakeLists.txt b/bench/btl/libs/ATLAS/CMakeLists.txt new file mode 100644 index 000000000..e047b4e08 --- /dev/null +++ b/bench/btl/libs/ATLAS/CMakeLists.txt @@ -0,0 +1,4 @@ + +include_directories(${BLITZ_INCLUDES}) +add_executable(btl_blitz main.cpp) +target_link_libraries(btl_blitz ${BLITZ_LIBRARIES}) diff --git a/bench/btl/libs/ATLAS/main.cpp b/bench/btl/libs/ATLAS/main.cpp new file mode 100644 index 000000000..2383a7367 --- /dev/null +++ b/bench/btl/libs/ATLAS/main.cpp @@ -0,0 +1,49 @@ +//===================================================== +// File : main.cpp +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:21 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "ATLAS_interface.hh" +#include "ATLAS_LU_solve_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" + + +int main() +{ + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + // bench > >(MIN_LU,MAX_LU,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/ATLAS/titi.txt b/bench/btl/libs/ATLAS/titi.txt new file mode 100644 index 000000000..470501f6f --- /dev/null +++ b/bench/btl/libs/ATLAS/titi.txt @@ -0,0 +1,33 @@ +Bonjour à tous, + +Une dizaine de candidats Neptune se sont déjà déclarés pour la formation C++ +(sur la base de 2 jours/semaine pendant 1 mois). + +Il faut faire une proposition de date pour la formation. Les vacances scolaires zone C (Paris) +se terminent le 22 avril (au matin) nous pourrions commencer ce jour. + +A priori il me semble que deux jours consécutifs soient préférables. Je propose les mardi et mercredi +de chaque semaine. Sachant qu'il y a 2 jeudi (1er et 8 mai) consécutifs qui sont fériés. + +Dans cette hypothèse les dates de formation seraient : + +Mardi 22 avril (Vincent/Marc) +Mercredi 23 avril (Marc) + +Mardi 29 avril (Marc/Antoine) +Mercredi 30 avril (Antoine) + +Mardi 6 mai (Antoine) +Mercredi 7 mai (Antoine) + +Mardi 13 mai (Laurent) +Mercredi 14 mai (Laurent) + +J'ai mis entre parenthèse les intervenants principaux (on doit choisir le deuxième formateur pour chaque session). + +Qu'en pensez-vous ? + +Je dois toujours présenter un programme, pouvez-vous me donner vos programmes respectifs...? + + +Laurent diff --git a/bench/btl/libs/C/CMakeLists.txt b/bench/btl/libs/C/CMakeLists.txt new file mode 100644 index 000000000..d3d2312d8 --- /dev/null +++ b/bench/btl/libs/C/CMakeLists.txt @@ -0,0 +1,2 @@ +include_directories(${PROJECT_SOURCE_DIR}/libs/f77) +btl_add_bench(btl_C main.cpp) diff --git a/bench/btl/libs/C/C_interface.hh b/bench/btl/libs/C/C_interface.hh new file mode 100755 index 000000000..b688f18fa --- /dev/null +++ b/bench/btl/libs/C/C_interface.hh @@ -0,0 +1,96 @@ +//===================================================== +// File : C_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:23 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef C_INTERFACE_HH +#define C_INTERFACE_HH + +#include "f77_interface.hh" + +template +class C_interface : public f77_interface_base { + +public : + + typedef typename f77_interface_base::gene_matrix gene_matrix; + typedef typename f77_interface_base::gene_vector gene_vector; + + static inline std::string name() { return "C"; } + + static inline void matrix_vector_product(const gene_matrix & A, const gene_vector & B, gene_vector & X, int N) + { + for (int i=0;i +// Copyright (C) EDF R&D, lun sep 30 14:23:23 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "bench.hh" +#include "C_interface.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" +//#include "action_lu_solve.hh" +#include "timers/mixed_perf_analyzer.hh" + +int main() +{ + + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + + return 0; +} + + diff --git a/bench/btl/libs/C_BLAS/CMakeLists.txt b/bench/btl/libs/C_BLAS/CMakeLists.txt new file mode 100644 index 000000000..9654bf8ad --- /dev/null +++ b/bench/btl/libs/C_BLAS/CMakeLists.txt @@ -0,0 +1,4 @@ + +include_directories(${CBLAS_INCLUDES} ${PROJECT_SOURCE_DIR}/libs/f77) +btl_add_bench(btl_cblas main.cpp) +target_link_libraries(btl_cblas ${CBLAS_LIBRARIES}) diff --git a/bench/btl/libs/C_BLAS/C_BLAS_interface.hh b/bench/btl/libs/C_BLAS/C_BLAS_interface.hh new file mode 100644 index 000000000..e637c0e5e --- /dev/null +++ b/bench/btl/libs/C_BLAS/C_BLAS_interface.hh @@ -0,0 +1,131 @@ +//===================================================== +// File : C_BLAS_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:28 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef C_BLAS_PRODUIT_MATRICE_VECTEUR_HH +#define C_BLAS_PRODUIT_MATRICE_VECTEUR_HH + +#include "f77_interface.hh" + +extern "C" +{ +#include "cblas.h" +} + +template +class C_BLAS_interface : public f77_interface_base +{ +public : + + typedef typename f77_interface_base::gene_matrix gene_matrix; + typedef typename f77_interface_base::gene_vector gene_vector; + + static inline std::string name( void ) + { + return "C_BLAS"; + } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + cblas_dgemv(CblasColMajor,CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + } + + static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + cblas_dgemv(CblasColMajor,CblasTrans,N,N,1.0,A,N,B,1,0.0,X,1); + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + cblas_dgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void transposed_matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + cblas_dgemm(CblasColMajor,CblasTrans,CblasTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) + { + cblas_dgemm(CblasColMajor,CblasTrans,CblasNoTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) + { + cblas_dgemm(CblasColMajor,CblasNoTrans,CblasTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void axpy(real coef, const gene_vector & X, gene_vector & Y, int N) + { + cblas_daxpy(N,coef,X,1,Y,1); + } + +}; + +template<> +class C_BLAS_interface : public f77_interface_base +{ +public : + + static inline std::string name( void ) + { + return "C_BLAS"; + } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + cblas_sgemv(CblasColMajor,CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + } + + static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + cblas_sgemv(CblasColMajor,CblasTrans,N,N,1.0,A,N,B,1,0.0,X,1); + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + cblas_sgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void transposed_matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + cblas_sgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) + { + cblas_sgemm(CblasColMajor,CblasTrans,CblasNoTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) + { + cblas_sgemm(CblasColMajor,CblasNoTrans,CblasTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void axpy(float coef, const gene_vector & X, gene_vector & Y, int N) + { + cblas_saxpy(N,coef,X,1,Y,1); + } + +}; + + +#endif + + + diff --git a/bench/btl/libs/C_BLAS/main.cpp b/bench/btl/libs/C_BLAS/main.cpp new file mode 100644 index 000000000..d88effa29 --- /dev/null +++ b/bench/btl/libs/C_BLAS/main.cpp @@ -0,0 +1,49 @@ +//===================================================== +// File : main.cpp +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:28 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "C_BLAS_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" + + +int main() +{ + + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + //bench > >(MIN_LU,MAX_LU,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/INTEL_BLAS/INTEL_BLAS_LU_solve_interface.hh b/bench/btl/libs/INTEL_BLAS/INTEL_BLAS_LU_solve_interface.hh new file mode 100644 index 000000000..616ab4720 --- /dev/null +++ b/bench/btl/libs/INTEL_BLAS/INTEL_BLAS_LU_solve_interface.hh @@ -0,0 +1,127 @@ +//===================================================== +// File : INTEL_BLAS_LU_solve_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:29 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef INTEL_BLAS_LU_solve_interface_HH +#define INTEL_BLAS_LU_solve_interface_HH +#include "INTEL_BLAS_interface.hh" +extern "C" +{ +// void dgetrf_(int *M, int *N, double *A, int *LDA, int *IPIV, int *INFO); +// void dgetrs_(char *TRANS, int *N, int *NRHS, double *A, int *LDA, int *IPIV, double *B, int *LDB, int *INFO); +// void sgetrf_(int *M, int *N, float *A, int *LDA, int *IPIV, int *INFO); +// void sgetrs_(char *TRANS, int *N, int *NRHS, float *A, int *LDA, int *IPIV, double *B, int *LDB, int *INFO); +#include "mkl_lapack.h" + +} + +template +class INTEL_BLAS_LU_solve_interface : public INTEL_BLAS_interface +{ +public : + + typedef typename INTEL_BLAS_interface::gene_matrix gene_matrix; + typedef typename INTEL_BLAS_interface::gene_vector gene_vector; + + typedef int * Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot, int N) + { + + pivot = new int[N]; + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + delete pivot; + + } + + + inline static void LU_factor(gene_matrix & LU, Pivot_Vector & pivot, int N) + { + + int info; + DGETRF(&N,&N,LU,&N,pivot,&info); + + } + + inline static void LU_solve(const gene_matrix & LU, const Pivot_Vector pivot, const gene_vector &B, gene_vector X, int N) + { + int info; + int one=1; + + char * transpose="N"; + + copy_vector(B,X,N); + DGETRS(transpose,&N,&one,LU,&N,pivot,X,&N,&info); + + } + +}; + +template<> +class INTEL_BLAS_LU_solve_interface : public INTEL_BLAS_interface +{ +public : + + typedef int * Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot, int N) + { + + pivot = new int[N]; + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + delete pivot; + + } + + + inline static void LU_factor(gene_matrix & LU, Pivot_Vector & pivot, int N) + { + + int info; + SGETRF(&N,&N,LU,&N,pivot,&info); + + } + + inline static void LU_solve(const gene_matrix & LU, const Pivot_Vector pivot, const gene_vector &B, gene_vector X, int N) + { + + char * transpose="N"; + int info; + int one=1; + copy_vector(B,X,N); + SGETRS(transpose,&N,&one,LU,&N,pivot,X,&N,&info); + + } + +}; + + +#endif + + + diff --git a/bench/btl/libs/INTEL_BLAS/INTEL_BLAS_interface.hh b/bench/btl/libs/INTEL_BLAS/INTEL_BLAS_interface.hh new file mode 100644 index 000000000..778aaf8b1 --- /dev/null +++ b/bench/btl/libs/INTEL_BLAS/INTEL_BLAS_interface.hh @@ -0,0 +1,95 @@ +//===================================================== +// File : INTEL_BLAS_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:29 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef INTEL_BLAS_PRODUIT_MATRICE_VECTEUR_HH +#define INTEL_BLAS_PRODUIT_MATRICE_VECTEUR_HH +#include "f77_interface.hh" +extern "C" +{ +#include "mkl_cblas.h" +} + +template +class INTEL_BLAS_interface : public f77_interface_base +{ +public : + + typedef typename f77_interface_base::gene_matrix gene_matrix; + typedef typename f77_interface_base::gene_vector gene_vector; + + static inline std::string name( void ) { return "INTEL_BLAS"; } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) { + cblas_dgemv(CblasColMajor,CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) { + cblas_dgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) { + cblas_dgemm(CblasColMajor,CblasTrans,CblasNoTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) { + cblas_dgemm(CblasColMajor,CblasNoTrans,CblasTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void axpy(real coef, const gene_vector & X, gene_vector & Y, int N) { + cblas_daxpy(N,coef,X,1,Y,1); + } + +}; + +template<> +class INTEL_BLAS_interface : public f77_interface_base +{ +public : + + static inline std::string name() { return "INTEL_BLAS"; } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) { + // cblas_sgemv(CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + cblas_sgemv(CblasColMajor,CblasNoTrans,N,N,1.0,A,N,B,1,0.0,X,1); + + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) { + cblas_sgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,N,N,N,1.0,A,N,B,N,0.0,X,N); + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) { + cblas_sgemm(CblasColMajor,CblasTrans,CblasNoTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) { + cblas_sgemm(CblasColMajor,CblasNoTrans,CblasTrans,N,N,N,1.0,A,N,A,N,0.0,X,N); + } + + static inline void axpy(float coef, const gene_vector & X, gene_vector & Y, int N) { + cblas_saxpy(N,coef,X,1,Y,1); + } + +}; + + +#endif + + + diff --git a/bench/btl/libs/INTEL_BLAS/config.sh b/bench/btl/libs/INTEL_BLAS/config.sh new file mode 100755 index 000000000..0ba48fe90 --- /dev/null +++ b/bench/btl/libs/INTEL_BLAS/config.sh @@ -0,0 +1,2 @@ +#! /bin/bash +export LD_LIBRARY_PATH=/opt/intel/mkl/lib/32:${LD_LIBRARY_PATH} diff --git a/bench/btl/libs/INTEL_BLAS/main.cpp b/bench/btl/libs/INTEL_BLAS/main.cpp new file mode 100644 index 000000000..b91d93470 --- /dev/null +++ b/bench/btl/libs/INTEL_BLAS/main.cpp @@ -0,0 +1,49 @@ +//===================================================== +// File : main.cpp +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:29 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "INTEL_BLAS_interface.hh" +#include "INTEL_BLAS_LU_solve_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" + +int main() +{ + + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + +// bench > >(MIN_LU,MAX_LU,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/STL/CMakeLists.txt b/bench/btl/libs/STL/CMakeLists.txt new file mode 100644 index 000000000..2897298d1 --- /dev/null +++ b/bench/btl/libs/STL/CMakeLists.txt @@ -0,0 +1,2 @@ + +btl_add_bench(btl_STL main.cpp) diff --git a/bench/btl/libs/STL/STL_interface.hh b/bench/btl/libs/STL/STL_interface.hh new file mode 100644 index 000000000..5b1a384af --- /dev/null +++ b/bench/btl/libs/STL/STL_interface.hh @@ -0,0 +1,190 @@ +//===================================================== +// File : STL_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:24 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef STL_INTERFACE_HH +#define STL_INTERFACE_HH +#include +#include +#include "utilities.h" + +using namespace std; + +template +class STL_interface{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef stl_matrix gene_matrix; + + typedef stl_vector gene_vector; + + static inline std::string name( void ) + { + return "STL"; + } + + static void free_matrix(gene_matrix & A, int N){} + + static void free_vector(gene_vector & B){} + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A = A_stl; + } + + static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){ + B = B_stl; + } + + static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){ + B_stl = B ; + } + + + static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){ + A_stl = A ; + } + + static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){ + for (int i=0;i > >(MIN_AXPY,MAX_AXPY,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/STL_algo/CMakeLists.txt b/bench/btl/libs/STL_algo/CMakeLists.txt new file mode 100644 index 000000000..e4387aba8 --- /dev/null +++ b/bench/btl/libs/STL_algo/CMakeLists.txt @@ -0,0 +1,2 @@ + +btl_add_bench(btl_STL_algo main.cpp) diff --git a/bench/btl/libs/STL_algo/STL_algo_interface.hh b/bench/btl/libs/STL_algo/STL_algo_interface.hh new file mode 100644 index 000000000..8854479a6 --- /dev/null +++ b/bench/btl/libs/STL_algo/STL_algo_interface.hh @@ -0,0 +1,138 @@ +//===================================================== +// File : STL_algo_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:24 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef STL_ALGO_INTERFACE_HH +#define STL_ALGO_INTERFACE_HH +#include +#include +#include +#include +#include "utilities.h" + + +template +class STL_algo_interface{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef stl_matrix gene_matrix; + + typedef stl_vector gene_vector; + + static inline std::string name( void ) + { + return "STL_algo"; + } + + static void free_matrix(gene_matrix & A, int N){} + + static void free_vector(gene_vector & B){} + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A=A_stl ; + } + + static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){ + B=B_stl ; + } + + static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){ + B_stl=B ; + } + + static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){ + A_stl=A ; + } + + static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){ + for (int i=0;i +// Copyright (C) EDF R&D, lun sep 30 14:23:23 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "STL_algo_interface.hh" +#include "bench.hh" +#include "action_atv_product.hh" +#include "action_axpy.hh" + +int main() +{ + + + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/blitz/CMakeLists.txt b/bench/btl/libs/blitz/CMakeLists.txt new file mode 100644 index 000000000..1cb71c36d --- /dev/null +++ b/bench/btl/libs/blitz/CMakeLists.txt @@ -0,0 +1,4 @@ + +include_directories(${BLITZ_INCLUDES}) +btl_add_bench(btl_blitz main.cpp) +target_link_libraries(btl_blitz ${BLITZ_LIBRARIES}) diff --git a/bench/btl/libs/blitz/blitz_LU_solve_interface.hh b/bench/btl/libs/blitz/blitz_LU_solve_interface.hh new file mode 100644 index 000000000..dcb9f567f --- /dev/null +++ b/bench/btl/libs/blitz/blitz_LU_solve_interface.hh @@ -0,0 +1,192 @@ +//===================================================== +// File : blitz_LU_solve_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:31 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BLITZ_LU_SOLVE_INTERFACE_HH +#define BLITZ_LU_SOLVE_INTERFACE_HH + +#include "blitz/array.h" +#include + +BZ_USING_NAMESPACE(blitz) + +template +class blitz_LU_solve_interface : public blitz_interface +{ + +public : + + typedef typename blitz_interface::gene_matrix gene_matrix; + typedef typename blitz_interface::gene_vector gene_vector; + + typedef blitz::Array Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot,int N) + { + + pivot.resize(N); + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + return; + + } + + + static inline real matrix_vector_product_sliced(const gene_matrix & A, gene_vector B, int row, int col_start, int col_end) + { + + real somme=0.; + + for (int j=col_start ; j=big ) big = abs( LU( i, j ) ) ; + } + if( big==0. ) { + INFOS( "blitz_LU_factor::Singular matrix" ) ; + exit( 0 ) ; + } + ImplicitScaling( i ) = 1./big ; + } + // Loop over columns of Crout's method : + for( int j=0; j=big ) { + dum = ImplicitScaling( i )*abs( theSum ) ; + big = dum ; + index_max = i ; + } + } + // Interchanging rows and the scale factor : + if( j!=index_max ) { + for( int k=0; k=0; i-- ) { + theSum = X( i ) ; + // theSum = B( i ) ; + theSum -= matrix_vector_product_sliced(LU, X, i, i+1, N) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*X( Range( i+1, toEnd ) ) ) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*B( Range( i+1, toEnd ) ) ) ; + // Store a component of the solution vector : + X( i ) = theSum/LU( i, i ) ; + // B( i ) = theSum/LU( i, i ) ; + } + + } + +}; + +#endif diff --git a/bench/btl/libs/blitz/blitz_interface.hh b/bench/btl/libs/blitz/blitz_interface.hh new file mode 100644 index 000000000..0ba73fc0d --- /dev/null +++ b/bench/btl/libs/blitz/blitz_interface.hh @@ -0,0 +1,147 @@ +//===================================================== +// File : blitz_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:30 CEST 2002 +// Copyright (C) 2008 Gael Guennebaud +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BLITZ_INTERFACE_HH +#define BLITZ_INTERFACE_HH + +#include +#include +#include +#include +#include +#include + +BZ_USING_NAMESPACE(blitz) + +template +class blitz_interface{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef blitz::Array gene_matrix; + typedef blitz::Array gene_vector; +// typedef blitz::Matrix gene_matrix; +// typedef blitz::Vector gene_vector; + + static inline std::string name() { return "blitz"; } + + static void free_matrix(gene_matrix & A, int N){} + + static void free_vector(gene_vector & B){} + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A.resize(A_stl[0].size(),A_stl.size()); + for (int j=0; j(source); +// for (int i=0;i(source); + cible = source; + } + +}; + +#endif diff --git a/bench/btl/libs/blitz/main.cpp b/bench/btl/libs/blitz/main.cpp new file mode 100644 index 000000000..65fbb6b11 --- /dev/null +++ b/bench/btl/libs/blitz/main.cpp @@ -0,0 +1,49 @@ +//===================================================== +// File : main.cpp +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:30 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "blitz_interface.hh" +#include "blitz_LU_solve_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" +#include "action_atv_product.hh" + +int main() +{ + + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + //bench > >(MIN_LU,MAX_LU,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/eigen2/CMakeLists.txt b/bench/btl/libs/eigen2/CMakeLists.txt new file mode 100644 index 000000000..6ac0ab24a --- /dev/null +++ b/bench/btl/libs/eigen2/CMakeLists.txt @@ -0,0 +1,8 @@ + +include_directories(${EIGEN2_INCLUDE_DIR}) +btl_add_bench(btl_eigen2 main.cpp) + +IF(NOT BTL_NOVEC) + btl_add_bench(btl_eigen2_novec main.cpp) + set_target_properties(btl_eigen2_novec PROPERTIES COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE") +ENDIF(NOT BTL_NOVEC) diff --git a/bench/btl/libs/eigen2/eigen2_LU_solve_interface.hh b/bench/btl/libs/eigen2/eigen2_LU_solve_interface.hh new file mode 100644 index 000000000..dcb9f567f --- /dev/null +++ b/bench/btl/libs/eigen2/eigen2_LU_solve_interface.hh @@ -0,0 +1,192 @@ +//===================================================== +// File : blitz_LU_solve_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:31 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BLITZ_LU_SOLVE_INTERFACE_HH +#define BLITZ_LU_SOLVE_INTERFACE_HH + +#include "blitz/array.h" +#include + +BZ_USING_NAMESPACE(blitz) + +template +class blitz_LU_solve_interface : public blitz_interface +{ + +public : + + typedef typename blitz_interface::gene_matrix gene_matrix; + typedef typename blitz_interface::gene_vector gene_vector; + + typedef blitz::Array Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot,int N) + { + + pivot.resize(N); + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + return; + + } + + + static inline real matrix_vector_product_sliced(const gene_matrix & A, gene_vector B, int row, int col_start, int col_end) + { + + real somme=0.; + + for (int j=col_start ; j=big ) big = abs( LU( i, j ) ) ; + } + if( big==0. ) { + INFOS( "blitz_LU_factor::Singular matrix" ) ; + exit( 0 ) ; + } + ImplicitScaling( i ) = 1./big ; + } + // Loop over columns of Crout's method : + for( int j=0; j=big ) { + dum = ImplicitScaling( i )*abs( theSum ) ; + big = dum ; + index_max = i ; + } + } + // Interchanging rows and the scale factor : + if( j!=index_max ) { + for( int k=0; k=0; i-- ) { + theSum = X( i ) ; + // theSum = B( i ) ; + theSum -= matrix_vector_product_sliced(LU, X, i, i+1, N) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*X( Range( i+1, toEnd ) ) ) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*B( Range( i+1, toEnd ) ) ) ; + // Store a component of the solution vector : + X( i ) = theSum/LU( i, i ) ; + // B( i ) = theSum/LU( i, i ) ; + } + + } + +}; + +#endif diff --git a/bench/btl/libs/eigen2/eigen2_interface.hh b/bench/btl/libs/eigen2/eigen2_interface.hh new file mode 100644 index 000000000..5d8ad9466 --- /dev/null +++ b/bench/btl/libs/eigen2/eigen2_interface.hh @@ -0,0 +1,128 @@ +//===================================================== +// Copyright (C) 2008 Gael Guennebaud +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef EIGEN2_INTERFACE_HH +#define EIGEN2_INTERFACE_HH + +#include +#include + +using namespace Eigen; + +template +class eigen2_interface +{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef Eigen::Matrix gene_matrix; + typedef Eigen::Matrix gene_vector; + + static inline std::string name( void ) + { + #if defined(EIGEN_VECTORIZE_SSE) + if (SIZE==Dynamic) return "eigen2_SSE"; else return "tiny_eigen2_SSE"; + #elif defined(EIGEN_VECTORIZE_ALTIVEC) + if (SIZE==Dynamic) return "eigen2_AltiVec"; else return "tiny_eigen2_AltiVec"; + #else + if (SIZE==Dynamic) return "eigen2"; else return "tiny_eigen2"; + #endif + } + + static void free_matrix(gene_matrix & A, int N) {} + + static void free_vector(gene_vector & B) {} + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A.resize(A_stl[0].size(), A_stl.size()); + + for (int j=0; j +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "eigen2_interface.hh" +#include "bench.hh" +#include "static/bench_static.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" +#include "action_atv_product.hh" + +int main() +{ + + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + + //bench > >(MIN_LU,MAX_LU,NB_POINT); + + bench_static(); + bench_static(); + bench_static(); + + return 0; +} + + diff --git a/bench/btl/libs/f77/CMakeLists.txt b/bench/btl/libs/f77/CMakeLists.txt new file mode 100644 index 000000000..03d0c6167 --- /dev/null +++ b/bench/btl/libs/f77/CMakeLists.txt @@ -0,0 +1,3 @@ + +enable_language(Fortran) +btl_add_bench(btl_f77 main.cpp dmxv.f smxv.f dmxm.f smxm.f daxpy.f saxpy.f data.f sata.f daat.f saat.f) diff --git a/bench/btl/libs/f77/daat.f b/bench/btl/libs/f77/daat.f new file mode 100644 index 000000000..a50329a66 --- /dev/null +++ b/bench/btl/libs/f77/daat.f @@ -0,0 +1,14 @@ + SUBROUTINE DAAT(A,X,N) +** +** X = AT * A + REAL*8 A(N,N),X(N,N),R + DO 20 I=1,N + DO 20 J=1,N + R=0. + DO 10 K=1,N + R=R+A(I,K)*A(J,K) + 10 CONTINUE + X(I,J)=R + 20 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/data.f b/bench/btl/libs/f77/data.f new file mode 100644 index 000000000..709211ca5 --- /dev/null +++ b/bench/btl/libs/f77/data.f @@ -0,0 +1,14 @@ + SUBROUTINE DATA(A,X,N) +** +** X = AT * A + REAL*8 A(N,N),X(N,N),R + DO 20 I=1,N + DO 20 J=1,N + R=0. + DO 10 K=1,N + R=R+A(K,I)*A(K,J) + 10 CONTINUE + X(I,J)=R + 20 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/daxpy.f b/bench/btl/libs/f77/daxpy.f new file mode 100644 index 000000000..94bb846de --- /dev/null +++ b/bench/btl/libs/f77/daxpy.f @@ -0,0 +1,18 @@ + SUBROUTINE DAXPY(N,A,X,Y) +** *************************************** +** CALCULE Y = Y + A*X +** *************************************** +*>N NOMBRE D'OPERATIONS A FAIRE +*>A CONSTANTE MULTIPLICATIVE +*>X TABLEAU +*=Y TABLEAU DES RESULTATS +*A R. SANCHEZ ( EARLY WINTER 1987 ) +*V M.F. ROBEAU + REAL*8 X(1),Y(1) + REAL*8 A + DO 10 I=1,N + Y(I)=Y(I)+A*X(I) + 10 CONTINUE + RETURN + END + diff --git a/bench/btl/libs/f77/dmxm.f b/bench/btl/libs/f77/dmxm.f new file mode 100644 index 000000000..eb7ef9006 --- /dev/null +++ b/bench/btl/libs/f77/dmxm.f @@ -0,0 +1,32 @@ + SUBROUTINE DMXM(A,N,B,M,C,L) +** +** C = A * B +** A ET B MATRICES A(N,M) B(M,L) ==> C(N,L) +** +*>A PREMIERE MATRICE +*>N PREMIERE DIMENSION DE A ET DE C +*>B DEUXIEME MATRICE +*>M DEUXIEME DIMENSION DE A ET PERMIERE DE B +*L DEUXIEME DIMENSION DE B ET DE C +*A R. SANCHEZ ( EARLY WINTER 1987 ) +*V M.F. ROBEAU +*M AM BAUDRON - AVRIL 94 +*: ERREUR DANS L'APPEL A L'UTILITAIRE SGEMM +*: APPEL A L'UTILITAIRE SGEMM DE LA LIBRAIRIE BLAS SUR HP +*M AM BAUDRON - NOVEMBRE 1991 +*: ERREUR ( SOMME SUR LES TERMES PAS FAITE ) +*: APPEL A L'UTILITAIRE SGEMM DE LA LIBRAIRIE BLAS SUR RISC +*M AM BAUDRON - MAI 1993 +*: CHANGEMENT DES %IF LOCAL SUN MIPS SUITE A INTRODUCTION VERSION IBM + REAL*8 A(N,M),B(M,L),C(N,L),R + DO 20 I=1,N + DO 20 J=1,L + R=0. + DO 10 K=1,M + R=R+A(I,K)*B(K,J) + 10 CONTINUE + C(I,J)=R + 20 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/dmxm.f.mfr b/bench/btl/libs/f77/dmxm.f.mfr new file mode 100644 index 000000000..82ccac9a5 --- /dev/null +++ b/bench/btl/libs/f77/dmxm.f.mfr @@ -0,0 +1,36 @@ + + SUBROUTINE DMXM(A,N,B,M,C,L) +** +** C = A * B +** A ET B MATRICES A(N,M) B(M,L) ==> C(N,L) +** +*>A PREMIERE MATRICE +*>N PREMIERE DIMENSION DE A ET DE C +*>B DEUXIEME MATRICE +*>M DEUXIEME DIMENSION DE A ET PERMIERE DE B +*L DEUXIEME DIMENSION DE B ET DE C +*A R. SANCHEZ ( EARLY WINTER 1987 ) +*V M.F. ROBEAU +*M AM BAUDRON - AVRIL 94 +*: ERREUR DANS L'APPEL A L'UTILITAIRE SGEMM +*: APPEL A L'UTILITAIRE SGEMM DE LA LIBRAIRIE BLAS SUR HP +*M AM BAUDRON - NOVEMBRE 1991 +*: ERREUR ( SOMME SUR LES TERMES PAS FAITE ) +*: APPEL A L'UTILITAIRE SGEMM DE LA LIBRAIRIE BLAS SUR RISC +*M AM BAUDRON - MAI 1993 +*: CHANGEMENT DES %IF LOCAL SUN MIPS SUITE A INTRODUCTION VERSION IBM + REAL*8 A(N,M),B(M,L),C(N,L),R + DO 5 J=1,L + DO 5 I=1,N + C(I,J)=0. + 5 CONTINUE + DO 10 K=1,M + DO 20 J=1,L + R=B(K,J) + DO 20 I=1,N + C(I,J)=C(I,J)+A(I,K)*R + 20 CONTINUE + 10 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/dmxv.f b/bench/btl/libs/f77/dmxv.f new file mode 100644 index 000000000..bd7e4d550 --- /dev/null +++ b/bench/btl/libs/f77/dmxv.f @@ -0,0 +1,39 @@ + SUBROUTINE DMXV(A,N,X,M,R) +C +** +** VERSION DOUBLE PRECISION DE MXV +** R = A * X +** A MATRICE A(N,M) +** R ET X VECTEURS +** +*>A PREMIERE MATRICE +*>N PREMIERE DIMENSION DE A +*>X VECTEUR +*>M DEUXIEME DIMENSION DE A +* +// Copyright (C) EDF R&D, lun sep 30 14:23:24 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef F77_INTERFACE_HH +#define F77_INTERFACE_HH +#include "f77_interface_base.hh" +#include + +extern "C" +{ + void dmxv_(double * A, int * N, double * X, int * M, double *R); + void smxv_(float * A, int * N, float * X, int * M, float *R); + + void dmxm_(double * A, int * N, double * B, int * M, double *C, int * K); + void smxm_(float * A, int * N, float * B, int * M, float *C, int * K); + + void data_(double * A, double *X, int * N); + void sata_(float * A, float *X, int * N); + + void daat_(double * A, double *X, int * N); + void saat_(float * A, float *X, int * N); + + void saxpy_(int * N, float * coef, float * X, float *Y); + void daxpy_(int * N, double * coef, double * X, double *Y); +} + +template +class f77_interface : public f77_interface_base +{ +public : + + typedef typename f77_interface_base::gene_matrix gene_matrix; + typedef typename f77_interface_base::gene_vector gene_vector; + + static inline std::string name( void ) + { + return "f77"; + } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + + dmxv_(A,&N,B,&N,X); + + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + + dmxm_(A,&N,B,&N,X,&N); + + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) + { + + data_(A,X,&N); + + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) + { + + daat_(A,X,&N); + + } + + static inline void axpy(real coef, const gene_vector & X, gene_vector & Y, int N) + { + int one=1; + daxpy_(&N,&coef,X,Y); + } + + +}; + + +template<> +class f77_interface : public f77_interface_base +{ +public : + + static inline std::string name( void ) + { + return "F77"; + } + + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N) + { + + smxv_(A,&N,B,&N,X); + + } + + static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N) + { + + smxm_(A,&N,B,&N,X,&N); + + } + + static inline void ata_product(gene_matrix & A, gene_matrix & X, int N) + { + + sata_(A,X,&N); + + } + + static inline void aat_product(gene_matrix & A, gene_matrix & X, int N) + { + + saat_(A,X,&N); + + } + + + static inline void axpy(float coef, const gene_vector & X, gene_vector & Y, int N) + { + saxpy_(&N,&coef,X,Y); + } + +}; + + +#endif + + + diff --git a/bench/btl/libs/f77/f77_interface_base.hh b/bench/btl/libs/f77/f77_interface_base.hh new file mode 100644 index 000000000..ab8a18295 --- /dev/null +++ b/bench/btl/libs/f77/f77_interface_base.hh @@ -0,0 +1,91 @@ +//===================================================== +// File : f77_interface_base.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:25 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef F77_INTERFACE_BASE_HH +#define F77_INTERFACE_BASE_HH + +#include "utilities.h" +#include +template +class f77_interface_base{ + +public: + + typedef real real_type ; + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef real * gene_matrix; + typedef real * gene_vector; + + static void free_matrix(gene_matrix & A, int N){ + delete A; + } + + static void free_vector(gene_vector & B){ + delete B; + } + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + int N = A_stl.size(); + A = new real[N*N]; + for (int j=0;j +// Copyright (C) EDF R&D, lun sep 30 14:23:25 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "f77_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" + + +int main() +{ + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/f77/saat.f b/bench/btl/libs/f77/saat.f new file mode 100644 index 000000000..5d1855d2c --- /dev/null +++ b/bench/btl/libs/f77/saat.f @@ -0,0 +1,14 @@ + SUBROUTINE SAAT(A,X,N) +** +** X = AT * A + REAL*4 A(N,N),X(N,N) + DO 20 I=1,N + DO 20 J=1,N + R=0. + DO 10 K=1,N + R=R+A(I,K)*A(J,K) + 10 CONTINUE + X(I,J)=R + 20 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/sata.f b/bench/btl/libs/f77/sata.f new file mode 100644 index 000000000..3ab83d958 --- /dev/null +++ b/bench/btl/libs/f77/sata.f @@ -0,0 +1,14 @@ + SUBROUTINE SATA(A,X,N) +** +** X = AT * A + REAL*4 A(N,N),X(N,N) + DO 20 I=1,N + DO 20 J=1,N + R=0. + DO 10 K=1,N + R=R+A(K,I)*A(K,J) + 10 CONTINUE + X(I,J)=R + 20 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/saxpy.f b/bench/btl/libs/f77/saxpy.f new file mode 100644 index 000000000..5eda4c2d2 --- /dev/null +++ b/bench/btl/libs/f77/saxpy.f @@ -0,0 +1,16 @@ + SUBROUTINE SAXPY(N,A,X,Y) +** *************************************** +** CALCULE Y = Y + A*X +** *************************************** +*>N NOMBRE D'OPERATIONS A FAIRE +*>A CONSTANTE MULTIPLICATIVE +*>X TABLEAU +*=Y TABLEAU DES RESULTATS +*A R. SANCHEZ ( EARLY WINTER 1987 ) +*V M.F. ROBEAU + DIMENSION X(1),Y(1) + DO 10 I=1,N + Y(I)=Y(I)+A*X(I) + 10 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/smxm.f b/bench/btl/libs/f77/smxm.f new file mode 100644 index 000000000..a1e63adca --- /dev/null +++ b/bench/btl/libs/f77/smxm.f @@ -0,0 +1,32 @@ + SUBROUTINE SMXM(A,N,B,M,C,L) +** +** C = A * B +** A ET B MATRICES A(N,M) B(M,L) ==> C(N,L) +** +*>A PREMIERE MATRICE +*>N PREMIERE DIMENSION DE A ET DE C +*>B DEUXIEME MATRICE +*>M DEUXIEME DIMENSION DE A ET PERMIERE DE B +*L DEUXIEME DIMENSION DE B ET DE C +*A R. SANCHEZ ( EARLY WINTER 1987 ) +*V M.F. ROBEAU +*M AM BAUDRON - AVRIL 94 +*: ERREUR DANS L'APPEL A L'UTILITAIRE SGEMM +*: APPEL A L'UTILITAIRE SGEMM DE LA LIBRAIRIE BLAS SUR HP +*M AM BAUDRON - NOVEMBRE 1991 +*: ERREUR ( SOMME SUR LES TERMES PAS FAITE ) +*: APPEL A L'UTILITAIRE SGEMM DE LA LIBRAIRIE BLAS SUR RISC +*M AM BAUDRON - MAI 1993 +*: CHANGEMENT DES %IF LOCAL SUN MIPS SUITE A INTRODUCTION VERSION IBM + DIMENSION A(N,M),B(M,L),C(N,L) + DO 20 I=1,N + DO 20 J=1,L + R=0. + DO 10 K=1,M + R=R+A(I,K)*B(K,J) + 10 CONTINUE + C(I,J)=R + 20 CONTINUE + RETURN + END diff --git a/bench/btl/libs/f77/smxv.f b/bench/btl/libs/f77/smxv.f new file mode 100644 index 000000000..d2f7ed24e --- /dev/null +++ b/bench/btl/libs/f77/smxv.f @@ -0,0 +1,38 @@ + SUBROUTINE SMXV(A,N,X,M,R) +C +** +** VERSION DOUBLE PRECISION DE MXV +** R = A * X +** A MATRICE A(N,M) +** R ET X VECTEURS +** +*>A PREMIERE MATRICE +*>N PREMIERE DIMENSION DE A +*>X VECTEUR +*>M DEUXIEME DIMENSION DE A +* +// Copyright (C) EDF R&D, lun sep 30 14:23:25 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef TEST_INTERFACE_HH +#define TEST_INTERFACE_HH + +template< class Interface > +void test_interface( void ){ + + Interface::interface_name(); + + typename Interface::gene_matrix A; + + + + + +} + +#endif diff --git a/bench/btl/libs/gmm/CMakeLists.txt b/bench/btl/libs/gmm/CMakeLists.txt new file mode 100644 index 000000000..98759e8b6 --- /dev/null +++ b/bench/btl/libs/gmm/CMakeLists.txt @@ -0,0 +1,3 @@ + +include_directories(${GMM_INCLUDES}) +btl_add_bench(btl_gmm main.cpp) diff --git a/bench/btl/libs/gmm/gmm_LU_solve_interface.hh b/bench/btl/libs/gmm/gmm_LU_solve_interface.hh new file mode 100644 index 000000000..dcb9f567f --- /dev/null +++ b/bench/btl/libs/gmm/gmm_LU_solve_interface.hh @@ -0,0 +1,192 @@ +//===================================================== +// File : blitz_LU_solve_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:31 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BLITZ_LU_SOLVE_INTERFACE_HH +#define BLITZ_LU_SOLVE_INTERFACE_HH + +#include "blitz/array.h" +#include + +BZ_USING_NAMESPACE(blitz) + +template +class blitz_LU_solve_interface : public blitz_interface +{ + +public : + + typedef typename blitz_interface::gene_matrix gene_matrix; + typedef typename blitz_interface::gene_vector gene_vector; + + typedef blitz::Array Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot,int N) + { + + pivot.resize(N); + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + return; + + } + + + static inline real matrix_vector_product_sliced(const gene_matrix & A, gene_vector B, int row, int col_start, int col_end) + { + + real somme=0.; + + for (int j=col_start ; j=big ) big = abs( LU( i, j ) ) ; + } + if( big==0. ) { + INFOS( "blitz_LU_factor::Singular matrix" ) ; + exit( 0 ) ; + } + ImplicitScaling( i ) = 1./big ; + } + // Loop over columns of Crout's method : + for( int j=0; j=big ) { + dum = ImplicitScaling( i )*abs( theSum ) ; + big = dum ; + index_max = i ; + } + } + // Interchanging rows and the scale factor : + if( j!=index_max ) { + for( int k=0; k=0; i-- ) { + theSum = X( i ) ; + // theSum = B( i ) ; + theSum -= matrix_vector_product_sliced(LU, X, i, i+1, N) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*X( Range( i+1, toEnd ) ) ) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*B( Range( i+1, toEnd ) ) ) ; + // Store a component of the solution vector : + X( i ) = theSum/LU( i, i ) ; + // B( i ) = theSum/LU( i, i ) ; + } + + } + +}; + +#endif diff --git a/bench/btl/libs/gmm/gmm_interface.hh b/bench/btl/libs/gmm/gmm_interface.hh new file mode 100644 index 000000000..6a81fe969 --- /dev/null +++ b/bench/btl/libs/gmm/gmm_interface.hh @@ -0,0 +1,119 @@ +//===================================================== +// Copyright (C) 2008 Gael Guennebaud +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef GMM_INTERFACE_HH +#define GMM_INTERFACE_HH + +#include +#include + +using namespace gmm; + +template +class gmm_interface { + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef gmm::dense_matrix gene_matrix; + typedef stl_vector gene_vector; + + static inline std::string name( void ) + { + return "gmm"; + } + + static void free_matrix(gene_matrix & A, int N){ + return ; + } + + static void free_vector(gene_vector & B){ + return ; + } + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A.resize(A_stl[0].size(),A_stl.size()); + + for (int j=0; j +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "gmm_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" +#include "action_atv_product.hh" + +int main() +{ + + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + + //bench > >(MIN_LU,MAX_LU,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/mtl4/.kdbgrc.main b/bench/btl/libs/mtl4/.kdbgrc.main new file mode 100644 index 000000000..fed082f7f --- /dev/null +++ b/bench/btl/libs/mtl4/.kdbgrc.main @@ -0,0 +1,12 @@ +[General] +DebuggerCmdStr= +DriverName=GDB +FileVersion=1 +OptionsSelected= +ProgramArgs= +TTYLevel=7 +WorkingDirectory= + +[Memory] +ColumnWidths=80,0 +NumExprs=0 diff --git a/bench/btl/libs/mtl4/main.cpp b/bench/btl/libs/mtl4/main.cpp new file mode 100644 index 000000000..219570d28 --- /dev/null +++ b/bench/btl/libs/mtl4/main.cpp @@ -0,0 +1,42 @@ +//===================================================== +// Copyright (C) 2008 Gael Guennebaud +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "mtl4_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_lu_solve.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" +#include "action_atv_product.hh" + +int main() +{ + + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/mtl4/mtl4_LU_solve_interface.hh b/bench/btl/libs/mtl4/mtl4_LU_solve_interface.hh new file mode 100644 index 000000000..dcb9f567f --- /dev/null +++ b/bench/btl/libs/mtl4/mtl4_LU_solve_interface.hh @@ -0,0 +1,192 @@ +//===================================================== +// File : blitz_LU_solve_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:31 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef BLITZ_LU_SOLVE_INTERFACE_HH +#define BLITZ_LU_SOLVE_INTERFACE_HH + +#include "blitz/array.h" +#include + +BZ_USING_NAMESPACE(blitz) + +template +class blitz_LU_solve_interface : public blitz_interface +{ + +public : + + typedef typename blitz_interface::gene_matrix gene_matrix; + typedef typename blitz_interface::gene_vector gene_vector; + + typedef blitz::Array Pivot_Vector; + + inline static void new_Pivot_Vector(Pivot_Vector & pivot,int N) + { + + pivot.resize(N); + + } + + inline static void free_Pivot_Vector(Pivot_Vector & pivot) + { + + return; + + } + + + static inline real matrix_vector_product_sliced(const gene_matrix & A, gene_vector B, int row, int col_start, int col_end) + { + + real somme=0.; + + for (int j=col_start ; j=big ) big = abs( LU( i, j ) ) ; + } + if( big==0. ) { + INFOS( "blitz_LU_factor::Singular matrix" ) ; + exit( 0 ) ; + } + ImplicitScaling( i ) = 1./big ; + } + // Loop over columns of Crout's method : + for( int j=0; j=big ) { + dum = ImplicitScaling( i )*abs( theSum ) ; + big = dum ; + index_max = i ; + } + } + // Interchanging rows and the scale factor : + if( j!=index_max ) { + for( int k=0; k=0; i-- ) { + theSum = X( i ) ; + // theSum = B( i ) ; + theSum -= matrix_vector_product_sliced(LU, X, i, i+1, N) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*X( Range( i+1, toEnd ) ) ) ; + // theSum -= sum( LU( i, Range( i+1, toEnd ) )*B( Range( i+1, toEnd ) ) ) ; + // Store a component of the solution vector : + X( i ) = theSum/LU( i, i ) ; + // B( i ) = theSum/LU( i, i ) ; + } + + } + +}; + +#endif diff --git a/bench/btl/libs/mtl4/mtl4_interface.hh b/bench/btl/libs/mtl4/mtl4_interface.hh new file mode 100644 index 000000000..73ff565fc --- /dev/null +++ b/bench/btl/libs/mtl4/mtl4_interface.hh @@ -0,0 +1,120 @@ +//===================================================== +// Copyright (C) 2008 Gael Guennebaud +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef MTL4_INTERFACE_HH +#define MTL4_INTERFACE_HH + +#include +#include + +using namespace mtl; + +template +class mtl4_interface { + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef mtl::dense2D > gene_matrix; + typedef mtl::dense_vector gene_vector; + + static inline std::string name() { return "mtl4"; } + + static void free_matrix(gene_matrix & A, int N){ + return ; + } + + static void free_vector(gene_vector & B){ + return ; + } + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A.change_dim(A_stl[0].size(), A_stl.size()); + + for (int j=0; j +// Copyright (C) EDF R&D, lun sep 30 14:23:30 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "tiny_blitz_interface.hh" +#include "static/bench_static.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "timers/x86_perf_analyzer.hh" + +int main() +{ + bench_static(); + bench_static(); + bench_static(); + + return 0; +} + + diff --git a/bench/btl/libs/tiny_blitz/tiny_blitz_interface.hh b/bench/btl/libs/tiny_blitz/tiny_blitz_interface.hh new file mode 100644 index 000000000..6b26db72d --- /dev/null +++ b/bench/btl/libs/tiny_blitz/tiny_blitz_interface.hh @@ -0,0 +1,106 @@ +//===================================================== +// File : tiny_blitz_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:30 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef TINY_BLITZ_INTERFACE_HH +#define TINY_BLITZ_INTERFACE_HH + +#include "blitz/array.h" +#include "blitz/tiny.h" +#include "blitz/tinymat.h" +#include "blitz/tinyvec.h" +#include + +#include + +BZ_USING_NAMESPACE(blitz) + +template +class tiny_blitz_interface +{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef TinyVector gene_vector; + typedef TinyMatrix gene_matrix; + + static inline std::string name() { return "tiny_blitz"; } + + static void free_matrix(gene_matrix & A, int N){} + + static void free_vector(gene_vector & B){} + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + for (int j=0; j +// Copyright (C) EDF R&D, lun sep 30 14:23:30 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "tvmet_interface.hh" +#include "static/bench_static.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" + +int main() +{ + bench_static(); + bench_static(); + bench_static(); + + return 0; +} + + diff --git a/bench/btl/libs/tvmet/tvmet_interface.hh b/bench/btl/libs/tvmet/tvmet_interface.hh new file mode 100644 index 000000000..dfbfa20aa --- /dev/null +++ b/bench/btl/libs/tvmet/tvmet_interface.hh @@ -0,0 +1,141 @@ +//===================================================== +// File : tvmet_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:30 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef TVMET_INTERFACE_HH +#define TVMET_INTERFACE_HH + +#include +#include + +#include + +using namespace tvmet; + +template +class tvmet_interface{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef Vector gene_vector; + typedef Matrix gene_matrix; + + static inline std::string name( void ) + { + return "tvmet"; + } + + + static void free_matrix(gene_matrix & A, int N){ + + return ; + } + + static void free_vector(gene_vector & B){ + + return ; + + } + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + + for (int i=0; i +// Copyright (C) EDF R&D, lun sep 30 14:23:27 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#include "utilities.h" +#include "ublas_interface.hh" +#include "bench.hh" +#include "action_matrix_vector_product.hh" +#include "action_matrix_matrix_product.hh" +#include "action_axpy.hh" +#include "action_ata_product.hh" +#include "action_aat_product.hh" +#include "action_atv_product.hh" + +int main() +{ + bench > >(MIN_AXPY,MAX_AXPY,NB_POINT); + + bench > >(MIN_MV,MAX_MV,NB_POINT); + bench > >(MIN_MV,MAX_MV,NB_POINT); + + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + bench > >(MIN_MM,MAX_MM,NB_POINT); + + return 0; +} + + diff --git a/bench/btl/libs/ublas/ublas_interface.hh b/bench/btl/libs/ublas/ublas_interface.hh new file mode 100644 index 000000000..c8acb32db --- /dev/null +++ b/bench/btl/libs/ublas/ublas_interface.hh @@ -0,0 +1,131 @@ +//===================================================== +// File : ublas_interface.hh +// Author : L. Plagne +// Copyright (C) EDF R&D, lun sep 30 14:23:27 CEST 2002 +//===================================================== +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +#ifndef UBLAS_INTERFACE_HH +#define UBLAS_INTERFACE_HH + +#include +#include +#include + + +template +class ublas_interface{ + +public : + + typedef real real_type ; + + typedef std::vector stl_vector; + typedef std::vector stl_matrix; + + typedef typename boost::numeric::ublas::matrix gene_matrix; + typedef typename boost::numeric::ublas::vector gene_vector; + + static inline std::string name( void ) { return "ublas"; } + + static void free_matrix(gene_matrix & A, int N) {} + + static void free_vector(gene_vector & B) {} + + static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){ + A.resize(A_stl.size(),A_stl[0].size()); + for (int i=0; i