[Openmp-commits] [openmp] d301a28 - [OpenMP] Guard Virtual Memory Management API and Types (#70986)

via Openmp-commits openmp-commits at lists.llvm.org
Fri Nov 3 16:24:21 PDT 2023


Author: Konstantinos Parasyris
Date: 2023-11-03T16:24:18-07:00
New Revision: d301a2895053fb335de0ba456d8cf80855a24fd9

URL: https://github.com/llvm/llvm-project/commit/d301a2895053fb335de0ba456d8cf80855a24fd9
DIFF: https://github.com/llvm/llvm-project/commit/d301a2895053fb335de0ba456d8cf80855a24fd9.diff

LOG: [OpenMP] Guard Virtual Memory Management API and Types (#70986)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
index be34051bc96f974..d4e9911b67189f8 100644
--- a/openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -37,6 +37,30 @@ struct CUDAKernelTy;
 struct CUDADeviceTy;
 struct CUDAPluginTy;
 
+#if (defined(CUDART_VERSION) && (CUDART_VERSION < 11000))
+/// Forward declarations for all Virtual Memory Management
+/// related data structures and functions. This is necessary
+/// for older cuda versions.
+typedef void *CUmemGenericAllocationHandle;
+typedef void *CUmemAllocationProp;
+typedef void *CUmemAccessDesc;
+typedef void *CUmemAllocationGranularity_flags;
+CUresult cuMemAddressReserve(CUdeviceptr *ptr, size_t size, size_t alignment,
+                             CUdeviceptr addr, unsigned long long flags) {}
+CUresult cuMemMap(CUdeviceptr ptr, size_t size, size_t offset,
+                  CUmemGenericAllocationHandle handle,
+                  unsigned long long flags) {}
+CUresult cuMemCreate(CUmemGenericAllocationHandle *handle, size_t size,
+                     const CUmemAllocationProp *prop,
+                     unsigned long long flags) {}
+CUresult cuMemSetAccess(CUdeviceptr ptr, size_t size,
+                        const CUmemAccessDesc *desc, size_t count) {}
+CUresult
+cuMemGetAllocationGranularity(size_t *granularity,
+                              const CUmemAllocationProp *prop,
+                              CUmemAllocationGranularity_flags option) {}
+#endif
+
 /// Class implementing the CUDA device images properties.
 struct CUDADeviceImageTy : public DeviceImageTy {
   /// Create the CUDA image with the id and the target image pointer.
@@ -518,7 +542,13 @@ struct CUDADeviceTy : public GenericDeviceTy {
   }
 
   /// CUDA support VA management
-  bool supportVAManagement() const override { return true; }
+  bool supportVAManagement() const override {
+#if (defined(CUDART_VERSION) && (CUDART_VERSION >= 11000))
+    return true;
+#else
+    return false;
+#endif
+  }
 
   /// Allocates \p RSize bytes (rounded up to page size) and hints the cuda
   /// driver to map it to \p VAddr. The obtained address is stored in \p Addr.


        


More information about the Openmp-commits mailing list