aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/btl/actions
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-08-04 11:30:33 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-08-04 11:30:33 +0200
commitc2a92e92a6e5aa0bcbb465220a8beb0687c1449a (patch)
treeb3d615aa6875c0d2bdc3778babd42f9e9b1456aa /bench/btl/actions
parent4bec101470091aae27e7469025c80e31b889f566 (diff)
add ger and lu with partial pivoting in BTL
Diffstat (limited to 'bench/btl/actions')
-rw-r--r--bench/btl/actions/action_aat_product.hh2
-rw-r--r--bench/btl/actions/action_ata_product.hh2
-rw-r--r--bench/btl/actions/action_atv_product.hh1
-rw-r--r--bench/btl/actions/action_axpby.hh1
-rw-r--r--bench/btl/actions/action_axpy.hh2
-rw-r--r--bench/btl/actions/action_cholesky.hh16
-rw-r--r--bench/btl/actions/action_ger.hh128
-rw-r--r--bench/btl/actions/action_partial_lu.hh125
-rw-r--r--bench/btl/actions/action_symv.hh19
-rw-r--r--bench/btl/actions/action_syr2.hh21
-rw-r--r--bench/btl/actions/action_trisolve.hh3
-rw-r--r--bench/btl/actions/basic_actions.hh1
12 files changed, 269 insertions, 52 deletions
diff --git a/bench/btl/actions/action_aat_product.hh b/bench/btl/actions/action_aat_product.hh
index 3d11e7d6f..92930e219 100644
--- a/bench/btl/actions/action_aat_product.hh
+++ b/bench/btl/actions/action_aat_product.hh
@@ -104,7 +104,7 @@ public :
}
void check_result( void ){
-
+ if (_size>128) return;
// calculation check
Interface::matrix_to_stl(X,resu_stl);
diff --git a/bench/btl/actions/action_ata_product.hh b/bench/btl/actions/action_ata_product.hh
index 47531d607..04364fe67 100644
--- a/bench/btl/actions/action_ata_product.hh
+++ b/bench/btl/actions/action_ata_product.hh
@@ -104,7 +104,7 @@ public :
}
void check_result( void ){
-
+ if (_size>128) return;
// calculation check
Interface::matrix_to_stl(X,resu_stl);
diff --git a/bench/btl/actions/action_atv_product.hh b/bench/btl/actions/action_atv_product.hh
index 22d25e23e..a8234514b 100644
--- a/bench/btl/actions/action_atv_product.hh
+++ b/bench/btl/actions/action_atv_product.hh
@@ -93,6 +93,7 @@ public :
void check_result( void )
{
+ if (_size>128) return;
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::atv_product(A_stl,B_stl,X_stl,_size);
diff --git a/bench/btl/actions/action_axpby.hh b/bench/btl/actions/action_axpby.hh
index 7815530ac..99ade7cd8 100644
--- a/bench/btl/actions/action_axpby.hh
+++ b/bench/btl/actions/action_axpby.hh
@@ -91,6 +91,7 @@ public :
}
void check_result( void ){
+ if (_size>128) return;
// calculation check
Interface::vector_to_stl(Y,resu_stl);
diff --git a/bench/btl/actions/action_axpy.hh b/bench/btl/actions/action_axpy.hh
index f127426db..e4cb3a5bd 100644
--- a/bench/btl/actions/action_axpy.hh
+++ b/bench/btl/actions/action_axpy.hh
@@ -102,7 +102,7 @@ public :
}
void check_result( void ){
-
+ if (_size>128) return;
// calculation check
Interface::vector_to_stl(Y,resu_stl);
diff --git a/bench/btl/actions/action_cholesky.hh b/bench/btl/actions/action_cholesky.hh
index a1a30977c..2ec83f021 100644
--- a/bench/btl/actions/action_cholesky.hh
+++ b/bench/btl/actions/action_cholesky.hh
@@ -38,14 +38,13 @@ public :
{
MESSAGE("Action_cholesky Ctor");
- // STL vector initialization
- typename Interface::stl_matrix tmp;
- init_matrix<pseudo_random>(tmp,_size);
- init_matrix<null_function>(X_stl,_size);
- STL_interface<typename Interface::real_type>::ata_product(tmp,X_stl,_size);
-
+ // STL mat/vec initialization
+ init_matrix_symm<pseudo_random>(X_stl,_size);
init_matrix<null_function>(C_stl,_size);
- init_matrix<null_function>(resu_stl,_size);
+
+ // make sure X is invertible
+ for (int i=0; i<_size; ++i)
+ X_stl[i][i] = X_stl[i][i] * 1e2 + 1;
// generic matrix and vector initialization
Interface::matrix_from_stl(X_ref,X_stl);
@@ -101,8 +100,6 @@ public :
void check_result( void ){
// calculation check
- Interface::matrix_to_stl(C,resu_stl);
-
// STL_interface<typename Interface::real_type>::cholesky(X_stl,C_stl,_size);
//
// typename Interface::real_type error=
@@ -119,7 +116,6 @@ private :
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
- typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix X;
diff --git a/bench/btl/actions/action_ger.hh b/bench/btl/actions/action_ger.hh
new file mode 100644
index 000000000..dc766efc5
--- /dev/null
+++ b/bench/btl/actions/action_ger.hh
@@ -0,0 +1,128 @@
+
+// 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_GER
+#define ACTION_GER
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_ger {
+
+public :
+
+ // Ctor
+ BTL_DONT_INLINE Action_ger( int size ):_size(size)
+ {
+ MESSAGE("Action_ger Ctor");
+
+ // STL matrix and vector initialization
+ typename Interface::stl_matrix tmp;
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<pseudo_random>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+ }
+
+ // invalidate copy ctor
+ Action_ger( const Action_ger & )
+ {
+ INFOS("illegal call to Action_ger Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+ BTL_DONT_INLINE ~Action_ger( void ){
+ MESSAGE("Action_ger 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);
+
+ }
+
+ // action name
+ static inline std::string name( void )
+ {
+ return "ger_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size;
+ }
+
+ BTL_DONT_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);
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin ger");
+ Interface::ger(A,B,X,_size);
+ BTL_ASM_COMMENT("end ger");
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+ // calculation check
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::ger(A_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-3){
+ 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_partial_lu.hh b/bench/btl/actions/action_partial_lu.hh
new file mode 100644
index 000000000..837661027
--- /dev/null
+++ b/bench/btl/actions/action_partial_lu.hh
@@ -0,0 +1,125 @@
+//=====================================================
+// File : action_lu_decomp.hh
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+//=====================================================
+//
+// 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_PARTIAL_LU
+#define ACTION_PARTIAL_LU
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_partial_lu {
+
+public :
+
+ // Ctor
+
+ Action_partial_lu( int size ):_size(size)
+ {
+ MESSAGE("Action_partial_lu Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl,_size);
+ init_matrix<null_function>(C_stl,_size);
+
+ // make sure X is invertible
+ for (int i=0; i<_size; ++i)
+ X_stl[i][i] = X_stl[i][i] * 1e2 + 1;
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref,X_stl);
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::matrix_from_stl(C,C_stl);
+
+ _cost = 2.0*size*size*size/3.0 + size*size;
+ }
+
+ // invalidate copy ctor
+
+ Action_partial_lu( const Action_partial_lu & )
+ {
+ INFOS("illegal call to Action_partial_lu Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_partial_lu( void ){
+
+ MESSAGE("Action_partial_lu Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref,_size);
+ Interface::free_matrix(X,_size);
+ Interface::free_matrix(C,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "partial_lu_decomp_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::partial_lu_decomp(X,C,_size);
+ }
+
+ void check_result( void ){
+ // calculation check
+// Interface::matrix_to_stl(C,resu_stl);
+
+// STL_interface<typename Interface::real_type>::lu_decomp(X_stl,C_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/bench/btl/actions/action_symv.hh b/bench/btl/actions/action_symv.hh
index f520623a8..a32b9dfa0 100644
--- a/bench/btl/actions/action_symv.hh
+++ b/bench/btl/actions/action_symv.hh
@@ -40,18 +40,12 @@ public :
MESSAGE("Action_symv Ctor");
// STL matrix and vector initialization
-
- typename Interface::stl_matrix tmp;
- init_matrix<pseudo_random>(A_stl,_size);
- init_matrix<pseudo_random>(tmp,_size);
+ init_matrix_symm<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<null_function>(X_stl,_size);
init_vector<null_function>(resu_stl,_size);
- STL_interface<typename Interface::real_type>::ata_product(tmp,A_stl,_size);
-
// generic matrix and vector initialization
-
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
@@ -70,21 +64,13 @@ public :
}
// Dtor
-
BTL_DONT_INLINE ~Action_symv( void ){
-
- MESSAGE("Action_symv 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
@@ -113,9 +99,8 @@ public :
}
BTL_DONT_INLINE void check_result( void ){
-
+ if (_size>128) return;
// calculation check
-
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::symv(A_stl,B_stl,X_stl,_size);
diff --git a/bench/btl/actions/action_syr2.hh b/bench/btl/actions/action_syr2.hh
index d5ef07411..7c6712b13 100644
--- a/bench/btl/actions/action_syr2.hh
+++ b/bench/btl/actions/action_syr2.hh
@@ -37,32 +37,23 @@ public :
BTL_DONT_INLINE Action_syr2( int size ):_size(size)
{
- MESSAGE("Action_syr2 Ctor");
-
// STL matrix and vector initialization
-
typename Interface::stl_matrix tmp;
init_matrix<pseudo_random>(A_stl,_size);
- init_matrix<pseudo_random>(tmp,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<pseudo_random>(X_stl,_size);
init_vector<null_function>(resu_stl,_size);
- STL_interface<typename Interface::real_type>::ata_product(tmp,A_stl,_size);
-
// generic matrix and vector initialization
-
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(X,X_stl);
-
}
// invalidate copy ctor
-
Action_syr2( const Action_syr2 & )
{
INFOS("illegal call to Action_syr2 Copy Ctor");
@@ -70,21 +61,13 @@ public :
}
// Dtor
-
BTL_DONT_INLINE ~Action_syr2( void ){
-
- MESSAGE("Action_syr2 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
@@ -99,11 +82,9 @@ public :
}
BTL_DONT_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);
-
}
BTL_DONT_INLINE void calculate( void ) {
@@ -113,9 +94,7 @@ public :
}
BTL_DONT_INLINE void check_result( void ){
-
// calculation check
-return;
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::syr2(A_stl,B_stl,X_stl,_size);
diff --git a/bench/btl/actions/action_trisolve.hh b/bench/btl/actions/action_trisolve.hh
index 0d277eb77..94e41e072 100644
--- a/bench/btl/actions/action_trisolve.hh
+++ b/bench/btl/actions/action_trisolve.hh
@@ -102,7 +102,8 @@ public :
Interface::trisolve_lower(L,B,X,_size);
}
- void check_result( void ){
+ void check_result(){
+ if (_size>128) return;
// calculation check
Interface::vector_to_stl(X,resu_stl);
diff --git a/bench/btl/actions/basic_actions.hh b/bench/btl/actions/basic_actions.hh
index a23e58096..06a382be6 100644
--- a/bench/btl/actions/basic_actions.hh
+++ b/bench/btl/actions/basic_actions.hh
@@ -14,6 +14,7 @@
#include "action_symv.hh"
// #include "action_symm.hh"
#include "action_syr2.hh"
+#include "action_ger.hh"
// #include "action_lu_solve.hh"