action_matrix_matrix_product_bis.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_matrix_matrix_product_bis.hh
3 // Author : L. Plagne <laurent.plagne@edf.fr)>
4 // Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
5 //=====================================================
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 //
20 #ifndef ACTION_MATRIX_MATRIX_PRODUCT_BIS
21 #define ACTION_MATRIX_MATRIX_PRODUCT_BIS
22 #include "utilities.h"
23 #include "STL_interface.hh"
24 #include "STL_timer.hh"
25 #include <string>
26 #include "init_function.hh"
27 #include "init_vector.hh"
28 #include "init_matrix.hh"
29 
30 using namespace std;
31 
32 template<class Interface>
34 
35 public :
36 
37  static inline std::string name( void )
38  {
39  return "matrix_matrix_"+Interface::name();
40  }
41 
42  static double nb_op_base(int size){
43  return 2.0*size*size*size;
44  }
45 
46  static double calculate( int nb_calc, int size ) {
47 
48  // STL matrix and vector initialization
49 
50  typename Interface::stl_matrix A_stl;
51  typename Interface::stl_matrix B_stl;
52  typename Interface::stl_matrix X_stl;
53 
54  init_matrix<pseudo_random>(A_stl,size);
55  init_matrix<pseudo_random>(B_stl,size);
56  init_matrix<null_function>(X_stl,size);
57 
58  // generic matrix and vector initialization
59 
60  typename Interface::gene_matrix A_ref;
61  typename Interface::gene_matrix B_ref;
62  typename Interface::gene_matrix X_ref;
63 
64  typename Interface::gene_matrix A;
65  typename Interface::gene_matrix B;
66  typename Interface::gene_matrix X;
67 
68 
69  Interface::matrix_from_stl(A_ref,A_stl);
70  Interface::matrix_from_stl(B_ref,B_stl);
71  Interface::matrix_from_stl(X_ref,X_stl);
72 
73  Interface::matrix_from_stl(A,A_stl);
74  Interface::matrix_from_stl(B,B_stl);
75  Interface::matrix_from_stl(X,X_stl);
76 
77 
78  // STL_timer utilities
79 
80  STL_timer chronos;
81 
82  // Baseline evaluation
83 
84  chronos.start_baseline(nb_calc);
85 
86  do {
87 
91 
92 
93  // Interface::matrix_matrix_product(A,B,X,size); This line must be commented !!!!
94  }
95  while(chronos.check());
96 
97  chronos.report(true);
98 
99  // Time measurement
100 
101  chronos.start(nb_calc);
102 
103  do {
104 
108 
109  Interface::matrix_matrix_product(A,B,X,size); // here it is not commented !!!!
110  }
111  while(chronos.check());
112 
113  chronos.report(true);
114 
115  double time=chronos.calculated_time/2000.0;
116 
117  // calculation check
118 
119  typename Interface::stl_matrix resu_stl(size);
120 
121  Interface::matrix_to_stl(X,resu_stl);
122 
124 
125  typename Interface::real_type error=
127 
128  if (error>1.e-6){
129  INFOS("WRONG CALCULATION...residual=" << error);
130  exit(1);
131  }
132 
133  // deallocation and return time
134 
135  Interface::free_matrix(A,size);
136  Interface::free_matrix(B,size);
137  Interface::free_matrix(X,size);
138 
139  Interface::free_matrix(A_ref,size);
140  Interface::free_matrix(B_ref,size);
141  Interface::free_matrix(X_ref,size);
142 
143  return time;
144  }
145 
146 };
147 
148 
149 #endif
150 
151 
152 
Action_matrix_matrix_product_bis::name
static std::string name(void)
Definition: action_matrix_matrix_product_bis.hh:37
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
STL_interface.hh
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Action_matrix_matrix_product_bis::calculate
static double calculate(int nb_calc, int size)
Definition: action_matrix_matrix_product_bis.hh:46
X
#define X
Definition: icosphere.cpp:20
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
name
static char name[]
Definition: rgamma.c:72
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
init_function.hh
Action_matrix_matrix_product_bis::nb_op_base
static double nb_op_base(int size)
Definition: action_matrix_matrix_product_bis.hh:42
STL_interface::matrix_matrix_product
static void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: STL_interface.hh:112
init_vector.hh
time
#define time
Definition: timeAdaptAutoDiff.cpp:31
init_matrix.hh
error
static double error
Definition: testRot3.cpp:37
INFOS
#define INFOS(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:22
STL_timer.hh
std
Definition: BFloat16.h:88
Action_matrix_matrix_product_bis
Definition: action_matrix_matrix_product_bis.hh:33
copy_matrix
void copy_matrix(MatrixType &m)
Definition: bench_move_semantics.cpp:19
STL_interface::norm_diff
static real norm_diff(const stl_vector &A, const stl_vector &B)
Definition: STL_interface.hh:203


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:05