Skip to content

Commit

Permalink
Merge pull request trilinos#7544 from Tech-XCorp/amesos2GPU-Basker
Browse files Browse the repository at this point in the history
Amesos2: Refactor Basker to use Kokkos views
  • Loading branch information
MicheldeMessieres authored Jul 9, 2020
2 parents b84d87f + 0a68532 commit 923406e
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 613 deletions.
323 changes: 8 additions & 315 deletions packages/amesos2/src/Amesos2_Basker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,331 +47,24 @@

#include "Amesos2_Basker_def.hpp"
#include "Amesos2_ExplicitInstantiationHelpers.hpp"
#include "TpetraCore_ETIHelperMacros.h"

namespace Amesos2 {

#ifdef HAVE_AMESOS2_EPETRA
AMESOS2_SOLVER_EPETRA_INST(Basker);
#endif

#ifdef HAVE_TPETRA_INST_INT_INT
#ifdef HAVE_TPETRA_INST_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,float,int,int);
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,double,int,int);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<float>,int,int);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<double>,int,int);
#endif
#endif// HAVE_TPETRA_INST_INT_INST
#define AMESOS2_BASKER_LOCAL_INSTANT(S,LO,GO,N) \
template class Amesos2::Basker<Tpetra::CrsMatrix<S, LO, GO, N>, \
Tpetra::MultiVector<S, LO, GO, N> >;

#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
#ifdef HAVE_TPETRA_INST_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,float,int,unsigned);
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,double,int,unsigned);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<float>,int,unsigned);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<double>,int,unsigned);
#endif
#endif// HAVE_TPETRA_INST_INST_UNSIGNED
TPETRA_ETI_MANGLING_TYPEDEFS()

#ifdef HAVE_TPETRA_INST_INT_LONG
#ifdef HAVE_TPETRA_INST_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,float,int,long);
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,double,int,long);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<float>,int,long);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<double>,int,long);
#endif
#endif// HAVE_TPETRA_INST_INT_UNSIGNED

#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
#ifdef HAVE_TPETRA_INST_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,float,int,long long);
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,double,int,long long);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<float>,int,long long);
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
AMESOS2_SOLVER_TPETRA_INST(Basker,std::complex<double>,int,long long);
#endif
#endif// HAVE_TPETRA_INST_INT_INT
TPETRA_INSTANTIATE_SLGN_NO_ORDINAL_SCALAR(AMESOS2_BASKER_LOCAL_INSTANT)

#define AMESOS2_KOKKOS_IMPL_SOLVER_NAME Basker
#include "Amesos2_Kokkos_Impl.hpp"
}

//
// 26-Nov-2014: JJH code copied from Amesos2_SuperLU.cpp.
//
#include "Kokkos_DefaultNode.hpp"
#include "TpetraCore_ETIHelperMacros.h"

#define AMESOS2_BASKER_LOCAL_INSTANT(S,LO,GO,N) \
template class Amesos2::Basker<Tpetra::CrsMatrix<S, LO, GO, N>, \
Tpetra::MultiVector<S, LO, GO, N> >;

TPETRA_ETI_MANGLING_TYPEDEFS()

#if defined(HAVE_TPETRA_INST_SERIAL) && !defined(HAVE_TPETRA_DEFAULTNODE_SERIALWRAPPERNODE) && defined(HAVE_TPETRA_INST_DOUBLE) && defined(TPETRA_HAVE_KOKKOS_REFACTOR)
#define NODETYPE Kokkos_Compat_KokkosSerialWrapperNode
#ifdef HAVE_TPETRA_INST_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(float, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(float, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(double, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(double, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, unsigned int, NODETYPE)
#endif
#endif
#undef NODETYPE
#endif



#if defined(HAVE_TPETRA_INST_PTHREAD) && !defined(HAVE_TPETRA_DEFAULTNODE_THREADSWRAPPERNODE) && defined(HAVE_TPETRA_INST_DOUBLE) && defined(TPETRA_HAVE_KOKKOS_REFACTOR)
#define NODETYPE Kokkos_Compat_KokkosThreadsWrapperNode
#ifdef HAVE_TPETRA_INST_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(float, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(float, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(double, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(double, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, unsigned int, NODETYPE)
#endif
#endif
#undef NODETYPE
#endif

#if defined(HAVE_TPETRA_INST_OPENMP) && !defined(HAVE_TPETRA_DEFAULTNODE_OPENMPWRAPPERNODE) && defined(HAVE_TPETRA_INST_DOUBLE) && defined(TPETRA_HAVE_KOKKOS_REFACTOR)
#define NODETYPE Kokkos_Compat_KokkosOpenMPWrapperNode
#ifdef HAVE_TPETRA_INST_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(float, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(float, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(double, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(double, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, unsigned int, NODETYPE)
#endif
#endif
#undef NODETYPE
#endif

#if defined(HAVE_TPETRA_INST_CUDA) && !defined(HAVE_TPETRA_DEFAULTNODE_CUDAWRAPPERNODE) && defined(HAVE_TPETRA_INST_DOUBLE) && defined(TPETRA_HAVE_KOKKOS_REFACTOR)
#define NODETYPE Kokkos_Compat_KokkosCudaWrapperNode
#ifdef HAVE_TPETRA_INST_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(float, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(float, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(float, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(double, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(double, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(double, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<float>, int, unsigned int, NODETYPE)
#endif
#endif
#ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
#ifdef HAVE_TPETRA_INST_INT_INT
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, int, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_LONG_LONG
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, long long, NODETYPE)
#endif
#ifdef HAVE_TPETRA_INST_INT_UNSIGNED
AMESOS2_BASKER_LOCAL_INSTANT(std::complex<double>, int, unsigned int, NODETYPE)
#endif
#endif
#undef NODETYPE
#endif

#endif // HAVE_AMESOS2_EXPLICIT_INSTANTIATION
29 changes: 17 additions & 12 deletions packages/amesos2/src/Amesos2_Basker_FunctionMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,25 @@

namespace Amesos2 {

/* ==================== Specializations ====================
*
* \cond Basker_function_specializations
*/

/**
* \brief Pass function calls to Basker based on data type.
*/
// TODO : Do we need the specializations for Basker ??

#ifdef HAVE_TEUCHOS_COMPLEX
template <>
struct FunctionMap<Basker,Kokkos::complex<double>>
{
static std::complex<double> * convert_scalar(Kokkos::complex<double> * pData) {
return reinterpret_cast<std::complex<double> *>(pData);
}
};

/* \endcond Basker_function_specializations */
#endif // HAVE_TEUCHOS_COMPLEX

// if not specialized, then assume generic conversion is fine
template <typename scalar_t>
struct FunctionMap<Basker,scalar_t>
{
static scalar_t * convert_scalar(scalar_t * pData) {
return pData; // no conversion necessary
}
};

} // end namespace Amesos2

Expand Down
Loading

0 comments on commit 923406e

Please sign in to comment.