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

Konstantinos Parasyris via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 1 14:28:38 PDT 2023


https://github.com/koparasy created https://github.com/llvm/llvm-project/pull/70986

None

>From 43098a552bc32c5e910ea1e4517ffc118add628a Mon Sep 17 00:00:00 2001
From: koparasy <parasyris1 at llnl.gov>
Date: Wed, 1 Nov 2023 14:12:06 -0700
Subject: [PATCH] [OpenMP] Guard Virtaul Memory Management API and types

---
 .../plugins-nextgen/cuda/src/rtl.cpp          | 32 ++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

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