multi-GPUs in node¶
Implementation of ChaseMpiDLAInterface for multi-GPU¶
-
template<class T>
class ChaseMpiDLAMultiGPU : public chase::mpi::ChaseMpiDLAInterface<T>¶ A derived class of ChaseMpiDLAInterface which implements the inter-node computation for a MPI-based implementation with GPU supports of ChASE.
This implementation supports to use all the GPU cards available on each node. The multi-GPU within node can be managed either with 1 MPI rank or each GPU be bounded to one MPI rank.
Public Functions
-
inline virtual void preApplication(T *V, std::size_t locked, std::size_t block) override¶
For ChaseMpiDLAMultiGPU,
preApplicationis implemented only with the operation of switching operation flags.For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void preApplication(T *V, T *V2, std::size_t locked, std::size_t block) override¶
For ChaseMpiDLAMultiGPU,
preApplicationis implemented only with the operation of switching operation flags.For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void apply(T alpha, T beta, std::size_t offset, std::size_t block) override¶
For ChaseMpiDLAMultiGPU, the matrix-matrix multiplication of local matrices are offloaded to multi-GPUs available on the node. The collection of local product among multi-GPUs is done by MPI communication scheme. The computation on each GPU card is implemented with
cublasXgemmprovided bycuBLAS.The multi-GPU HEMM within each node is implemented in class mgpu_cudaDLA.
The collective communication based on MPI which ALLREDUCE the product of local matrices either within the column communicator or row communicator, is implemented within ChaseMpiDLA.
Parallelism on distributed-memory system SUPPORT
Parallelism within each node among multi-GPUs SUPPORT
Parallelism within each GPU SUPPORT
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual bool postApplication(T *V, std::size_t block) override¶
For ChaseMpiDLAMultiGPU,
postApplicationis implemented for the synchronization among the GPUs bounded to a same MPI rank.For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void shiftMatrix(T c, bool isunshift = false) override¶
For ChaseMpiDLAMultiGPU,
shiftMatrixis implemented in ChaseMpiDLA which is executed on CPUs.Parallelism on distributed-memory system SUPPORT
The distribution of matrix
Howned by each MPI rank to the GPUs bounded to it, it is called in this function. The implementation is within class mgpu_cudaDLA.For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void applyVec(T *B, T *C) override¶
For ChaseMpiDLAMultiGPU,
applyVecis implemented in ChaseMpiDLA.Parallelism on distributed-memory system SUPPORT
Parallelism within each node among multi-GPUs SUPPORT
Parallelism within each GPU SUPPORT
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual Base<T> lange(char norm, std::size_t m, std::size_t n, T *A, std::size_t lda) override¶
For ChaseMpiDLAMultiGPU,
langeis implemented usingLAPACKroutinexLANGE.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void gegqr(std::size_t N, std::size_t nevex, T *approxV, std::size_t LDA) override¶
For ChaseMpiDLAMultiGPU,
gegqris implemented by callinggegqrfunction of class mgpu_cudaDLA, whose implementation is based oncuSOLVERroutinescusolverDnXgeqrfandcusolverDnXumgqr.Parallelism is SUPPORT within one GPU card
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void axpy(std::size_t N, T *alpha, T *x, std::size_t incx, T *y, std::size_t incy) override¶
For ChaseMpiDLAMultiGPU,
axpyis implemented in ChaseMpiDLA.
Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void scal(std::size_t N, T *a, T *x, std::size_t incx) override¶
For ChaseMpiDLAMultiGPU,
scalis implemented in ChaseMpiDLAParallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual Base<T> nrm2(std::size_t n, T *x, std::size_t incx) override¶
For ChaseMpiDLAMultiGPU,
nrm2is implemented usingBLASroutinexNRM2.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual T dot(std::size_t n, T *x, std::size_t incx, T *y, std::size_t incy) override¶
For ChaseMpiDLAMultiGPU,
dotis implemented usingBLASroutinexDOT.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void gemm_small(CBLAS_LAYOUT Layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, std::size_t m, std::size_t n, std::size_t k, T *alpha, T *a, std::size_t lda, T *b, std::size_t ldb, T *beta, T *c, std::size_t ldc) override¶
For ChaseMpiDLAMultiGPU,
gemm_smallis implemented in ChaseMpiDLA.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void gemm_large(CBLAS_LAYOUT Layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, std::size_t m, std::size_t n, std::size_t k, T *alpha, T *a, std::size_t lda, T *b, std::size_t ldb, T *beta, T *c, std::size_t ldc) override¶
For ChaseMpiDLAMultiGPU,
gemm_largeis implemented in ChaseMpiDLA.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual std::size_t stemr(int matrix_layout, char jobz, char range, std::size_t n, double *d, double *e, double vl, double vu, std::size_t il, std::size_t iu, int *m, double *w, double *z, std::size_t ldz, std::size_t nzc, int *isuppz, lapack_logical *tryrac) override¶
For ChaseMpiDLAMultiGPU,
stemrwith scalar being real and double precision, is implemented usingLAPACKroutineDSTEMR.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual std::size_t stemr(int matrix_layout, char jobz, char range, std::size_t n, float *d, float *e, float vl, float vu, std::size_t il, std::size_t iu, int *m, float *w, float *z, std::size_t ldz, std::size_t nzc, int *isuppz, lapack_logical *tryrac) override¶
For ChaseMpiDLAMultiGPU,
stemrwith scalar being real and single precision, is implemented usingLAPACKroutineSSTEMR.Parallelism is SUPPORT within node if multi-threading is enabled
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void RR_kernel(std::size_t N, std::size_t block, T *approxV, std::size_t locked, T *workspace, T One, T Zero, Base<T> *ritzv) override¶
For ChaseMpiDLAMultiGPU,
RR_kernelis implemented by calling theRR_kernelfunction of class mgpu_cudaDLA, whose implementation is based oncuBLASroutinecublasXgemmandLAPACKroutine(SY)HEEVD.The 1st operation
A <- W^T * Vis implemented bycublasXgemmfromcuBLAS.The 2nd operation which computes the eigenpairs of
A, is implemented by(SY)HEEVDfromLAPACK.The 3rd operation which computes
W<-V*Ais implemented bycublasXgemmfromcuBLAS.
for (SY)HHEVD, parallelism is SUPPORT within node if multi-threading is actived
for cublasXgemm, parallelism is SUPPORT within one GPU card
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline virtual void preApplication(T *V, std::size_t locked, std::size_t block) override¶
Implementation of Selected DLA with multi-GPUs¶
-
template<class T>
class mgpu_cudaDLA¶ A class to defines the multi-GPU implementation of DLA within node.
This class mainly implements a multi-GPU for
HEMM, which is able to be executed either with 1 MPI managing multi-GPUs or each GPU being bounded to one MPI rank. This class mainly provides the basic functionality for a series of a multi-GPU Hemm-s. The core functionalies are to distribute H, V and W between the GPU devices and to perform the Hemm operation in distributed manner among all GPU devices. The class supports two type of operationsW = alpha * H * V + beta * W (refered as ‘cAb’ operation)
V = alpha * H^C * W + beta * V (refered as ‘bAc’ operation)
such that not additional redististribution of H is required between successive Hemm calls.
This class also provides single-GPU implementation of
gegqrandRR_kernel.Public Functions
-
inline mgpu_cudaDLA()¶
-
inline mgpu_cudaDLA(ChaseMpiProperties<T> *matrix_properties, std::size_t m, std::size_t n, std::size_t maxBlock)¶
A constructor of mgpu_cudaDLA which sets GPUs, allocate device arrays, create cublas and cusolver handles and streams.
- Parameters:
matrix_properties – it is an object of ChaseMpiProperties, which defines the MPI environment and data distribution scheme in ChASE-MPI.
m – row number of local matrix stored on each MPI rank.
n – column number of local matrix stored on each MPI rank.
maxBlock – maximum number of column of the rectangular matrix
V, which equals tonev+nex.
-
inline void distribute_H(T *orig_H, std::size_t ld_origH)¶
This member functions Distribute given matrix
orig_Hamong GPUs.- Parameters:
orig_H – original matrix to be distributed on Host
ld_origH – leading dimension of
orig_H.
-
inline void distribute_V(T *buf_init, std::size_t ldBuf, std::size_t block)¶
This member function divides given matrix
buf_initinto panels and distributed among GPUs.- Parameters:
buf_init – the given matrix to be divided into panels and distributed among GPUs
ldBuf – the leading dimension of
buf_initblock – number of non-converged eigenvectors, it indicates the number of columns in
Vwhich performs theHEMMoperation.
-
inline void computeHemm(std::size_t block, T alpha, T beta)¶
This member function computes HEMM within each GPU card.
- Parameters:
block – number of non-converged eigenvectors, it indicates the number of columns in
Vwhich performs theHEMMoperation.alpha&beta – scalars of type
TinHEMMfunctions.
-
inline void return_W(T *buf_target, std::size_t ldBuf, std::size_t block)¶
This member function collects and returns the computed
Wfrom the GPUs to the host.- Parameters:
buf_target – the matrix host which the computed
Wshould be copied to.ldBuf – the leading dimension of
buf_targetblock – number of non-converged eigenvectors, it indicates the number of columns in
Vwhich performs theHEMMoperation.
-
inline void synchronizeAll()¶
This member function synchronizes all devices.
-
inline void gegqr(std::size_t N, std::size_t nevex, T *approxV, std::size_t LDA)¶
gegqris implemented usingcuSOLVERroutinescusolverDnXgeqrfandcusolverDnXumgqr.Parallelism is SUPPORT within one GPU card
For the meaning of this function, please visit ChaseMpiDLAInterface.
-
inline void RR_kernel(std::size_t N, std::size_t block, T *approxV, std::size_t locked, T *workspace, T One, T Zero, Base<T> *ritzv)¶
RR_kernelis implemented bycublasXgemmroutine provided bycuBLASand(SY)HEEVDroutine provided byLAPACK.The 1st operation
A <- W^T * Vis implemented bycublasXgemmfromcuBLAS.The 2nd operation which computes the eigenpairs of
A, is implemented by(SY)HEEVDfromLAPACK.The 3rd operation which computes
W<-V*Ais implemented bycublasXgemmfromcuBLAS.
for (SY)HHEVD, parallelism is SUPPORT within node if multi-threading is actived
for cublasXgemm, parallelism is SUPPORT within one GPU card
For the meaning of this function, please visit ChaseMpiDLAInterface.