Commit 8879b360 authored by MIJIEUX Thomas's avatar MIJIEUX Thomas

Add type traits and static assert to detect invalid combination

parent 053c328e
......@@ -64,7 +64,8 @@ public:
* \return Total Number of Matrix vector product done
* (cumulated size of the spanned Krylov Spaces)
*/
template< template<class> class ARNOLDI_HESS, class Matrix, class Block >
template< template<class> class ARNOLDI_HESS,
class Matrix, class Block >
int solve_block( Matrix &A, Block &B, Block &X,
const int maxMVP, const int max_krylov_space_size,
const std::vector<P> &epsilon,
......
......@@ -9,7 +9,7 @@ template<template<class> class HESSENBERG, class S> class Arnoldi_IB;
#include "fabulous/data/BlockWP.hpp"
#include "fabulous/utils/Utils.hpp"
#include "fabulous/utils/Logger.hpp"
#include "fabulous/utils/ClassCompatibility.hpp"
#include "fabulous/utils/TypeInfo.hpp"
namespace fabulous {
......@@ -20,7 +20,7 @@ namespace fabulous {
*
* \warning This class does NOT support DeflatedRestarting (not implemented)
*/
template <template<class> class HESSENBERG, class S> class Arnoldi_IB
template < template<class> class HESSENBERG, class S > class Arnoldi_IB
{
static_assert(
arnoldiXhessenberg<fabulous::Arnoldi_IB, HESSENBERG>::value,
......@@ -327,8 +327,8 @@ private:
public:
template<class Restarter>
Arnoldi_IB(Logger<P> &logger, Restarter &restarter,
template<template <class> class Restarter>
Arnoldi_IB(Logger<P> &logger, Restarter<S> &restarter,
int dim, int nbRHS, int max_krylov_space_size):
_logger(logger),
L{max_krylov_space_size+1, nbRHS},
......@@ -345,6 +345,10 @@ public:
_IB_happened{false},
_cold_restart{false}
{
static_assert(
hessenbergXrestarter<HESSENBERG, Restarter>::value,
"The Hessenberg used is not compatible with the kind of restarting selected"
);
}
/**
......@@ -368,7 +372,7 @@ public:
bool run( Matrix &A, Block &X, Block &B,
const int max_krylov_space_size,
const std::vector<P> &epsilon,
Restarter &,
Restarter&,
OrthoScheme ortho_scheme,
OrthoType ortho_type )
{
......
......@@ -9,7 +9,7 @@ template<template<class> class HESSENBERG, class S > class Arnoldi;
#include "fabulous/data/Block.hpp"
#include "fabulous/utils/Utils.hpp"
#include "fabulous/utils/Logger.hpp"
#include "fabulous/utils/ClassCompatibility.hpp"
#include "fabulous/utils/TypeInfo.hpp"
#include "fabulous/restart/DeflatedRestart.hpp"
#include "fabulous/orthogonalization/Arnoldi_Ortho.hpp"
......@@ -152,8 +152,8 @@ private:
}
public:
template<class Restarter>
Arnoldi(Logger<P> &logger, Restarter &restarter,
template<template <class> class Restarter>
Arnoldi(Logger<P> &logger, Restarter<S> &restarter,
int dim, int nbRHS, int max_krylov_space_size):
_logger(logger),
_hess{max_krylov_space_size, nbRHS},
......@@ -166,6 +166,10 @@ public:
_iteration_count{0},
_cold_restart{false}
{
static_assert(
hessenbergXrestarter<HESSENBERG, Restarter>::value,
"The Hessenberg used is not compatible with the kind of restarting selected"
);
}
/**
......
#ifndef FABULOUS_LAPACK_INTERFACE_HPP
#define FABULOUS_LAPACK_INTERFACE_HPP
#include <iostream>
#include <cstring>
#include <complex>
#include <cassert>
#include <type_traits>
#include <vector>
namespace fabulous {
......@@ -14,8 +10,6 @@ struct LapackKernI;
#include "fabulous/utils/Arithmetic.hpp"
#include "fabulous/utils/Error.hpp"
#include "fabulous/ext/cblas.h"
#include "fabulous/ext/lapacke.h"
namespace fabulous {
......@@ -250,21 +244,19 @@ struct LapackKernI
}; // end class LapackKernI
}; // namespace fabulous
#define FABULOUS_LAPACK_INTERFACE_INC__
#include "LapackInterface_cblas.hpp"
#include "./LapackInterface_cblas.hpp"
#ifdef FABULOUS_LAPACKE_NANCHECK
# include "LapackInterface_nancheck.hpp"
# include "./LapackInterface_nancheck.hpp"
#else
# include "LapackInterface_work.hpp"
# include "./LapackInterface_work.hpp"
#endif
#undef FABULOUS_LAPACK_INTERFACE_INC__
}; // namespace fabulous
#endif // FABULOUS_LAPACK_INTERFACE_HPP
#ifndef FABULOUS_LAPACK_INTERFACE_CBLAS_HPP
#define FABULOUS_LAPACK_INTERFACE_CBLAS_HPP
#ifndef FABULOUS_LAPACK_INTERFACE_INC__
# error "Do not include this header directly, use LapackInterface.hpp instead"
#endif
#include "./LapackInterface.hpp"
#include "fabulous/ext/cblas.h"
/************* T-GEMM ********************/
namespace fabulous {
template<> //float
inline void LapackKernI::Tgemm(int m, int n, int k,
const float *A, int lda,
......@@ -26,7 +34,7 @@ inline void LapackKernI::Tgemm(int m, int n, int k,
m, n, k, alpha, A, lda, B, ldb, beta, C, ldc);
}
template<> //Cmplx Float
template<> //Complex Float
inline void LapackKernI::Tgemm(int m, int n, int k,
const std::complex<float> *A, int lda,
const std::complex<float> *B, int ldb,
......@@ -38,7 +46,7 @@ inline void LapackKernI::Tgemm(int m, int n, int k,
m, n, k, &alpha, A, lda, B, ldb, &beta, C, ldc);
}
template<> //Cmplx Double
template<> //Complex Double
inline void LapackKernI::Tgemm(int m, int n, int k,
const std::complex<double> *A, int lda,
const std::complex<double> *B, int ldb,
......@@ -195,3 +203,8 @@ inline void LapackKernI::dot(int N,
{
cblas_zdotc_sub(N, X, incX, Y, incY, ret);
}
};
#endif // FABULOUS_LAPACK_INTERFACE_CBLAS_HPP
#ifndef FABULOUS_LAPACK_INTERFACE_NANCHECK_HPP
#define FABULOUS_LAPACK_INTERFACE_NANCHECK_HPP
#ifndef FABULOUS_LAPACK_INTERFACE_INC__
# error "Do not include this header directly, use LapackInterface.hpp instead"
#endif
......@@ -6,7 +9,12 @@
# error "LapackInterface_nancheck.hpp was included but FABULOUS_LAPACKE_NANCHECK is not set"
#endif
#include "./LapackInterface.hpp"
#include "fabulous/utils/Arithmetic.hpp"
#include "fabulous/ext/lapacke.h"
namespace fabulous {
/********* LACPY **********/
......@@ -249,3 +257,6 @@ inline int LapackKernI::ggev(int n, std::complex<double> * a,int lda,
FABULOUS_ARITHMETIC_LIST(FABULOUS_SPECIALIZE_TRSM);
}; // end namespace fabulous
#endif // FABULOUS_LAPACK_INTERFACE_NANCHECK_HPP
#ifndef FABULOUS_LAPACK_INTERFACE_WORK_HPP
#define FABULOUS_LAPACK_INTERFACE_WORK_HPP
#ifndef FABULOUS_LAPACK_INTERFACE_INC__
# error "Do not include this header directly, use LapackInterface.hpp instead"
#endif
......@@ -6,6 +9,14 @@
# error "LapackInterface_work.hpp was included but FABULOUS_LAPACKE_NANCHECK is set"
#endif
#include "./LapackInterface.hpp"
#include "fabulous/ext/lapacke.h"
namespace fabulous {
/********* LACPY **********/
#define FABULOUS_SPECIALIZE_LACPY(_1, S_, P_, _4, _5, _6, prefix_, ...) \
......@@ -454,3 +465,8 @@ inline int LapackKernI::ggev(int n,
} \
FABULOUS_ARITHMETIC_LIST(FABULOUS_SPECIALIZE_TRSM);
};
#endif // FABULOUS_LAPACK_INTERFACE_WORK_HPP
......@@ -22,6 +22,8 @@ template< template<class> class HESSENBERG,
#include <fabulous/restart/DeflatedRestart.hpp>
#include <array>
namespace fabulous {
template<
......@@ -35,7 +37,6 @@ struct arnoldiXhessenberg : public std::false_type {};
struct arnoldiXhessenberg<ARNOLDI, HESSENBERG> \
: public std::true_type {}; \
ARNOLDI_X_HESSENBERG(Arnoldi, HessStandard);
ARNOLDI_X_HESSENBERG(Arnoldi, HessQR);
ARNOLDI_X_HESSENBERG(Arnoldi, HessQRDR);
......
......@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
// OrthoScheme::IMGS, OrthoType::BLOCK
// );
runTest_BGMRES_DR_filelog<ARNOLDI_QR>(
runTest_BGMRES_DR_filelog<ARNOLDI_QRDR>(
"young1c",
mat, RHS, XExact,
maxMVP, restart, epsilon,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment