[Openmp-commits] [llvm] [openmp] [offload][OpenMP] Require CUDA 11.8 (PR #191100)
Kevin Sala Penades via Openmp-commits
openmp-commits at lists.llvm.org
Wed Apr 15 07:25:16 PDT 2026
https://github.com/kevinsala updated https://github.com/llvm/llvm-project/pull/191100
>From 6a4f272dce768afbbac88b274fbe905ac547c832 Mon Sep 17 00:00:00 2001
From: Kevin Sala <salapenades1 at llnl.gov>
Date: Wed, 8 Apr 2026 19:35:07 -0700
Subject: [PATCH] [offload][OpenMP] Require CUDA 11.8
---
offload/CMakeLists.txt | 3 +++
offload/plugins-nextgen/cuda/CMakeLists.txt | 3 ++-
offload/plugins-nextgen/cuda/src/rtl.cpp | 16 ++++++++++++++++
offload/test/CMakeLists.txt | 2 +-
offload/unittests/CMakeLists.txt | 2 +-
openmp/docs/Building.md | 11 ++++++-----
6 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 99004d83e819a..9e8925b8610b4 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)
+
# Check that the library can actually be built.
if(APPLE OR WIN32 OR WASM)
message(WARNING "libomptarget cannot be built on Windows and MacOS X!")
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 7a47f2ce7e5aa..2e2b1be809e5c 100644
--- a/offload/plugins-nextgen/cuda/src/rtl.cpp
+++ b/offload/plugins-nextgen/cuda/src/rtl.cpp
@@ -1594,6 +1594,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 fa1a1bacc4062..bda84de698741 100644
--- a/offload/test/CMakeLists.txt
+++ b/offload/test/CMakeLists.txt
@@ -16,7 +16,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
More information about the Openmp-commits
mailing list