1 #include "../matseqdensecupm.hpp" 2 3 using namespace Petsc::mat::cupm; 4 using Petsc::device::cupm::DeviceType; 5 6 static constexpr impl::MatDense_Seq_CUPM<DeviceType::CUDA> cupm_mat{}; 7 8 /*MC 9 MATSEQDENSECUDA - "seqdensecuda" - A matrix type to be used for sequential dense matrices on 10 GPUs. 11 12 Options Database Keys: 13 . -mat_type seqdensecuda - sets the matrix type to `MATSEQDENSECUDA` during a call to 14 `MatSetFromOptions()` 15 16 Level: beginner 17 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 } 26 27 PETSC_INTERN PetscErrorCode MatSolverTypeRegister_DENSECUDA(void) 28 { 29 PetscFunctionBegin; 30 PetscCall(impl::MatSolverTypeRegister_DENSECUPM<DeviceType::CUDA>()); 31 PetscFunctionReturn(PETSC_SUCCESS); 32 } 33 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 } 40 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 } 47 48 PetscErrorCode MatSeqDenseCUDAInvertFactors_Internal(Mat A) 49 { 50 PetscFunctionBegin; 51 PetscCall(cupm_mat.InvertFactors(A)); 52 PetscFunctionReturn(PETSC_SUCCESS); 53 } 54 55 /*@C 56 MatCreateSeqDenseCUDA - Creates a sequential matrix in dense format using CUDA. 57 58 Collective 59 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 66 67 Output Parameter: 68 . A - the matrix 69 70 Level: intermediate 71 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 } 80