[Openmp-commits] [llvm] [openmp] [offload][OpenMP] Require CUDA 11.8 (PR #191100)
via Openmp-commits
openmp-commits at lists.llvm.org
Wed Apr 8 19:40:52 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Kevin Sala Penades (kevinsala)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/191100.diff
6 Files Affected:
- (modified) offload/CMakeLists.txt (+3)
- (modified) offload/plugins-nextgen/cuda/CMakeLists.txt (+2-1)
- (modified) offload/plugins-nextgen/cuda/src/rtl.cpp (+16)
- (modified) offload/test/CMakeLists.txt (+1-1)
- (modified) offload/unittests/CMakeLists.txt (+1-1)
- (modified) openmp/docs/Building.md (+6-5)
``````````diff
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 65733de43d29e..527facb007b4d 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -4,6 +4,9 @@
cmake_minimum_required(VERSION 3.20.0)
set(LLVM_SUBPROJECT_TITLE "liboffload")
+# The minimum versions required for dependencies.
+set(OFFLOAD_MINIMUM_CUDA_VERSION 11.8.0)
+
# Permit redefining OPENMP_STANDALONE_BUILD when doing a runtimes build.
if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(OPENMP_STANDALONE_BUILD TRUE)
diff --git a/offload/plugins-nextgen/cuda/CMakeLists.txt b/offload/plugins-nextgen/cuda/CMakeLists.txt
index 5fdfb8f9cf628..687842db006e9 100644
--- a/offload/plugins-nextgen/cuda/CMakeLists.txt
+++ b/offload/plugins-nextgen/cuda/CMakeLists.txt
@@ -3,7 +3,8 @@ add_target_library(omptarget.rtl.cuda CUDA)
target_sources(omptarget.rtl.cuda PRIVATE src/rtl.cpp)
-find_package(CUDAToolkit QUIET)
+find_package(CUDAToolkit QUIET ${OFFLOAD_MINIMUM_CUDA_VERSION})
+
if(CUDAToolkit_FOUND AND NOT "cuda" IN_LIST LIBOMPTARGET_DLOPEN_PLUGINS)
message(STATUS "Building CUDA plugin linked against libcuda")
target_link_libraries(omptarget.rtl.cuda PRIVATE CUDA::cuda_driver)
diff --git a/offload/plugins-nextgen/cuda/src/rtl.cpp b/offload/plugins-nextgen/cuda/src/rtl.cpp
index c96cf3d89d3d4..9ce0b31335bbf 100644
--- a/offload/plugins-nextgen/cuda/src/rtl.cpp
+++ b/offload/plugins-nextgen/cuda/src/rtl.cpp
@@ -1584,6 +1584,22 @@ struct CUDAPluginTy final : public GenericPluginTy {
if (auto Err = Plugin::check(Res, "error in cuInit: %s"))
return std::move(Err);
+ // Get the latest CUDA version supported by the driver.
+ int Version;
+ Res = cuDriverGetVersion(&Version);
+ if (auto Err = Plugin::check(Res, "error in cuDriverGetVersion: %s"))
+ return std::move(Err);
+
+ // Verify that the driver supports the minimum CUDA version required.
+ constexpr int MinVersion = 11080;
+ if (Version < MinVersion) {
+ ODBG(OLDT_Init) << "Minimum CUDA version not supported by the driver.";
+ return Plugin::error(
+ ErrorCode::UNSUPPORTED,
+ "CUDA driver does not support minimum CUDA version %d (%d detected)",
+ MinVersion, Version);
+ }
+
// Get the number of devices.
int NumDevices;
Res = cuDeviceGetCount(&NumDevices);
diff --git a/offload/test/CMakeLists.txt b/offload/test/CMakeLists.txt
index 711621de9075d..0126134138fae 100644
--- a/offload/test/CMakeLists.txt
+++ b/offload/test/CMakeLists.txt
@@ -22,7 +22,7 @@ endif()
# char into the lit command.
string(REPLACE " " ";" LIBOMPTARGET_LIT_ARG_LIST "${LIBOMPTARGET_LIT_ARGS}")
-find_package(CUDAToolkit QUIET)
+find_package(CUDAToolkit QUIET ${OFFLOAD_MINIMUM_CUDA_VERSION})
if(CUDAToolkit_FOUND)
get_filename_component(CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE)
get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
diff --git a/offload/unittests/CMakeLists.txt b/offload/unittests/CMakeLists.txt
index 33b22b56b1955..eaaa0025bb92f 100644
--- a/offload/unittests/CMakeLists.txt
+++ b/offload/unittests/CMakeLists.txt
@@ -26,7 +26,7 @@ function(add_offload_test_device_code test_filename test_name)
# Try to build with support for NVPTX devices.
if("cuda" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
- find_package(CUDAToolkit QUIET)
+ find_package(CUDAToolkit QUIET ${OFFLOAD_MINIMUM_CUDA_VERSION})
if(CUDAToolkit_FOUND)
get_filename_component(cuda_path "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE)
endif()
diff --git a/openmp/docs/Building.md b/openmp/docs/Building.md
index 460d4f03915f1..699ae60720274 100644
--- a/openmp/docs/Building.md
+++ b/openmp/docs/Building.md
@@ -20,11 +20,12 @@ for those requirements.
### Requirements for Building with Nvidia GPU support
The CUDA SDK is required on the machine that will build and execute the
-offloading application. Normally this is only required at runtime by dynamically
-opening the CUDA driver API. This can be disabled in the build by omitting
-`cuda` from the [`LIBOMPTARGET_DLOPEN_PLUGINS`](LIBOMPTARGET_DLOPEN_PLUGINS)
-list which is present by default. With this setting we will instead find the
-CUDA library at LLVM build time and link against it directly.
+offloading application. The CUDA driver must support CUDA 11.8.0 or later.
+Normally this is only required at runtime when the CUDA driver API is
+dynamically opened. This can be disabled in the build by omitting `cuda` from
+the [`LIBOMPTARGET_DLOPEN_PLUGINS`](LIBOMPTARGET_DLOPEN_PLUGINS) list which is
+present by default. With this setting we will instead find the CUDA library at
+LLVM build time and link against it directly.
### Requirements for Building with AMD GPU support
``````````
</details>
https://github.com/llvm/llvm-project/pull/191100
More information about the Openmp-commits
mailing list