1: #include "../cupmcontext.hpp" /*I "petscdevice.h" I*/ 3: using namespace Petsc::device::cupm; 5: PetscErrorCode PetscDeviceContextCreate_HIP(PetscDeviceContext dctx) 6: { 7: static constexpr auto hip_context = CUPMContextHip(); 9: hip_context.initialize(); 10: dctx->data = new PetscDeviceContext_(HIP); 11: PetscMemcpy(dctx->ops, &hip_context.ops, sizeof(hip_context.ops)); 12: return 0; 13: } 15: /* 16: Management of HIPBLAS and HIPSOLVER handles 18: Unlike CUDA, hipSOLVER is just for dense matrices so there is 19: no distinguishing being dense and sparse. Also, hipSOLVER is 20: very immature so we often have to do the mapping between roc and 21: cuda manually. 22: */ 24: PetscErrorCode PetscHIPBLASGetHandle(hipblasHandle_t *handle) 25: { 26: PetscDeviceContext dctx; 29: PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx, PETSC_DEVICE_HIP); 30: PetscDeviceContextGetBLASHandle_Internal(dctx, handle); 31: return 0; 32: } 34: PetscErrorCode PetscHIPSOLVERGetHandle(hipsolverHandle_t *handle) 35: { 36: PetscDeviceContext dctx; 39: PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx, PETSC_DEVICE_HIP); 40: PetscDeviceContextGetSOLVERHandle_Internal(dctx, handle); 41: return 0; 42: }