20BatchedLinAlg::BatchedLinAlg()
22 backends[
NATIVE].reset(
new NativeBatchedLinAlg);
26#ifdef MFEM_USE_CUDA_OR_HIP
27 backends[
GPU_BLAS].reset(
new GPUBlasBatchedLinAlg);
31 backends[
MAGMA].reset(
new MagmaBatchedLinAlg);
34#if defined(MFEM_USE_MAGMA)
35 active_backend =
MAGMA;
36#elif defined(MFEM_USE_CUDA_OR_HIP)
48BatchedLinAlg &BatchedLinAlg::Instance()
50 static BatchedLinAlg instance;
62 Get(Instance().active_backend).
Mult(A, x, y);
84 Get(Instance().active_backend).
LUSolve(A, P, x);
89 return Instance().backends[backend] !=
nullptr;
94 MFEM_VERIFY(
IsAvailable(backend),
"Requested backend not supported.");
95 Instance().active_backend = backend;
100 return Instance().active_backend;
105 auto &backend_ptr = Instance().backends[backend];
106 MFEM_VERIFY(backend_ptr,
"Requested backend not supported.")
119 AddMult(A, x, y, 1.0, 0.0, Op::T);
Abstract base clase for batched linear algebra operations.
virtual void Mult(const DenseTensor &A, const Vector &x, Vector &y) const
See BatchedLinAlg::Mult.
virtual void Invert(DenseTensor &A) const =0
See BatchedLinAlg::Invert.
virtual void LUFactor(DenseTensor &A, Array< int > &P) const =0
See BatchedLinAlg::LUFactor.
virtual void MultTranspose(const DenseTensor &A, const Vector &x, Vector &y) const
See BatchedLinAlg::MultTranspose.
virtual void LUSolve(const DenseTensor &LU, const Array< int > &P, Vector &x) const =0
See BatchedLinAlg::LUSolve.
virtual void AddMult(const DenseTensor &A, const Vector &x, Vector &y, real_t alpha=1.0, real_t beta=1.0, Op op=Op::N) const =0
See BatchedLinAlg::AddMult.
static void Mult(const DenseTensor &A, const Vector &x, Vector &y)
Computes (e.g. by calling AddMult(A,x,y,1,0,Op::N)).
Backend
Available backends for implementations of batched algorithms.
@ GPU_BLAS
Either cuBLAS or hipBLAS, depending on whether MFEM is using CUDA or HIP. Not available otherwise.
@ MAGMA
MAGMA backend, only available if MFEM is compiled with MAGMA support.
@ NATIVE
The standard MFEM backend, implemented using mfem::forall kernels. Not as performant as the other ker...
static const BatchedLinAlgBase & Get(Backend backend)
Get the BatchedLinAlgBase object associated with a specific backend.
static void MultTranspose(const DenseTensor &A, const Vector &x, Vector &y)
Computes (e.g. by calling AddMult(A,x,y,1,0,Op::T)).
static Backend GetActiveBackend()
Get the default backend for batched linear algebra operations.
static bool IsAvailable(Backend backend)
Returns true if the requested backend is available.
static void LUFactor(DenseTensor &A, Array< int > &P)
Replaces the block diagonal matrix with its LU factors. The pivots are stored in P.
static void AddMult(const DenseTensor &A, const Vector &x, Vector &y, real_t alpha=1.0, real_t beta=1.0, Op op=Op::N)
Computes .
static void SetActiveBackend(Backend backend)
Set the default backend for batched linear algebra operations.
Op
Operation type (transposed or not transposed)
static void LUSolve(const DenseTensor &A, const Array< int > &P, Vector &x)
Replaces with , given the LU factors A and pivots P of the block-diagonal matrix .
static void Invert(DenseTensor &A)
Replaces the block diagonal matrix with its inverse .
Rank 3 tensor (array of matrices)
static bool Allows(unsigned long b_mask)
Return true if any of the backends in the backend mask, b_mask, are allowed.
@ HIP_MASK
Biwise-OR of all HIP backends.
@ CUDA_MASK
Biwise-OR of all CUDA backends.