[Openmp-commits] [openmp] c568622 - [Libomptarget] Remove find_package(CUDA) as it has been deprecated
Joseph Huber via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jan 25 11:58:12 PST 2023
Author: Joseph Huber
Date: 2023-01-25T13:58:01-06:00
New Revision: c5686220460550476ddcc809e46b02ba44f2ee7e
URL: https://github.com/llvm/llvm-project/commit/c5686220460550476ddcc809e46b02ba44f2ee7e
DIFF: https://github.com/llvm/llvm-project/commit/c5686220460550476ddcc809e46b02ba44f2ee7e.diff
LOG: [Libomptarget] Remove find_package(CUDA) as it has been deprecated
Since D137724 and the LLVM 17 release we have updated to CMake version
3.20. This means that `find_package(CUDA)` is officially deprecated and
can be replaced with `find_package(CUDAToolkit)` instead. This patch
does this and also cleans up a bit of the CMake.
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D142568
Added:
Modified:
openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
openmp/libomptarget/plugins/cuda/CMakeLists.txt
Removed:
################################################################################
diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
index 8677b4f1016a4..fb4935a61c565 100644
--- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -101,12 +101,13 @@ mark_as_advanced(
################################################################################
# Looking for CUDA...
################################################################################
-if (CUDA_TOOLKIT_ROOT_DIR)
- set(LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET TRUE)
-endif()
-find_package(CUDA QUIET)
-# Identify any locally installed GPUs to use for testing.
+find_package(CUDAToolkit QUIET)
+set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDAToolkit_FOUND})
+
+################################################################################
+# Looking for NVIDIA GPUs...
+################################################################################
set(LIBOMPTARGET_DEP_CUDA_ARCH "sm_35")
find_program(LIBOMPTARGET_NVPTX_ARCH NAMES nvptx-arch PATHS ${LLVM_BINARY_DIR}/bin)
@@ -123,41 +124,6 @@ if(LIBOMPTARGET_NVPTX_ARCH)
endif()
endif()
-set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDA_FOUND})
-set(LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
-
-mark_as_advanced(
- LIBOMPTARGET_DEP_CUDA_FOUND
- LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS)
-
-################################################################################
-# Looking for CUDA Driver API... (needed for CUDA plugin)
-################################################################################
-
-find_library (
- LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES
- NAMES
- cuda
- PATHS
- /lib64)
-
-# There is a libcuda.so in lib64/stubs that can be used for linking.
-if (NOT LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES AND CUDA_FOUND)
- get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
- find_library(
- LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES
- NAMES
- cuda
- HINTS
- "${CUDA_LIBDIR}/stubs")
-endif()
-
-find_package_handle_standard_args(
- LIBOMPTARGET_DEP_CUDA_DRIVER
- DEFAULT_MSG
- LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES)
-
-mark_as_advanced(LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES)
################################################################################
# Looking for AMD GPUs...
@@ -234,33 +200,4 @@ mark_as_advanced(
LIBOMPTARGET_DEP_VEO_FOUND
LIBOMPTARGET_DEP_VEO_INCLUDE_DIRS)
-# Looking for CUDA libdevice subdirectory
-#
-# Special case for Debian/Ubuntu to have nvidia-cuda-toolkit work
-# out of the box. More info on http://bugs.debian.org/882505
-################################################################################
-
-set(LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR nvvm/libdevice)
-
-# Don't alter CUDA_TOOLKIT_ROOT_DIR if the user specified it, if a value was
-# already cached for it, or if it already has libdevice. Otherwise, on
-# Debian/Ubuntu, look where the nvidia-cuda-toolkit package normally installs
-# libdevice.
-if (NOT LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET AND
- NOT EXISTS
- "${CUDA_TOOLKIT_ROOT_DIR}/${LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR}")
- find_program(LSB_RELEASE lsb_release)
- if (LSB_RELEASE)
- execute_process(COMMAND ${LSB_RELEASE} -is
- OUTPUT_VARIABLE LSB_RELEASE_ID
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(candidate_dir /usr/lib/cuda)
- if ((LSB_RELEASE_ID STREQUAL "Debian" OR LSB_RELEASE_ID STREQUAL "Ubuntu")
- AND EXISTS "${candidate_dir}/${LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR}")
- set(CUDA_TOOLKIT_ROOT_DIR "${candidate_dir}" CACHE PATH
- "Toolkit location." FORCE)
- endif()
- endif()
-endif()
-
set(OPENMP_PTHREAD_LIB ${LLVM_PTHREAD_LIB})
diff --git a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
index 02cf47b405caf..90471a92a3b9a 100644
--- a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
@@ -34,7 +34,7 @@ set(LIBOMPTARGET_DLOPEN_LIBCUDA OFF)
option(LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA "Build with dlopened libcuda" ${LIBOMPTARGET_DLOPEN_LIBCUDA})
set(LIBOMPTARGET_CAN_LINK_LIBCUDA FALSE)
-if (LIBOMPTARGET_DEP_CUDA_FOUND AND LIBOMPTARGET_DEP_CUDA_DRIVER_FOUND)
+if (LIBOMPTARGET_DEP_CUDA_FOUND)
set(LIBOMPTARGET_CAN_LINK_LIBCUDA TRUE)
endif()
@@ -53,7 +53,7 @@ if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
elf_common
MemoryManager
PluginInterface
- ${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES}
+ CUDA::cuda_driver
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,-z,defs"
diff --git a/openmp/libomptarget/plugins/cuda/CMakeLists.txt b/openmp/libomptarget/plugins/cuda/CMakeLists.txt
index 520c6b0365de2..c92f22f076446 100644
--- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -30,13 +30,12 @@ set(LIBOMPTARGET_DLOPEN_LIBCUDA OFF)
option(LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA "Build with dlopened libcuda" ${LIBOMPTARGET_DLOPEN_LIBCUDA})
set(LIBOMPTARGET_CAN_LINK_LIBCUDA FALSE)
-if (LIBOMPTARGET_DEP_CUDA_FOUND AND LIBOMPTARGET_DEP_CUDA_DRIVER_FOUND)
+if (LIBOMPTARGET_DEP_CUDA_FOUND)
set(LIBOMPTARGET_CAN_LINK_LIBCUDA TRUE)
endif()
if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
libomptarget_say("Building CUDA plugin linked against libcuda")
- include_directories(${LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS})
add_llvm_library(omptarget.rtl.cuda SHARED
src/rtl.cpp
@@ -52,7 +51,7 @@ if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
PRIVATE
elf_common
MemoryManager
- ${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES}
+ CUDA::cuda_driver
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,-z,defs"
More information about the Openmp-commits
mailing list