]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/ublas/benchmarks/bench1/bench1.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / numeric / ublas / benchmarks / bench1 / bench1.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2000-2002
3// Joerg Walter, Mathias Koch
4//
5// Distributed under the Boost Software License, Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// The authors gratefully acknowledge the support of
10// GeNeSys mbH & Co. KG in producing this work.
11//
12
13#ifndef BENCH1_H
14#define BENCH1_H
15
16#include <iostream>
17#include <string>
18#include <valarray>
19
20#include <boost/numeric/ublas/vector.hpp>
21#include <boost/numeric/ublas/matrix.hpp>
22
23#include <boost/timer.hpp>
24
25
26#define BOOST_UBLAS_NOT_USED(x) (void)(x)
27
28
29namespace ublas = boost::numeric::ublas;
30
31void header (std::string text);
32
33template<class T>
34struct footer {
35 void operator () (int multiplies, int plus, int runs, double elapsed) {
36 std::cout << "elapsed: " << elapsed << " s, "
37 << (multiplies * ublas::type_traits<T>::multiplies_complexity +
38 plus * ublas::type_traits<T>::plus_complexity) * runs /
39 (1024 * 1024 * elapsed) << " Mflops" << std::endl;
40 }
41};
42
43template<class T, int N>
44struct c_vector_traits {
45 typedef T type [N];
46};
47template<class T, int N, int M>
48struct c_matrix_traits {
49 typedef T type [N] [M];
50};
51
52template<class T, int N>
53struct initialize_c_vector {
54 void operator () (typename c_vector_traits<T, N>::type &v) {
55 for (int i = 0; i < N; ++ i)
56 v [i] = std::rand () * 1.f;
57// v [i] = 0.f;
58 }
59};
60template<class V>
61BOOST_UBLAS_INLINE
62void initialize_vector (V &v) {
63 int size = v.size ();
64 for (int i = 0; i < size; ++ i)
65 v [i] = std::rand () * 1.f;
66// v [i] = 0.f;
67}
68
69template<class T, int N, int M>
70struct initialize_c_matrix {
71 void operator () (typename c_matrix_traits<T, N, M>::type &m) {
72 for (int i = 0; i < N; ++ i)
73 for (int j = 0; j < M; ++ j)
74 m [i] [j] = std::rand () * 1.f;
75// m [i] [j] = 0.f;
76 }
77};
78template<class M>
79BOOST_UBLAS_INLINE
80void initialize_matrix (M &m) {
81 int size1 = m.size1 ();
82 int size2 = m.size2 ();
83 for (int i = 0; i < size1; ++ i)
84 for (int j = 0; j < size2; ++ j)
85 m (i, j) = std::rand () * 1.f;
86// m (i, j) = 0.f;
87}
88
89template<class T>
90BOOST_UBLAS_INLINE
91void sink_scalar (const T &s) {
92 static T g_s = s;
93}
94
95template<class T, int N>
96struct sink_c_vector {
97 void operator () (const typename c_vector_traits<T, N>::type &v) {
98 static typename c_vector_traits<T, N>::type g_v;
99 for (int i = 0; i < N; ++ i)
100 g_v [i] = v [i];
101 }
102};
103template<class V>
104BOOST_UBLAS_INLINE
105void sink_vector (const V &v) {
106 static V g_v (v);
107}
108
109template<class T, int N, int M>
110struct sink_c_matrix {
111 void operator () (const typename c_matrix_traits<T, N, M>::type &m) {
112 static typename c_matrix_traits<T, N, M>::type g_m;
113 for (int i = 0; i < N; ++ i)
114 for (int j = 0; j < M; ++ j)
115 g_m [i] [j] = m [i] [j];
116 }
117};
118template<class M>
119BOOST_UBLAS_INLINE
120void sink_matrix (const M &m) {
121 static M g_m (m);
122}
123
124template<class T>
125struct peak {
126 void operator () (int runs);
127};
128
129template<class T, int N>
130struct bench_1 {
131 void operator () (int runs);
132};
133
134template<class T, int N>
135struct bench_2 {
136 void operator () (int runs);
137};
138
139template<class T, int N>
140struct bench_3 {
141 void operator () (int runs);
142};
143
144struct safe_tag {};
145struct fast_tag {};
146
147//#define USE_FLOAT
148#define USE_DOUBLE
149// #define USE_STD_COMPLEX
150
151#define USE_C_ARRAY
152// #define USE_BOUNDED_ARRAY
153#define USE_UNBOUNDED_ARRAY
154// #define USE_STD_VALARRAY
155//#define USE_STD_VECTOR
156
157#endif
158
159