1: #include "../cupmcontext.hpp" /*I "petscdevice.h" I*/
3: using namespace Petsc::device::cupm;
5: PetscErrorCode PetscDeviceContextCreate_CUDA(PetscDeviceContext dctx)
6: {
7: static constexpr auto cuda_context = CUPMContextCuda();
9: cuda_context.initialize();
10: dctx->data = new PetscDeviceContext_(CUDA);
11: PetscMemcpy(dctx->ops, &cuda_context.ops, sizeof(cuda_context.ops));
12: return 0;
13: }
15: /* Management of CUBLAS and CUSOLVER handles */
16: PetscErrorCode PetscCUBLASGetHandle(cublasHandle_t *handle)
17: {
18: PetscDeviceContext dctx;
21: PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx, PETSC_DEVICE_CUDA);
22: PetscDeviceContextGetBLASHandle_Internal(dctx, handle);
23: return 0;
24: }
26: PetscErrorCode PetscCUSOLVERDnGetHandle(cusolverDnHandle_t *handle)
27: {
28: PetscDeviceContext dctx;
31: PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx, PETSC_DEVICE_CUDA);
32: PetscDeviceContextGetSOLVERHandle_Internal(dctx, handle);
33: return 0;
34: }