diff options
Diffstat (limited to 'bench/btl/libs/blitz')
-rw-r--r-- | bench/btl/libs/blitz/CMakeLists.txt | 19 | ||||
-rw-r--r-- | bench/btl/libs/blitz/btl_blitz.cpp (renamed from bench/btl/libs/blitz/main.cpp) | 0 | ||||
-rw-r--r-- | bench/btl/libs/blitz/btl_tiny_blitz.cpp | 39 | ||||
-rw-r--r-- | bench/btl/libs/blitz/tiny_blitz_interface.hh | 106 |
4 files changed, 161 insertions, 3 deletions
diff --git a/bench/btl/libs/blitz/CMakeLists.txt b/bench/btl/libs/blitz/CMakeLists.txt index 1cb71c36d..880ab7338 100644 --- a/bench/btl/libs/blitz/CMakeLists.txt +++ b/bench/btl/libs/blitz/CMakeLists.txt @@ -1,4 +1,17 @@ -include_directories(${BLITZ_INCLUDES}) -btl_add_bench(btl_blitz main.cpp) -target_link_libraries(btl_blitz ${BLITZ_LIBRARIES}) +find_package(Blitz) + +if (BLITZ_FOUND) + include_directories(${BLITZ_INCLUDES}) + + btl_add_bench(btl_blitz btl_blitz.cpp) + if (BUILD_btl_blitz) + target_link_libraries(btl_blitz ${BLITZ_LIBRARIES}) + endif (BUILD_btl_blitz) + + btl_add_bench(btl_tiny_blitz btl_tiny_blitz.cpp OFF) + if (BUILD_btl_tiny_blitz) + target_link_libraries(btl_tiny_blitz ${BLITZ_LIBRARIES}) + endif (BUILD_btl_tiny_blitz) + +endif (BLITZ_FOUND) diff --git a/bench/btl/libs/blitz/main.cpp b/bench/btl/libs/blitz/btl_blitz.cpp index 16d2b5951..16d2b5951 100644 --- a/bench/btl/libs/blitz/main.cpp +++ b/bench/btl/libs/blitz/btl_blitz.cpp diff --git a/bench/btl/libs/blitz/btl_tiny_blitz.cpp b/bench/btl/libs/blitz/btl_tiny_blitz.cpp new file mode 100644 index 000000000..eff3c1881 --- /dev/null +++ b/bench/btl/libs/blitz/btl_tiny_blitz.cpp @@ -0,0 +1,39 @@ +//===================================================== +// File : main.cpp +// Author : L. Plagne <laurent.plagne@edf.fr)> +// 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" + +BTL_MAIN; + +int main() +{ + bench_static<Action_axpy,tiny_blitz_interface>(); + bench_static<Action_matrix_matrix_product,tiny_blitz_interface>(); + bench_static<Action_matrix_vector_product,tiny_blitz_interface>(); + + return 0; +} + + diff --git a/bench/btl/libs/blitz/tiny_blitz_interface.hh b/bench/btl/libs/blitz/tiny_blitz_interface.hh new file mode 100644 index 000000000..6b26db72d --- /dev/null +++ b/bench/btl/libs/blitz/tiny_blitz_interface.hh @@ -0,0 +1,106 @@ +//===================================================== +// File : tiny_blitz_interface.hh +// Author : L. Plagne <laurent.plagne@edf.fr)> +// 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 <blitz/tinyvec-et.h> + +#include <vector> + +BZ_USING_NAMESPACE(blitz) + +template<class real, int SIZE> +class tiny_blitz_interface +{ + +public : + + typedef real real_type ; + + typedef std::vector<real> stl_vector; + typedef std::vector<stl_vector > stl_matrix; + + typedef TinyVector<real,SIZE> gene_vector; + typedef TinyMatrix<real,SIZE,SIZE> 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<A_stl.size() ; j++) + for (int i=0; i<A_stl[j].size() ; i++) + A(i,j)=A_stl[j][i]; + } + + static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){ + for (int i=0; i<B_stl.size() ; i++) + B(i) = B_stl[i]; + } + + static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){ + for (int i=0; i<B_stl.size() ; i++) + B_stl[i] = B(i); + } + + static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){ + int N = A_stl.size(); + for (int j=0;j<N;j++) + { + A_stl[j].resize(N); + for (int i=0;i<N;i++) + A_stl[j][i] = A(i,j); + } + } + + static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){ + for (int j=0;j<N;j++) + for (int i=0;i<N;i++) + cible(i,j) = source(i,j); + } + + static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){ + for (int i=0;i<N;i++){ + cible(i) = source(i); + } + } + + static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){ + X = product(A,B); + } + + static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){ + X = product(A,B); + } + + static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){ + Y += coef * X; + } + +}; + + +#endif |