action_axpy.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_axpy.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_AXPY
21 #define ACTION_AXPY
22 #include "utilities.h"
23 #include "STL_interface.hh"
24 #include <string>
25 #include "init/init_function.hh"
26 #include "init/init_vector.hh"
27 #include "init/init_matrix.hh"
28 
29 using namespace std;
30 
31 template<class Interface>
32 class Action_axpy {
33 
34 public :
35 
36  // Ctor
37 
38  Action_axpy( int size ):_coef(1.0),_size(size)
39  {
40  MESSAGE("Action_axpy Ctor");
41 
42  // STL vector initialization
43 
44  init_vector<pseudo_random>(X_stl,_size);
45  init_vector<pseudo_random>(Y_stl,_size);
46  init_vector<null_function>(resu_stl,_size);
47 
48  // generic matrix and vector initialization
49 
50  Interface::vector_from_stl(X_ref,X_stl);
51  Interface::vector_from_stl(Y_ref,Y_stl);
52 
53  Interface::vector_from_stl(X,X_stl);
54  Interface::vector_from_stl(Y,Y_stl);
55 
56 
57  }
58 
59  // invalidate copy ctor
60 
62  {
63  INFOS("illegal call to Action_axpy Copy Ctor");
64  exit(1);
65  }
66 
67  // Dtor
68 
69  ~Action_axpy( void ){
70 
71  MESSAGE("Action_axpy Dtor");
72 
73  // deallocation
74 
75  Interface::free_vector(X_ref);
76  Interface::free_vector(Y_ref);
77 
78  Interface::free_vector(X);
79  Interface::free_vector(Y);
80  }
81 
82  // action name
83 
84  static inline std::string name( void )
85  {
86  return "axpy_"+Interface::name();
87  }
88 
89  double nb_op_base( void ){
90  return 2.0*_size;
91  }
92 
93  inline void initialize( void ){
94  Interface::copy_vector(X_ref,X,_size);
95  Interface::copy_vector(Y_ref,Y,_size);
96  }
97 
98  inline void calculate( void ) {
99  BTL_ASM_COMMENT("mybegin axpy");
100  Interface::axpy(_coef,X,Y,_size);
101  BTL_ASM_COMMENT("myend axpy");
102  }
103 
104  void check_result( void ){
105  if (_size>128) return;
106  // calculation check
107 
108  Interface::vector_to_stl(Y,resu_stl);
109 
111 
112  typename Interface::real_type error=
114 
115  if (error>1.e-6){
116  INFOS("WRONG CALCULATION...residual=" << error);
117  exit(0);
118  }
119 
120  }
121 
122 private :
123 
124  typename Interface::stl_vector X_stl;
125  typename Interface::stl_vector Y_stl;
126  typename Interface::stl_vector resu_stl;
127 
128  typename Interface::gene_vector X_ref;
129  typename Interface::gene_vector Y_ref;
130 
131  typename Interface::gene_vector X;
132  typename Interface::gene_vector Y;
133 
134  typename Interface::real_type _coef;
135 
136  int _size;
137 };
138 
139 #endif
Action_axpy::~Action_axpy
~Action_axpy(void)
Definition: action_axpy.hh:69
STL_interface.hh
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Action_axpy::_coef
Interface::real_type _coef
Definition: action_axpy.hh:134
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
Action_axpy::X
Interface::gene_vector X
Definition: action_axpy.hh:131
Action_axpy
Definition: action_axpy.hh:32
Action_axpy::check_result
void check_result(void)
Definition: action_axpy.hh:104
Action_axpy::calculate
void calculate(void)
Definition: action_axpy.hh:98
X
#define X
Definition: icosphere.cpp:20
Action_axpy::_size
int _size
Definition: action_axpy.hh:136
name
static char name[]
Definition: rgamma.c:72
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
init_function.hh
MESSAGE
#define MESSAGE(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:76
Action_axpy::X_ref
Interface::gene_vector X_ref
Definition: action_axpy.hh:128
BTL_ASM_COMMENT
#define BTL_ASM_COMMENT(X)
Definition: btl.hh:44
axpy
int EIGEN_BLAS_FUNC() axpy(const int *n, const RealScalar *palpha, const RealScalar *px, const int *incx, RealScalar *py, const int *incy)
Definition: level1_impl.h:12
Action_axpy::Action_axpy
Action_axpy(const Action_axpy &)
Definition: action_axpy.hh:61
init_vector.hh
init_matrix.hh
Action_axpy::Action_axpy
Action_axpy(int size)
Definition: action_axpy.hh:38
error
static double error
Definition: testRot3.cpp:37
INFOS
#define INFOS(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:22
Action_axpy::Y_ref
Interface::gene_vector Y_ref
Definition: action_axpy.hh:129
std
Definition: BFloat16.h:88
Action_axpy::initialize
void initialize(void)
Definition: action_axpy.hh:93
STL_interface::norm_diff
static real norm_diff(const stl_vector &A, const stl_vector &B)
Definition: STL_interface.hh:203
Action_axpy::resu_stl
Interface::stl_vector resu_stl
Definition: action_axpy.hh:126
Action_axpy::Y_stl
Interface::stl_vector Y_stl
Definition: action_axpy.hh:125
Action_axpy::X_stl
Interface::stl_vector X_stl
Definition: action_axpy.hh:124
Action_axpy::nb_op_base
double nb_op_base(void)
Definition: action_axpy.hh:89
STL_interface::axpy
static void axpy(real coef, const gene_vector &X, gene_vector &Y, int N)
Definition: STL_interface.hh:182
Action_axpy::Y
Interface::gene_vector Y
Definition: action_axpy.hh:132
Action_axpy::name
static std::string name(void)
Definition: action_axpy.hh:84


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:47