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::HIP> cupm_mat{}; 7 8 /*MC 9 MATSEQDENSEHIP - "seqdensehip" - A matrix type to be used for sequential dense matrices on 10 GPUs. 11 12 Options Database Keys: 13 . -mat_type seqdensehip - sets the matrix type to `MATSEQDENSEHIP` during a call to 14 `MatSetFromOptions()` 15 16 Level: beginner 17 18 .seealso: `MATSEQDENSE` 19 M*/ 20 PETSC_INTERN PetscErrorCode MatCreate_SeqDenseHIP(Mat A) 21 { 22 PetscFunctionBegin; 23 PetscCall(cupm_mat.Create(A)); 24 PetscFunctionReturn(PETSC_SUCCESS); 25 } 26 27 PETSC_INTERN PetscErrorCode MatSolverTypeRegister_DENSEHIP(void) 28 { 29 PetscFunctionBegin; 30 PetscCall(impl::MatSolverTypeRegister_DENSECUPM<DeviceType::HIP>()); 31 PetscFunctionReturn(PETSC_SUCCESS); 32 } 33 34 PetscErrorCode MatConvert_SeqDense_SeqDenseHIP(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_SeqDenseHIP_SeqDenseHIP_Internal(Mat A, Mat B, Mat C, PetscBool TA, PetscBool TB) 42 { 43 PetscFunctionBegin; 44 PetscCall(impl::MatMatMultNumeric_SeqDenseCUPM_SeqDenseCUPM<DeviceType::HIP>(A, B, C, TA, TB)); 45 PetscFunctionReturn(PETSC_SUCCESS); 46 } 47 48 PetscErrorCode MatSeqDenseHIPInvertFactors_Internal(Mat A) 49 { 50 PetscFunctionBegin; 51 PetscCall(cupm_mat.InvertFactors(A)); 52 PetscFunctionReturn(PETSC_SUCCESS); 53 } 54 55 /*@C 56 MatCreateSeqDenseHIP - Creates a sequential matrix in dense format using HIP. 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 MatCreateSeqDenseHIP(MPI_Comm comm, PetscInt m, PetscInt n, PetscScalar *data, Mat *A) 75 { 76 PetscFunctionBegin; 77 PetscCall(MatCreateSeqDenseCUPM<DeviceType::HIP>(comm, m, n, data, A)); 78 PetscFunctionReturn(PETSC_SUCCESS); 79 } 80