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

inline virtual void preApplication(T *V, T *V2, std::size_t locked, std::size_t block) override

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 cublasXgemm provided by cuBLAS.

  • 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

inline virtual void shiftMatrix(T c, bool isunshift = false) override

  • For ChaseMpiDLAMultiGPU, shiftMatrix is implemented in ChaseMpiDLA which is executed on CPUs.

  • Parallelism on distributed-memory system SUPPORT

  • The distribution of matrix H owned 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, applyVec is 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, lange is implemented using LAPACK routine xLANGE.

  • 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, gegqr is implemented by calling gegqr function of class mgpu_cudaDLA, whose implementation is based on cuSOLVER routines cusolverDnXgeqrf and cusolverDnXumgqr.

  • 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

Parallelism is SUPPORT within node if multi-threading is enabled

inline virtual void scal(std::size_t N, T *a, T *x, std::size_t incx) override

inline virtual Base<T> nrm2(std::size_t n, T *x, std::size_t incx) override

  • For ChaseMpiDLAMultiGPU, nrm2 is implemented using BLAS routine xNRM2.

  • 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, dot is implemented using BLAS routine xDOT.

  • 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

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

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, stemr with scalar being real and double precision, is implemented using LAPACK routine DSTEMR.

  • 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, stemr with scalar being real and single precision, is implemented using LAPACK routine SSTEMR.

  • 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_kernel is implemented by calling the RR_kernel function of class mgpu_cudaDLA, whose implementation is based on cuBLAS routine cublasXgemm and LAPACK routine (SY)HEEVD.

    • The 1st operation A <- W^T * V is implemented by cublasXgemm from cuBLAS.

    • The 2nd operation which computes the eigenpairs of A, is implemented by (SY)HEEVD from LAPACK.

    • The 3rd operation which computes W<-V*A is implemented by cublasXgemm from cuBLAS.

  • 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.

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 operations

  • W = 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 gegqr and RR_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 to nev+nex.

inline void distribute_H(T *orig_H, std::size_t ld_origH)

This member functions Distribute given matrix orig_H among 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_init into 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_init

  • block – number of non-converged eigenvectors, it indicates the number of columns in V which performs the HEMM operation.

inline void computeHemm(std::size_t block, std::size_t offset, 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 V which performs the HEMM operation.

  • alpha&beta – scalars of type T in HEMM functions.

inline void return_W(T *buf_target, std::size_t ldBuf, std::size_t block, std::size_t offset)

This member function collects and returns the computed W from the GPUs to the host.

Parameters:
  • buf_target – the matrix host which the computed W should be copied to.

  • ldBuf – the leading dimension of buf_target

  • block – number of non-converged eigenvectors, it indicates the number of columns in V which performs the HEMM operation.

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)

  • gegqr is implemented using cuSOLVER routines cusolverDnXgeqrf and cusolverDnXumgqr.

  • 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_kernel is implemented by cublasXgemm routine provided by cuBLAS and (SY)HEEVD routine provided by LAPACK.

    • The 1st operation A <- W^T * V is implemented by cublasXgemm from cuBLAS.

    • The 2nd operation which computes the eigenpairs of A, is implemented by (SY)HEEVD from LAPACK.

    • The 3rd operation which computes W<-V*A is implemented by cublasXgemm from cuBLAS.

  • 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.