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 contextHip = CUPMContextHip(); 8: PetscDeviceContext_(HIP) *dci; 10: PetscNew(&dci); 11: dctx->data = static_cast<decltype(dctx->data)>(dci); 12: PetscMemcpy(dctx->ops,&contextHip.ops,sizeof(contextHip.ops)); 13: return 0; 14: } 16: /* 17: Management of HIPBLAS and HIPSOLVER handles 19: Unlike CUDA, hipSOLVER is just for dense matrices so there is 20: no distinguishing being dense and sparse. Also, hipSOLVER is 21: very immature so we often have to do the mapping between roc and 22: cuda manually. 23: */ 25: PetscErrorCode PetscHIPBLASGetHandle(hipblasHandle_t *handle) 26: { 27: PetscDeviceContext dctx; 30: PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx,PETSC_DEVICE_HIP); 31: PetscDeviceContextGetBLASHandle_Internal(dctx,handle); 32: return 0; 33: } 35: PetscErrorCode PetscHIPSOLVERGetHandle(hipsolverHandle_t *handle) 36: { 37: PetscDeviceContext dctx; 40: PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx,PETSC_DEVICE_HIP); 41: PetscDeviceContextGetSOLVERHandle_Internal(dctx,handle); 42: return 0; 43: }