Clang-format tests, examples, libraries, benchmarks, etc.

This commit is contained in:
Antonio Sánchez
2023-12-05 21:22:55 +00:00
committed by Rasmus Munk Larsen
parent 3252ecc7a4
commit 46e9cdb7fe
876 changed files with 33453 additions and 37795 deletions

View File

@@ -28,101 +28,80 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_aat_product {
public :
public:
// Ctor
Action_aat_product( int size ):_size(size)
{
Action_aat_product(int size) : _size(size) {
MESSAGE("Action_aat_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<pseudo_random>(A_stl, _size);
init_matrix<null_function>(X_stl, _size);
init_matrix<null_function>(resu_stl, _size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(A_ref, A_stl);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::matrix_from_stl(X, X_stl);
}
// invalidate copy ctor
Action_aat_product( const Action_aat_product & )
{
Action_aat_product(const Action_aat_product&) {
INFOS("illegal call to Action_aat_product Copy Ctor");
exit(0);
}
// Dtor
~Action_aat_product( void ){
~Action_aat_product(void) {
MESSAGE("Action_aat_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(A, _size);
Interface::free_matrix(X, _size);
Interface::free_matrix(A_ref, _size);
Interface::free_matrix(X_ref, _size);
}
// action name
static inline std::string name( void )
{
return "aat_"+Interface::name();
static inline std::string name(void) { return "aat_" + Interface::name(); }
double nb_op_base(void) { return double(_size) * double(_size) * double(_size); }
inline void initialize(void) {
Interface::copy_matrix(A_ref, A, _size);
Interface::copy_matrix(X_ref, X, _size);
}
double nb_op_base( void ){
return double(_size)*double(_size)*double(_size);
}
inline void calculate(void) { Interface::aat_product(A, X, _size); }
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::aat_product(A,X,_size);
}
void check_result( void ){
if (_size>128) return;
void check_result(void) {
if (_size > 128) return;
// calculation check
Interface::matrix_to_stl(X,resu_stl);
Interface::matrix_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::aat_product(A_stl,X_stl,_size);
STL_interface<typename Interface::real_type>::aat_product(A_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-6){
if (error > 1.e-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix resu_stl;
@@ -133,13 +112,7 @@ private :
typename Interface::gene_matrix A;
typename Interface::gene_matrix X;
int _size;
};
#endif

View File

@@ -28,101 +28,80 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_ata_product {
public :
public:
// Ctor
Action_ata_product( int size ):_size(size)
{
Action_ata_product(int size) : _size(size) {
MESSAGE("Action_ata_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<pseudo_random>(A_stl, _size);
init_matrix<null_function>(X_stl, _size);
init_matrix<null_function>(resu_stl, _size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(A_ref, A_stl);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::matrix_from_stl(X, X_stl);
}
// invalidate copy ctor
Action_ata_product( const Action_ata_product & )
{
Action_ata_product(const Action_ata_product&) {
INFOS("illegal call to Action_ata_product Copy Ctor");
exit(0);
}
// Dtor
~Action_ata_product( void ){
~Action_ata_product(void) {
MESSAGE("Action_ata_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(A, _size);
Interface::free_matrix(X, _size);
Interface::free_matrix(A_ref, _size);
Interface::free_matrix(X_ref, _size);
}
// action name
static inline std::string name( void )
{
return "ata_"+Interface::name();
static inline std::string name(void) { return "ata_" + Interface::name(); }
double nb_op_base(void) { return 2.0 * _size * _size * _size; }
inline void initialize(void) {
Interface::copy_matrix(A_ref, A, _size);
Interface::copy_matrix(X_ref, X, _size);
}
double nb_op_base( void ){
return 2.0*_size*_size*_size;
}
inline void calculate(void) { Interface::ata_product(A, X, _size); }
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::ata_product(A,X,_size);
}
void check_result( void ){
if (_size>128) return;
void check_result(void) {
if (_size > 128) return;
// calculation check
Interface::matrix_to_stl(X,resu_stl);
Interface::matrix_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::ata_product(A_stl,X_stl,_size);
STL_interface<typename Interface::real_type>::ata_product(A_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-6){
if (error > 1.e-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix resu_stl;
@@ -133,13 +112,7 @@ private :
typename Interface::gene_matrix A;
typename Interface::gene_matrix X;
int _size;
};
#endif

View File

@@ -28,87 +28,79 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_atv_product {
public :
Action_atv_product( int size ) : _size(size)
{
public:
Action_atv_product(int size) : _size(size) {
MESSAGE("Action_atv_product Ctor");
// STL matrix and vector initialization
init_matrix<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);
init_matrix<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);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A_ref, A_stl);
Interface::vector_from_stl(B_ref, B_stl);
Interface::vector_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X,X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::vector_from_stl(B, B_stl);
Interface::vector_from_stl(X, X_stl);
}
// invalidate copy ctor
Action_atv_product( const Action_atv_product & )
{
Action_atv_product(const Action_atv_product&) {
INFOS("illegal call to Action_atv_product Copy Ctor");
exit(1);
}
~Action_atv_product( void )
{
~Action_atv_product(void) {
MESSAGE("Action_atv_product Dtor");
Interface::free_matrix(A,_size);
Interface::free_matrix(A, _size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(A_ref, _size);
Interface::free_vector(B_ref);
Interface::free_vector(X_ref);
}
static inline std::string name() { return "atv_" + Interface::name(); }
double nb_op_base( void ) { return 2.0*_size*_size; }
double nb_op_base(void) { return 2.0 * _size * _size; }
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);
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_DONT_INLINE void calculate(void) {
BTL_ASM_COMMENT("begin atv");
Interface::atv_product(A,B,X,_size);
Interface::atv_product(A, B, X, _size);
BTL_ASM_COMMENT("end atv");
}
void check_result( void )
{
if (_size>128) return;
Interface::vector_to_stl(X,resu_stl);
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);
STL_interface<typename Interface::real_type>::atv_product(A_stl, B_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-6){
if (error > 1.e-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
@@ -122,13 +114,7 @@ private :
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif

View File

@@ -27,38 +27,34 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_axpby {
public :
public:
// Ctor
Action_axpby( int size ):_alpha(0.5),_beta(0.95),_size(size)
{
Action_axpby(int size) : _alpha(0.5), _beta(0.95), _size(size) {
MESSAGE("Action_axpby Ctor");
// STL vector initialization
init_vector<pseudo_random>(X_stl,_size);
init_vector<pseudo_random>(Y_stl,_size);
init_vector<null_function>(resu_stl,_size);
init_vector<pseudo_random>(X_stl, _size);
init_vector<pseudo_random>(Y_stl, _size);
init_vector<null_function>(resu_stl, _size);
// generic matrix and vector initialization
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(Y_ref,Y_stl);
Interface::vector_from_stl(X_ref, X_stl);
Interface::vector_from_stl(Y_ref, Y_stl);
Interface::vector_from_stl(X,X_stl);
Interface::vector_from_stl(Y,Y_stl);
Interface::vector_from_stl(X, X_stl);
Interface::vector_from_stl(Y, Y_stl);
}
// invalidate copy ctor
Action_axpby( const Action_axpby & )
{
Action_axpby(const Action_axpby&) {
INFOS("illegal call to Action_axpby Copy Ctor");
exit(1);
}
// Dtor
~Action_axpby( void ){
~Action_axpby(void) {
MESSAGE("Action_axpby Dtor");
// deallocation
@@ -70,44 +66,37 @@ public :
}
// action name
static inline std::string name( void )
{
return "axpby_"+Interface::name();
static inline std::string name(void) { return "axpby_" + Interface::name(); }
double nb_op_base(void) { return 3.0 * _size; }
inline void initialize(void) {
Interface::copy_vector(X_ref, X, _size);
Interface::copy_vector(Y_ref, Y, _size);
}
double nb_op_base( void ){
return 3.0*_size;
}
inline void initialize( void ){
Interface::copy_vector(X_ref,X,_size);
Interface::copy_vector(Y_ref,Y,_size);
}
inline void calculate( void ) {
inline void calculate(void) {
BTL_ASM_COMMENT("mybegin axpby");
Interface::axpby(_alpha,X,_beta,Y,_size);
Interface::axpby(_alpha, X, _beta, Y, _size);
BTL_ASM_COMMENT("myend axpby");
}
void check_result( void ){
if (_size>128) return;
void check_result(void) {
if (_size > 128) return;
// calculation check
Interface::vector_to_stl(Y,resu_stl);
Interface::vector_to_stl(Y, resu_stl);
STL_interface<typename Interface::real_type>::axpby(_alpha,X_stl,_beta,Y_stl,_size);
STL_interface<typename Interface::real_type>::axpby(_alpha, X_stl, _beta, Y_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(Y_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(Y_stl, resu_stl);
if (error>1.e-6){
if (error > 1.e-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(2);
}
}
private :
private:
typename Interface::stl_vector X_stl;
typename Interface::stl_vector Y_stl;
typename Interface::stl_vector resu_stl;

View File

@@ -28,46 +28,39 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_axpy {
public :
public:
// Ctor
Action_axpy( int size ):_coef(1.0),_size(size)
{
Action_axpy(int size) : _coef(1.0), _size(size) {
MESSAGE("Action_axpy Ctor");
// STL vector initialization
init_vector<pseudo_random>(X_stl,_size);
init_vector<pseudo_random>(Y_stl,_size);
init_vector<null_function>(resu_stl,_size);
init_vector<pseudo_random>(X_stl, _size);
init_vector<pseudo_random>(Y_stl, _size);
init_vector<null_function>(resu_stl, _size);
// generic matrix and vector initialization
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(Y_ref,Y_stl);
Interface::vector_from_stl(X,X_stl);
Interface::vector_from_stl(Y,Y_stl);
Interface::vector_from_stl(X_ref, X_stl);
Interface::vector_from_stl(Y_ref, Y_stl);
Interface::vector_from_stl(X, X_stl);
Interface::vector_from_stl(Y, Y_stl);
}
// invalidate copy ctor
Action_axpy( const Action_axpy & )
{
Action_axpy(const Action_axpy&) {
INFOS("illegal call to Action_axpy Copy Ctor");
exit(1);
}
// Dtor
~Action_axpy( void ){
~Action_axpy(void) {
MESSAGE("Action_axpy Dtor");
// deallocation
@@ -81,46 +74,38 @@ public :
// action name
static inline std::string name( void )
{
return "axpy_"+Interface::name();
static inline std::string name(void) { return "axpy_" + Interface::name(); }
double nb_op_base(void) { return 2.0 * _size; }
inline void initialize(void) {
Interface::copy_vector(X_ref, X, _size);
Interface::copy_vector(Y_ref, Y, _size);
}
double nb_op_base( void ){
return 2.0*_size;
}
inline void initialize( void ){
Interface::copy_vector(X_ref,X,_size);
Interface::copy_vector(Y_ref,Y,_size);
}
inline void calculate( void ) {
inline void calculate(void) {
BTL_ASM_COMMENT("mybegin axpy");
Interface::axpy(_coef,X,Y,_size);
Interface::axpy(_coef, X, Y, _size);
BTL_ASM_COMMENT("myend axpy");
}
void check_result( void ){
if (_size>128) return;
void check_result(void) {
if (_size > 128) return;
// calculation check
Interface::vector_to_stl(Y,resu_stl);
Interface::vector_to_stl(Y, resu_stl);
STL_interface<typename Interface::real_type>::axpy(_coef,X_stl,Y_stl,_size);
STL_interface<typename Interface::real_type>::axpy(_coef, X_stl, Y_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(Y_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(Y_stl, resu_stl);
if (error>1.e-6){
if (error > 1.e-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(0);
}
}
private :
private:
typename Interface::stl_vector X_stl;
typename Interface::stl_vector Y_stl;
typename Interface::stl_vector resu_stl;

View File

@@ -27,93 +27,75 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_cholesky {
public :
public:
// Ctor
Action_cholesky( int size ):_size(size)
{
Action_cholesky(int size) : _size(size) {
MESSAGE("Action_cholesky Ctor");
// STL mat/vec initialization
init_matrix_symm<pseudo_random>(X_stl,_size);
init_matrix<null_function>(C_stl,_size);
init_matrix_symm<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] = std::abs(X_stl[i][i]) * 1e2 + 100;
for (int i = 0; i < _size; ++i) X_stl[i][i] = std::abs(X_stl[i][i]) * 1e2 + 100;
// 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);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(X, X_stl);
Interface::matrix_from_stl(C, C_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
double r = std::max(_size - j -1,0);
_cost += 2*(r*j+r+j);
for (int j = 0; j < _size; ++j) {
double r = std::max(_size - j - 1, 0);
_cost += 2 * (r * j + r + j);
}
}
// invalidate copy ctor
Action_cholesky( const Action_cholesky & )
{
Action_cholesky(const Action_cholesky&) {
INFOS("illegal call to Action_cholesky Copy Ctor");
exit(1);
}
// Dtor
~Action_cholesky( void ){
~Action_cholesky(void) {
MESSAGE("Action_cholesky Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
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 "cholesky_"+Interface::name();
}
static inline std::string name(void) { return "cholesky_" + Interface::name(); }
double nb_op_base( void ){
return _cost;
}
double nb_op_base(void) { return _cost; }
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void initialize(void) { Interface::copy_matrix(X_ref, X, _size); }
inline void calculate( void ) {
Interface::cholesky(X,C,_size);
}
inline void calculate(void) { Interface::cholesky(X, C, _size); }
void check_result( void ){
void check_result(void) {
// calculation check
// STL_interface<typename Interface::real_type>::cholesky(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);
// }
// STL_interface<typename Interface::real_type>::cholesky(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 :
private:
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;

View File

@@ -23,91 +23,78 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_ger {
public :
public:
// Ctor
BTL_DONT_INLINE Action_ger( int size ):_size(size)
{
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);
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);
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 & )
{
Action_ger(const Action_ger&) {
INFOS("illegal call to Action_ger Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_ger( void ){
BTL_DONT_INLINE ~Action_ger(void) {
MESSAGE("Action_ger Dtor");
Interface::free_matrix(A,_size);
Interface::free_matrix(A, _size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
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();
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);
}
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_DONT_INLINE void calculate(void) {
BTL_ASM_COMMENT("#begin ger");
Interface::ger(A,B,X,_size);
Interface::ger(A, B, X, _size);
BTL_ASM_COMMENT("end ger");
}
BTL_DONT_INLINE void check_result( void ){
BTL_DONT_INLINE void check_result(void) {
// calculation check
Interface::vector_to_stl(X,resu_stl);
Interface::vector_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::ger(A_stl,B_stl,X_stl,_size);
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);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-3){
if (error > 1.e-3) {
INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// exit(0);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
@@ -124,5 +111,4 @@ private :
int _size;
};
#endif

View File

@@ -27,94 +27,77 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_hessenberg {
public :
public:
// Ctor
Action_hessenberg( int size ):_size(size)
{
Action_hessenberg(int size) : _size(size) {
MESSAGE("Action_hessenberg Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
init_matrix<pseudo_random>(X_stl, _size);
init_matrix<null_function>(C_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<null_function>(C_stl, _size);
init_matrix<null_function>(resu_stl, _size);
// 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);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(X, X_stl);
Interface::matrix_from_stl(C, C_stl);
_cost = 0;
for (int j=0; j<_size-2; ++j)
{
double r = std::max(0,_size-j-1);
double b = std::max(0,_size-j-2);
_cost += 6 + 3*b + r*r*4 + r*_size*4;
for (int j = 0; j < _size - 2; ++j) {
double r = std::max(0, _size - j - 1);
double b = std::max(0, _size - j - 2);
_cost += 6 + 3 * b + r * r * 4 + r * _size * 4;
}
}
// invalidate copy ctor
Action_hessenberg( const Action_hessenberg & )
{
Action_hessenberg(const Action_hessenberg&) {
INFOS("illegal call to Action_hessenberg Copy Ctor");
exit(1);
}
// Dtor
~Action_hessenberg( void ){
~Action_hessenberg(void) {
MESSAGE("Action_hessenberg Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
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 "hessenberg_"+Interface::name();
}
static inline std::string name(void) { return "hessenberg_" + Interface::name(); }
double nb_op_base( void ){
return _cost;
}
double nb_op_base(void) { return _cost; }
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void initialize(void) { Interface::copy_matrix(X_ref, X, _size); }
inline void calculate( void ) {
Interface::hessenberg(X,C,_size);
}
inline void calculate(void) { Interface::hessenberg(X, C, _size); }
void check_result( void ){
void check_result(void) {
// calculation check
Interface::matrix_to_stl(C,resu_stl);
// STL_interface<typename Interface::real_type>::hessenberg(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);
// }
Interface::matrix_to_stl(C, resu_stl);
// STL_interface<typename Interface::real_type>::hessenberg(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 :
private:
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::stl_matrix resu_stl;
@@ -127,97 +110,81 @@ private :
double _cost;
};
template<class Interface>
template <class Interface>
class Action_tridiagonalization {
public :
public:
// Ctor
Action_tridiagonalization( int size ):_size(size)
{
Action_tridiagonalization(int size) : _size(size) {
MESSAGE("Action_tridiagonalization Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
for(int i=0; i<_size; ++i)
{
for(int j=0; j<i; ++j)
X_stl[i][j] = X_stl[j][i];
init_matrix<pseudo_random>(X_stl, _size);
for (int i = 0; i < _size; ++i) {
for (int j = 0; j < i; ++j) X_stl[i][j] = X_stl[j][i];
}
init_matrix<null_function>(C_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<null_function>(C_stl, _size);
init_matrix<null_function>(resu_stl, _size);
// 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);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(X, X_stl);
Interface::matrix_from_stl(C, C_stl);
_cost = 0;
for (int j=0; j<_size-2; ++j)
{
double r = std::max(0,_size-j-1);
double b = std::max(0,_size-j-2);
_cost += 6. + 3.*b + r*r*8.;
for (int j = 0; j < _size - 2; ++j) {
double r = std::max(0, _size - j - 1);
double b = std::max(0, _size - j - 2);
_cost += 6. + 3. * b + r * r * 8.;
}
}
// invalidate copy ctor
Action_tridiagonalization( const Action_tridiagonalization & )
{
Action_tridiagonalization(const Action_tridiagonalization&) {
INFOS("illegal call to Action_tridiagonalization Copy Ctor");
exit(1);
}
// Dtor
~Action_tridiagonalization( void ){
~Action_tridiagonalization(void) {
MESSAGE("Action_tridiagonalization Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
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 "tridiagonalization_"+Interface::name(); }
static inline std::string name(void) { return "tridiagonalization_" + Interface::name(); }
double nb_op_base( void ){
return _cost;
}
double nb_op_base(void) { return _cost; }
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void initialize(void) { Interface::copy_matrix(X_ref, X, _size); }
inline void calculate( void ) {
Interface::tridiagonalization(X,C,_size);
}
inline void calculate(void) { Interface::tridiagonalization(X, C, _size); }
void check_result( void ){
void check_result(void) {
// calculation check
Interface::matrix_to_stl(C,resu_stl);
// STL_interface<typename Interface::real_type>::tridiagonalization(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);
// }
Interface::matrix_to_stl(C, resu_stl);
// STL_interface<typename Interface::real_type>::tridiagonalization(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 :
private:
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::stl_matrix resu_stl;

View File

@@ -27,88 +27,72 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_lu_decomp {
public :
public:
// Ctor
Action_lu_decomp( int size ):_size(size)
{
Action_lu_decomp(int size) : _size(size) {
MESSAGE("Action_lu_decomp Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
init_matrix<pseudo_random>(X_stl, _size);
init_matrix<null_function>(C_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<null_function>(C_stl, _size);
init_matrix<null_function>(resu_stl, _size);
// 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);
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;
_cost = 2.0 * size * size * size / 3.0 + size * size;
}
// invalidate copy ctor
Action_lu_decomp( const Action_lu_decomp & )
{
Action_lu_decomp(const Action_lu_decomp&) {
INFOS("illegal call to Action_lu_decomp Copy Ctor");
exit(1);
}
// Dtor
~Action_lu_decomp( void ){
~Action_lu_decomp(void) {
MESSAGE("Action_lu_decomp Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
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 "complete_lu_decomp_"+Interface::name();
}
static inline std::string name(void) { return "complete_lu_decomp_" + Interface::name(); }
double nb_op_base( void ){
return _cost;
}
double nb_op_base(void) { return _cost; }
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void initialize(void) { Interface::copy_matrix(X_ref, X, _size); }
inline void calculate( void ) {
Interface::lu_decomp(X,C,_size);
}
inline void calculate(void) { Interface::lu_decomp(X, C, _size); }
void check_result( void ){
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);
// }
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 :
private:
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::stl_matrix resu_stl;

View File

@@ -1,14 +1,14 @@
//=====================================================
// File : action_lu_solve.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 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
@@ -16,7 +16,7 @@
// 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_LU_SOLVE
#define ACTION_LU_SOLVE
#include "utilities.h"
@@ -28,33 +28,25 @@
using namespace std;
template<class Interface>
class Action_lu_solve
{
template <class Interface>
class Action_lu_solve {
public:
static inline std::string name(void) { return "lu_solve_" + Interface::name(); }
public :
static inline std::string name( void )
{
return "lu_solve_"+Interface::name();
}
static double nb_op_base(int size){
return 2.0*size*size*size/3.0; // questionable but not really important
static double nb_op_base(int size) {
return 2.0 * size * size * size / 3.0; // questionable but not really important
}
static double calculate( int nb_calc, int size ) {
static double calculate(int nb_calc, int size) {
// STL matrix and vector initialization
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
init_matrix<pseudo_random>(A_stl,size);
init_vector<pseudo_random>(B_stl,size);
init_vector<null_function>(X_stl,size);
init_matrix<pseudo_random>(A_stl, size);
init_vector<pseudo_random>(B_stl, size);
init_vector<null_function>(X_stl, size);
// generic matrix and vector initialization
@@ -62,18 +54,18 @@ public :
typename Interface::gene_vector B;
typename Interface::gene_vector X;
typename Interface::gene_matrix LU;
typename Interface::gene_matrix LU;
Interface::matrix_from_stl(A, A_stl);
Interface::vector_from_stl(B, B_stl);
Interface::vector_from_stl(X, X_stl);
Interface::matrix_from_stl(LU, A_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X,X_stl);
Interface::matrix_from_stl(LU,A_stl);
// local variable :
typename Interface::Pivot_Vector pivot; // pivot vector
Interface::new_Pivot_Vector(pivot,size);
typename Interface::Pivot_Vector pivot; // pivot vector
Interface::new_Pivot_Vector(pivot, size);
// timer utilities
Portable_Timer chronos;
@@ -81,56 +73,48 @@ public :
// time measurement
chronos.start();
for (int ii=0;ii<nb_calc;ii++){
for (int ii = 0; ii < nb_calc; ii++) {
// LU factorization
Interface::copy_matrix(A,LU,size);
Interface::LU_factor(LU,pivot,size);
Interface::copy_matrix(A, LU, size);
Interface::LU_factor(LU, pivot, size);
// LU solve
Interface::LU_solve(LU,pivot,B,X,size);
Interface::LU_solve(LU, pivot, B, X, size);
}
// Time stop
chronos.stop();
double time=chronos.user_time();
double time = chronos.user_time();
// check result :
typename Interface::stl_vector B_new_stl(size);
Interface::vector_to_stl(X,X_stl);
Interface::vector_to_stl(X, X_stl);
STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl,X_stl,B_new_stl,size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(B_stl,B_new_stl);
if (error>1.e-5){
STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl, X_stl, B_new_stl, size);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(B_stl, B_new_stl);
if (error > 1.e-5) {
INFOS("WRONG CALCULATION...residual=" << error);
STL_interface<typename Interface::real_type>::display_vector(B_stl);
STL_interface<typename Interface::real_type>::display_vector(B_new_stl);
exit(0);
}
// deallocation and return time
Interface::free_matrix(A,size);
Interface::free_matrix(A, size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_Pivot_Vector(pivot);
return time;
}
};
#endif

View File

@@ -28,103 +28,83 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_matrix_matrix_product {
public :
public:
// Ctor
Action_matrix_matrix_product( int size ):_size(size)
{
Action_matrix_matrix_product(int size) : _size(size) {
MESSAGE("Action_matrix_matrix_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<pseudo_random>(B_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<pseudo_random>(A_stl, _size);
init_matrix<pseudo_random>(B_stl, _size);
init_matrix<null_function>(X_stl, _size);
init_matrix<null_function>(resu_stl, _size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(A_ref, A_stl);
Interface::matrix_from_stl(B_ref, B_stl);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::matrix_from_stl(B, B_stl);
Interface::matrix_from_stl(X, X_stl);
}
// invalidate copy ctor
Action_matrix_matrix_product( const Action_matrix_matrix_product & )
{
Action_matrix_matrix_product(const Action_matrix_matrix_product&) {
INFOS("illegal call to Action_matrix_matrix_product Copy Ctor");
exit(0);
}
// Dtor
~Action_matrix_matrix_product( void ){
~Action_matrix_matrix_product(void) {
MESSAGE("Action_matrix_matrix_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(B,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(B_ref,_size);
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(A, _size);
Interface::free_matrix(B, _size);
Interface::free_matrix(X, _size);
Interface::free_matrix(A_ref, _size);
Interface::free_matrix(B_ref, _size);
Interface::free_matrix(X_ref, _size);
}
// action name
static inline std::string name( void )
{
return "matrix_matrix_"+Interface::name();
static inline std::string name(void) { return "matrix_matrix_" + Interface::name(); }
double nb_op_base(void) { return 2.0 * _size * _size * _size; }
inline void initialize(void) {
Interface::copy_matrix(A_ref, A, _size);
Interface::copy_matrix(B_ref, B, _size);
Interface::copy_matrix(X_ref, X, _size);
}
double nb_op_base( void ){
return 2.0*_size*_size*_size;
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(B_ref,B,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::matrix_matrix_product(A,B,X,_size);
}
void check_result( void ){
inline void calculate(void) { Interface::matrix_matrix_product(A, B, X, _size); }
void check_result(void) {
// calculation check
if (_size<200)
{
Interface::matrix_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::matrix_matrix_product(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-6){
if (_size < 200) {
Interface::matrix_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::matrix_matrix_product(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-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
@@ -138,13 +118,7 @@ private :
typename Interface::gene_matrix B;
typename Interface::gene_matrix X;
int _size;
};
#endif

View File

@@ -29,31 +29,23 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_matrix_matrix_product_bis {
public:
static inline std::string name(void) { return "matrix_matrix_" + Interface::name(); }
public :
static inline std::string name( void )
{
return "matrix_matrix_"+Interface::name();
}
static double nb_op_base(int size){
return 2.0*size*size*size;
}
static double calculate( int nb_calc, int size ) {
static double nb_op_base(int size) { return 2.0 * size * size * size; }
static double calculate(int nb_calc, int size) {
// STL matrix and vector initialization
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
init_matrix<pseudo_random>(A_stl,size);
init_matrix<pseudo_random>(B_stl,size);
init_matrix<null_function>(X_stl,size);
init_matrix<pseudo_random>(A_stl, size);
init_matrix<pseudo_random>(B_stl, size);
init_matrix<null_function>(X_stl, size);
// generic matrix and vector initialization
@@ -65,15 +57,13 @@ public :
typename Interface::gene_matrix B;
typename Interface::gene_matrix X;
Interface::matrix_from_stl(A_ref, A_stl);
Interface::matrix_from_stl(B_ref, B_stl);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::matrix_from_stl(B, B_stl);
Interface::matrix_from_stl(X, X_stl);
// STL_timer utilities
@@ -84,15 +74,12 @@ public :
chronos.start_baseline(nb_calc);
do {
Interface::copy_matrix(A_ref,A,size);
Interface::copy_matrix(B_ref,B,size);
Interface::copy_matrix(X_ref,X,size);
Interface::copy_matrix(A_ref, A, size);
Interface::copy_matrix(B_ref, B, size);
Interface::copy_matrix(X_ref, X, size);
// Interface::matrix_matrix_product(A,B,X,size); This line must be commented !!!!
}
while(chronos.check());
} while (chronos.check());
chronos.report(true);
@@ -101,52 +88,44 @@ public :
chronos.start(nb_calc);
do {
Interface::copy_matrix(A_ref, A, size);
Interface::copy_matrix(B_ref, B, size);
Interface::copy_matrix(X_ref, X, size);
Interface::copy_matrix(A_ref,A,size);
Interface::copy_matrix(B_ref,B,size);
Interface::copy_matrix(X_ref,X,size);
Interface::matrix_matrix_product(A,B,X,size); // here it is not commented !!!!
}
while(chronos.check());
Interface::matrix_matrix_product(A, B, X, size); // here it is not commented !!!!
} while (chronos.check());
chronos.report(true);
double time=chronos.calculated_time/2000.0;
double time = chronos.calculated_time / 2000.0;
// calculation check
typename Interface::stl_matrix resu_stl(size);
Interface::matrix_to_stl(X,resu_stl);
Interface::matrix_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,size);
STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl, B_stl, X_stl, size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-6){
if (error > 1.e-6) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
// deallocation and return time
Interface::free_matrix(A,size);
Interface::free_matrix(B,size);
Interface::free_matrix(X,size);
Interface::free_matrix(A, size);
Interface::free_matrix(B, size);
Interface::free_matrix(X, size);
Interface::free_matrix(A_ref,size);
Interface::free_matrix(B_ref,size);
Interface::free_matrix(X_ref,size);
Interface::free_matrix(A_ref, size);
Interface::free_matrix(B_ref, size);
Interface::free_matrix(X_ref, size);
return time;
}
};
#endif

View File

@@ -28,106 +28,88 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_matrix_vector_product {
public :
public:
// Ctor
BTL_DONT_INLINE Action_matrix_vector_product( int size ):_size(size)
{
BTL_DONT_INLINE Action_matrix_vector_product(int size) : _size(size) {
MESSAGE("Action_matrix_vector_product Ctor");
// STL matrix and vector initialization
init_matrix<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);
init_matrix<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);
// 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);
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_matrix_vector_product( const Action_matrix_vector_product & )
{
Action_matrix_vector_product(const Action_matrix_vector_product&) {
INFOS("illegal call to Action_matrix_vector_product Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_matrix_vector_product( void ){
BTL_DONT_INLINE ~Action_matrix_vector_product(void) {
MESSAGE("Action_matrix_vector_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(A, _size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
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 "matrix_vector_" + Interface::name();
static inline std::string name(void) { return "matrix_vector_" + 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);
}
double nb_op_base( void ){
return 2.0*_size*_size;
BTL_DONT_INLINE void calculate(void) {
BTL_ASM_COMMENT("#begin matrix_vector_product");
Interface::matrix_vector_product(A, B, X, _size);
BTL_ASM_COMMENT("end matrix_vector_product");
}
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 matrix_vector_product");
Interface::matrix_vector_product(A,B,X,_size);
BTL_ASM_COMMENT("end matrix_vector_product");
}
BTL_DONT_INLINE void check_result( void ){
BTL_DONT_INLINE void check_result(void) {
// calculation check
Interface::vector_to_stl(X,resu_stl);
Interface::vector_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl,B_stl,X_stl,_size);
STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl, B_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-5){
if (error > 1.e-5) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(0);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
@@ -141,13 +123,7 @@ private :
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif

View File

@@ -27,90 +27,73 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_partial_lu {
public :
public:
// Ctor
Action_partial_lu( int size ):_size(size)
{
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);
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;
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);
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;
_cost = 2.0 * size * size * size / 3.0 + size * size;
}
// invalidate copy ctor
Action_partial_lu( const Action_partial_lu & )
{
Action_partial_lu(const Action_partial_lu&) {
INFOS("illegal call to Action_partial_lu Copy Ctor");
exit(1);
}
// Dtor
~Action_partial_lu( void ){
~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);
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();
}
static inline std::string name(void) { return "partial_lu_decomp_" + Interface::name(); }
double nb_op_base( void ){
return _cost;
}
double nb_op_base(void) { return _cost; }
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void initialize(void) { Interface::copy_matrix(X_ref, X, _size); }
inline void calculate( void ) {
Interface::partial_lu_decomp(X,C,_size);
}
inline void calculate(void) { Interface::partial_lu_decomp(X, C, _size); }
void check_result( void ){
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);
// }
// 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 :
private:
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;

View File

@@ -23,37 +23,33 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_rot {
public :
public:
// Ctor
BTL_DONT_INLINE Action_rot( int size ):_size(size)
{
BTL_DONT_INLINE Action_rot(int size) : _size(size) {
MESSAGE("Action_rot Ctor");
// STL matrix and vector initialization
typename Interface::stl_matrix tmp;
init_vector<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<pseudo_random>(A_stl, _size);
init_vector<pseudo_random>(B_stl, _size);
// generic matrix and vector initialization
Interface::vector_from_stl(A_ref,A_stl);
Interface::vector_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(A_ref, A_stl);
Interface::vector_from_stl(A, A_stl);
Interface::vector_from_stl(B_ref, B_stl);
Interface::vector_from_stl(B, B_stl);
}
// invalidate copy ctor
Action_rot( const Action_rot & )
{
Action_rot(const Action_rot&) {
INFOS("illegal call to Action_rot Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_rot( void ){
BTL_DONT_INLINE ~Action_rot(void) {
MESSAGE("Action_rot Dtor");
Interface::free_vector(A);
Interface::free_vector(B);
@@ -62,44 +58,37 @@ public :
}
// action name
static inline std::string name( void )
{
return "rot_" + Interface::name();
static inline std::string name(void) { return "rot_" + Interface::name(); }
double nb_op_base(void) { return 6.0 * _size; }
BTL_DONT_INLINE void initialize(void) {
Interface::copy_vector(A_ref, A, _size);
Interface::copy_vector(B_ref, B, _size);
}
double nb_op_base( void ){
return 6.0*_size;
}
BTL_DONT_INLINE void initialize( void ){
Interface::copy_vector(A_ref,A,_size);
Interface::copy_vector(B_ref,B,_size);
}
BTL_DONT_INLINE void calculate( void ) {
BTL_DONT_INLINE void calculate(void) {
BTL_ASM_COMMENT("#begin rot");
Interface::rot(A,B,0.5,0.6,_size);
Interface::rot(A, B, 0.5, 0.6, _size);
BTL_ASM_COMMENT("end rot");
}
BTL_DONT_INLINE void check_result( void ){
BTL_DONT_INLINE void check_result(void) {
// calculation check
// Interface::vector_to_stl(X,resu_stl);
// Interface::vector_to_stl(X,resu_stl);
// STL_interface<typename Interface::real_type>::rot(A_stl,B_stl,X_stl,_size);
// STL_interface<typename Interface::real_type>::rot(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);
// }
// 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 :
private:
typename Interface::stl_vector A_stl;
typename Interface::stl_vector B_stl;
@@ -112,5 +101,4 @@ private :
int _size;
};
#endif

View File

@@ -28,95 +28,80 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_symv {
public :
public:
// Ctor
BTL_DONT_INLINE Action_symv( int size ):_size(size)
{
BTL_DONT_INLINE Action_symv(int size) : _size(size) {
MESSAGE("Action_symv Ctor");
// STL matrix and vector initialization
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);
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);
// 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);
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_symv( const Action_symv & )
{
Action_symv(const Action_symv&) {
INFOS("illegal call to Action_symv Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_symv( void ){
Interface::free_matrix(A,_size);
BTL_DONT_INLINE ~Action_symv(void) {
Interface::free_matrix(A, _size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
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 "symv_" + Interface::name();
static inline std::string name(void) { return "symv_" + 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);
}
double nb_op_base( void ){
return 2.0*_size*_size;
BTL_DONT_INLINE void calculate(void) {
BTL_ASM_COMMENT("#begin symv");
Interface::symv(A, B, X, _size);
BTL_ASM_COMMENT("end symv");
}
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 symv");
Interface::symv(A,B,X,_size);
BTL_ASM_COMMENT("end symv");
}
BTL_DONT_INLINE void check_result( void ){
if (_size>128) return;
BTL_DONT_INLINE void check_result(void) {
if (_size > 128) return;
// calculation check
Interface::vector_to_stl(X,resu_stl);
Interface::vector_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::symv(A_stl,B_stl,X_stl,_size);
STL_interface<typename Interface::real_type>::symv(A_stl, B_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-5){
if (error > 1.e-5) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(0);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
@@ -130,10 +115,7 @@ private :
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif

View File

@@ -28,89 +28,77 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_syr2 {
public :
public:
// Ctor
BTL_DONT_INLINE Action_syr2( int size ):_size(size)
{
BTL_DONT_INLINE Action_syr2(int size) : _size(size) {
// 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);
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);
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 & )
{
Action_syr2(const Action_syr2&) {
INFOS("illegal call to Action_syr2 Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_syr2( void ){
Interface::free_matrix(A,_size);
BTL_DONT_INLINE ~Action_syr2(void) {
Interface::free_matrix(A, _size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
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 "syr2_" + Interface::name();
static inline std::string name(void) { return "syr2_" + 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);
}
double nb_op_base( void ){
return 2.0*_size*_size;
BTL_DONT_INLINE void calculate(void) {
BTL_ASM_COMMENT("#begin syr2");
Interface::syr2(A, B, X, _size);
BTL_ASM_COMMENT("end syr2");
}
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 syr2");
Interface::syr2(A,B,X,_size);
BTL_ASM_COMMENT("end syr2");
}
BTL_DONT_INLINE void check_result( void ){
BTL_DONT_INLINE void check_result(void) {
// calculation check
Interface::vector_to_stl(X,resu_stl);
Interface::vector_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::syr2(A_stl,B_stl,X_stl,_size);
STL_interface<typename Interface::real_type>::syr2(A_stl, B_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-3){
if (error > 1.e-3) {
INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// exit(0);
}
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
@@ -124,10 +112,7 @@ private :
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif

View File

@@ -27,100 +27,82 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_trisolve {
public :
public:
// Ctor
Action_trisolve( int size ):_size(size)
{
Action_trisolve(int size) : _size(size) {
MESSAGE("Action_trisolve Ctor");
// STL vector initialization
init_matrix<pseudo_random>(L_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<null_function>(X_stl,_size);
for (int j=0; j<_size; ++j)
{
for (int i=0; i<j; ++i)
L_stl[j][i] = 0;
init_matrix<pseudo_random>(L_stl, _size);
init_vector<pseudo_random>(B_stl, _size);
init_vector<null_function>(X_stl, _size);
for (int j = 0; j < _size; ++j) {
for (int i = 0; i < j; ++i) L_stl[j][i] = 0;
L_stl[j][j] += 3;
}
init_vector<null_function>(resu_stl,_size);
init_vector<null_function>(resu_stl, _size);
// generic matrix and vector initialization
Interface::matrix_from_stl(L,L_stl);
Interface::vector_from_stl(X,X_stl);
Interface::vector_from_stl(B,B_stl);
Interface::matrix_from_stl(L, L_stl);
Interface::vector_from_stl(X, X_stl);
Interface::vector_from_stl(B, B_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
_cost += 2*j + 1;
for (int j = 0; j < _size; ++j) {
_cost += 2 * j + 1;
}
}
// invalidate copy ctor
Action_trisolve( const Action_trisolve & )
{
Action_trisolve(const Action_trisolve&) {
INFOS("illegal call to Action_trisolve Copy Ctor");
exit(1);
}
// Dtor
~Action_trisolve( void ){
~Action_trisolve(void) {
MESSAGE("Action_trisolve Dtor");
// deallocation
Interface::free_matrix(L,_size);
Interface::free_matrix(L, _size);
Interface::free_vector(B);
Interface::free_vector(X);
}
// action name
static inline std::string name( void )
{
return "trisolve_vector_"+Interface::name();
static inline std::string name(void) { return "trisolve_vector_" + Interface::name(); }
double nb_op_base(void) { return _cost; }
inline void initialize(void) {
// Interface::copy_vector(X_ref,X,_size);
}
double nb_op_base( void ){
return _cost;
}
inline void calculate(void) { Interface::trisolve_lower(L, B, X, _size); }
inline void initialize( void ){
//Interface::copy_vector(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::trisolve_lower(L,B,X,_size);
}
void check_result(){
if (_size>128) return;
void check_result() {
if (_size > 128) return;
// calculation check
Interface::vector_to_stl(X,resu_stl);
Interface::vector_to_stl(X, resu_stl);
STL_interface<typename Interface::real_type>::trisolve_lower(L_stl,B_stl,X_stl,_size);
STL_interface<typename Interface::real_type>::trisolve_lower(L_stl, B_stl, X_stl, _size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(X_stl, resu_stl);
if (error>1.e-4){
if (error > 1.e-4) {
INFOS("WRONG CALCULATION...residual=" << error);
exit(2);
} //else INFOS("CALCULATION OK...residual=" << error);
} // else INFOS("CALCULATION OK...residual=" << error);
}
private :
private:
typename Interface::stl_matrix L_stl;
typename Interface::stl_vector X_stl;
typename Interface::stl_vector B_stl;

View File

@@ -28,118 +28,97 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_trisolve_matrix {
public :
public:
// Ctor
Action_trisolve_matrix( int size ):_size(size)
{
Action_trisolve_matrix(int size) : _size(size) {
MESSAGE("Action_trisolve_matrix Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<pseudo_random>(B_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<pseudo_random>(A_stl, _size);
init_matrix<pseudo_random>(B_stl, _size);
init_matrix<null_function>(X_stl, _size);
init_matrix<null_function>(resu_stl, _size);
for (int j=0; j<_size; ++j)
{
for (int i=0; i<j; ++i)
A_stl[j][i] = 0;
for (int j = 0; j < _size; ++j) {
for (int i = 0; i < j; ++i) A_stl[j][i] = 0;
A_stl[j][j] += 3;
}
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A_ref, A_stl);
Interface::matrix_from_stl(B_ref, B_stl);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::matrix_from_stl(B, B_stl);
Interface::matrix_from_stl(X, X_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
_cost += 2*j + 1;
for (int j = 0; j < _size; ++j) {
_cost += 2 * j + 1;
}
_cost *= _size;
}
// invalidate copy ctor
Action_trisolve_matrix( const Action_trisolve_matrix & )
{
Action_trisolve_matrix(const Action_trisolve_matrix&) {
INFOS("illegal call to Action_trisolve_matrix Copy Ctor");
exit(0);
}
// Dtor
~Action_trisolve_matrix( void ){
~Action_trisolve_matrix(void) {
MESSAGE("Action_trisolve_matrix Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(B,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(B_ref,_size);
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(A, _size);
Interface::free_matrix(B, _size);
Interface::free_matrix(X, _size);
Interface::free_matrix(A_ref, _size);
Interface::free_matrix(B_ref, _size);
Interface::free_matrix(X_ref, _size);
}
// action name
static inline std::string name( void )
{
return "trisolve_matrix_"+Interface::name();
static inline std::string name(void) { return "trisolve_matrix_" + Interface::name(); }
double nb_op_base(void) { return _cost; }
inline void initialize(void) {
Interface::copy_matrix(A_ref, A, _size);
Interface::copy_matrix(B_ref, B, _size);
Interface::copy_matrix(X_ref, X, _size);
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(B_ref,B,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::trisolve_lower_matrix(A,B,X,_size);
}
void check_result( void ){
inline void calculate(void) { Interface::trisolve_lower_matrix(A, B, X, _size); }
void check_result(void) {
// calculation check
// Interface::matrix_to_stl(X,resu_stl);
//
// STL_interface<typename Interface::real_type>::matrix_matrix_product(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-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// // exit(1);
// }
// Interface::matrix_to_stl(X,resu_stl);
//
// STL_interface<typename Interface::real_type>::matrix_matrix_product(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-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// // exit(1);
// }
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
@@ -155,11 +134,6 @@ private :
int _size;
double _cost;
};
#endif

View File

@@ -28,118 +28,97 @@
using namespace std;
template<class Interface>
template <class Interface>
class Action_trmm {
public :
public:
// Ctor
Action_trmm( int size ):_size(size)
{
Action_trmm(int size) : _size(size) {
MESSAGE("Action_trmm Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<pseudo_random>(B_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
init_matrix<pseudo_random>(A_stl, _size);
init_matrix<pseudo_random>(B_stl, _size);
init_matrix<null_function>(X_stl, _size);
init_matrix<null_function>(resu_stl, _size);
for (int j=0; j<_size; ++j)
{
for (int i=0; i<j; ++i)
A_stl[j][i] = 0;
for (int j = 0; j < _size; ++j) {
for (int i = 0; i < j; ++i) A_stl[j][i] = 0;
A_stl[j][j] += 3;
}
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A_ref, A_stl);
Interface::matrix_from_stl(B_ref, B_stl);
Interface::matrix_from_stl(X_ref, X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(A, A_stl);
Interface::matrix_from_stl(B, B_stl);
Interface::matrix_from_stl(X, X_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
_cost += 2*j + 1;
for (int j = 0; j < _size; ++j) {
_cost += 2 * j + 1;
}
_cost *= _size;
}
// invalidate copy ctor
Action_trmm( const Action_trmm & )
{
Action_trmm(const Action_trmm&) {
INFOS("illegal call to Action_trmm Copy Ctor");
exit(0);
}
// Dtor
~Action_trmm( void ){
~Action_trmm(void) {
MESSAGE("Action_trmm Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(B,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(B_ref,_size);
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(A, _size);
Interface::free_matrix(B, _size);
Interface::free_matrix(X, _size);
Interface::free_matrix(A_ref, _size);
Interface::free_matrix(B_ref, _size);
Interface::free_matrix(X_ref, _size);
}
// action name
static inline std::string name( void )
{
return "trmm_"+Interface::name();
static inline std::string name(void) { return "trmm_" + Interface::name(); }
double nb_op_base(void) { return _cost; }
inline void initialize(void) {
Interface::copy_matrix(A_ref, A, _size);
Interface::copy_matrix(B_ref, B, _size);
Interface::copy_matrix(X_ref, X, _size);
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(B_ref,B,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::trmm(A,B,X,_size);
}
void check_result( void ){
inline void calculate(void) { Interface::trmm(A, B, X, _size); }
void check_result(void) {
// calculation check
// Interface::matrix_to_stl(X,resu_stl);
//
// STL_interface<typename Interface::real_type>::matrix_matrix_product(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-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// // exit(1);
// }
// Interface::matrix_to_stl(X,resu_stl);
//
// STL_interface<typename Interface::real_type>::matrix_matrix_product(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-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// // exit(1);
// }
}
private :
private:
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
@@ -155,11 +134,6 @@ private :
int _size;
double _cost;
};
#endif

View File

@@ -18,4 +18,3 @@
#include "action_rot.hh"
// #include "action_lu_solve.hh"