diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake --- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake @@ -101,12 +101,13 @@ ################################################################################ # 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 @@ 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 @@ 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 --- a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt @@ -34,7 +34,7 @@ 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 @@ 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 --- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt +++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt @@ -30,13 +30,12 @@ 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 @@ 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"