Skip to content

Commit d301a28

Browse files
authored
[OpenMP] Guard Virtual Memory Management API and Types (#70986)
1 parent 0500c93 commit d301a28

File tree

1 file changed

+31
-1
lines changed
  • openmp/libomptarget/plugins-nextgen/cuda/src

1 file changed

+31
-1
lines changed

openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ struct CUDAKernelTy;
3737
struct CUDADeviceTy;
3838
struct CUDAPluginTy;
3939

40+
#if (defined(CUDART_VERSION) && (CUDART_VERSION < 11000))
41+
/// Forward declarations for all Virtual Memory Management
42+
/// related data structures and functions. This is necessary
43+
/// for older cuda versions.
44+
typedef void *CUmemGenericAllocationHandle;
45+
typedef void *CUmemAllocationProp;
46+
typedef void *CUmemAccessDesc;
47+
typedef void *CUmemAllocationGranularity_flags;
48+
CUresult cuMemAddressReserve(CUdeviceptr *ptr, size_t size, size_t alignment,
49+
CUdeviceptr addr, unsigned long long flags) {}
50+
CUresult cuMemMap(CUdeviceptr ptr, size_t size, size_t offset,
51+
CUmemGenericAllocationHandle handle,
52+
unsigned long long flags) {}
53+
CUresult cuMemCreate(CUmemGenericAllocationHandle *handle, size_t size,
54+
const CUmemAllocationProp *prop,
55+
unsigned long long flags) {}
56+
CUresult cuMemSetAccess(CUdeviceptr ptr, size_t size,
57+
const CUmemAccessDesc *desc, size_t count) {}
58+
CUresult
59+
cuMemGetAllocationGranularity(size_t *granularity,
60+
const CUmemAllocationProp *prop,
61+
CUmemAllocationGranularity_flags option) {}
62+
#endif
63+
4064
/// Class implementing the CUDA device images properties.
4165
struct CUDADeviceImageTy : public DeviceImageTy {
4266
/// Create the CUDA image with the id and the target image pointer.
@@ -518,7 +542,13 @@ struct CUDADeviceTy : public GenericDeviceTy {
518542
}
519543

520544
/// CUDA support VA management
521-
bool supportVAManagement() const override { return true; }
545+
bool supportVAManagement() const override {
546+
#if (defined(CUDART_VERSION) && (CUDART_VERSION >= 11000))
547+
return true;
548+
#else
549+
return false;
550+
#endif
551+
}
522552

523553
/// Allocates \p RSize bytes (rounded up to page size) and hints the cuda
524554
/// driver to map it to \p VAddr. The obtained address is stored in \p Addr.

0 commit comments

Comments
 (0)