Date: 2022-03-31T04:46:09+00:00

Actual source code: cupmcontext.cu

      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     contextCuda = CUPMContextCuda();
      8:   PetscDeviceContext_(CUDA) *dci;

     10:   PetscNew(&dci);
     11:   dctx->data = static_cast<decltype(dctx->data)>(dci);
     12:   PetscMemcpy(dctx->ops,&contextCuda.ops,sizeof(contextCuda.ops));
     13:   return 0;
     14: }

     16: /* Management of CUBLAS and CUSOLVER handles */
     17: PetscErrorCode PetscCUBLASGetHandle(cublasHandle_t *handle)
     18: {
     19:   PetscDeviceContext dctx;

     22:   PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx,PETSC_DEVICE_CUDA);
     23:   PetscDeviceContextGetBLASHandle_Internal(dctx,handle);
     24:   return 0;
     25: }

     27: PetscErrorCode PetscCUSOLVERDnGetHandle(cusolverDnHandle_t *handle)
     28: {
     29:   PetscDeviceContext dctx;

     32:   PetscDeviceContextGetCurrentContextAssertType_Internal(&dctx,PETSC_DEVICE_CUDA);
     33:   PetscDeviceContextGetSOLVERHandle_Internal(dctx,handle);
     34:   return 0;
     35: }