Actual source code: matseqdensecuda.cu

  1: #include "../matseqdensecupm.hpp"

  3: using namespace Petsc::mat::cupm;
  4: using Petsc::device::cupm::DeviceType;

  6: static constexpr impl::MatDense_Seq_CUPM<DeviceType::CUDA> cupm_mat{};

  8: /*MC
  9:   MATSEQDENSECUDA - "seqdensecuda" - A matrix type to be used for sequential dense matrices on
 10:   GPUs.

 12:   Options Database Keys:
 13: . -mat_type seqdensecuda - sets the matrix type to `MATSEQDENSECUDA` during a call to
 14:                            `MatSetFromOptions()`

 16:   Level: beginner

 18: .seealso: `MATSEQDENSE`
 19: M*/
 20: PETSC_INTERN PetscErrorCode MatCreate_SeqDenseCUDA(Mat A)
 21: {
 22:   PetscFunctionBegin;
 23:   PetscCall(cupm_mat.Create(A));
 24:   PetscFunctionReturn(PETSC_SUCCESS);
 25: }

 27: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_DENSECUDA(void)
 28: {
 29:   PetscFunctionBegin;
 30:   PetscCall(impl::MatSolverTypeRegister_DENSECUPM<DeviceType::CUDA>());
 31:   PetscFunctionReturn(PETSC_SUCCESS);
 32: }

 34: PetscErrorCode MatConvert_SeqDense_SeqDenseCUDA(Mat A, MatType newtype, MatReuse reuse, Mat *newmat)
 35: {
 36:   PetscFunctionBegin;
 37:   PetscCall(cupm_mat.Convert_SeqDense_SeqDenseCUPM(A, newtype, reuse, newmat));
 38:   PetscFunctionReturn(PETSC_SUCCESS);
 39: }

 41: PetscErrorCode MatMatMultNumeric_SeqDenseCUDA_SeqDenseCUDA_Internal(Mat A, Mat B, Mat C, PetscBool TA, PetscBool TB)
 42: {
 43:   PetscFunctionBegin;
 44:   PetscCall(impl::MatMatMultNumeric_SeqDenseCUPM_SeqDenseCUPM<DeviceType::CUDA>(A, B, C, TA, TB));
 45:   PetscFunctionReturn(PETSC_SUCCESS);
 46: }

 48: PetscErrorCode MatSeqDenseCUDAInvertFactors_Internal(Mat A)
 49: {
 50:   PetscFunctionBegin;
 51:   PetscCall(cupm_mat.InvertFactors(A));
 52:   PetscFunctionReturn(PETSC_SUCCESS);
 53: }

 55: /*@C
 56:   MatCreateSeqDenseCUDA - Creates a sequential matrix in dense format using CUDA.

 58:   Collective

 60:   Input Parameters:
 61: + comm - MPI communicator
 62: . m    - number of rows
 63: . n    - number of columns
 64: - data - optional location of GPU matrix data. Pass `NULL` to let PETSc to control matrix
 65:          memory allocation

 67:   Output Parameter:
 68: . A - the matrix

 70:   Level: intermediate

 72: .seealso: `MATSEQDENSE`, `MatCreate()`, `MatCreateSeqDense()`
 73: @*/
 74: PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm comm, PetscInt m, PetscInt n, PetscScalar *data, Mat *A)
 75: {
 76:   PetscFunctionBegin;
 77:   PetscCall(MatCreateSeqDenseCUPM<DeviceType::CUDA>(comm, m, n, data, A));
 78:   PetscFunctionReturn(PETSC_SUCCESS);
 79: }