Skip to content

Commit e7535f8

Browse files
committed
[OpenMP][NVPTX] Drop dependence on CUDA to build NVPTX deviceRTLs
With D94745, we no longer use CUDA SDK to compile `deviceRTLs`. Therefore, many CMake code in the project is useless. This patch cleans up unnecessary code and also drops the requirement to build NVPTX `deviceRTLs`. CUDA detection is still being used however to determine whether we need to involve the tests. Auto detection of compute capability is enabled by default and can be disabled by setting CMake variable `LIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY=OFF`. If auto detection is enabled, and CUDA is also valid, it will only build the bitcode library for the detected version; otherwise, all variants supported will be generated. One drawback of this patch is, we now generate 96 variants of bitcode library, and totally 1485 files to be built with a clean build on a non-CUDA system. `LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=""` can be used to disable building NVPTX `deviceRTLs`. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D95466
1 parent e1d6178 commit e7535f8

File tree

4 files changed

+178
-265
lines changed

4 files changed

+178
-265
lines changed

openmp/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Options for ``NVPTX device RTL``
281281

282282
**LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES** = ``35``
283283
List of CUDA compute capabilities that should be supported by the NVPTX
284-
device RTL. E.g. for compute capabilities 6.0 and 7.0, the option "60,70"
284+
device RTL. E.g. for compute capabilities 6.0 and 7.0, the option "60;70"
285285
should be used. Compute capability 3.5 is the minimum required.
286286

287287
**LIBOMPTARGET_NVPTX_DEBUG** = ``OFF|ON``

openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake

+12-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# components of libomptarget. These are the dependencies we have:
1313
#
1414
# libelf : required by some targets to handle the ELF files at runtime.
15-
# libffi : required to launch target kernels given function and argument
15+
# libffi : required to launch target kernels given function and argument
1616
# pointers.
1717
# CUDA : required to control offloading to NVIDIA GPUs.
1818
# VEOS : required to control offloading to NEC Aurora.
@@ -47,18 +47,18 @@ find_library (
4747
/sw/lib
4848
ENV LIBRARY_PATH
4949
ENV LD_LIBRARY_PATH)
50-
50+
5151
set(LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
5252
find_package_handle_standard_args(
53-
LIBOMPTARGET_DEP_LIBELF
53+
LIBOMPTARGET_DEP_LIBELF
5454
DEFAULT_MSG
5555
LIBOMPTARGET_DEP_LIBELF_LIBRARIES
5656
LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS)
5757

5858
mark_as_advanced(
59-
LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS
59+
LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS
6060
LIBOMPTARGET_DEP_LIBELF_LIBRARIES)
61-
61+
6262
################################################################################
6363
# Looking for libffi...
6464
################################################################################
@@ -100,15 +100,15 @@ endif()
100100

101101
set(LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
102102
find_package_handle_standard_args(
103-
LIBOMPTARGET_DEP_LIBFFI
103+
LIBOMPTARGET_DEP_LIBFFI
104104
DEFAULT_MSG
105105
LIBOMPTARGET_DEP_LIBFFI_LIBRARIES
106106
LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS)
107107

108108
mark_as_advanced(
109-
LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS
109+
LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS
110110
LIBOMPTARGET_DEP_LIBFFI_LIBRARIES)
111-
111+
112112
################################################################################
113113
# Looking for CUDA...
114114
################################################################################
@@ -118,7 +118,9 @@ endif()
118118
find_package(CUDA QUIET)
119119

120120
# Try to get the highest Nvidia GPU architecture the system supports
121-
if (CUDA_FOUND)
121+
set(LIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY TRUE CACHE BOOL
122+
"Auto detect CUDA Compute Capability if CUDA is detected.")
123+
if (CUDA_FOUND AND LIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY)
122124
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
123125
string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH_OUTPUT ${CUDA_ARCH_FLAGS})
124126
if (NOT DEFINED CUDA_ARCH_MATCH_OUTPUT OR "${CMAKE_MATCH_1}" LESS 35)
@@ -133,7 +135,7 @@ set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDA_FOUND})
133135
set(LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
134136

135137
mark_as_advanced(
136-
LIBOMPTARGET_DEP_CUDA_FOUND
138+
LIBOMPTARGET_DEP_CUDA_FOUND
137139
LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS)
138140

139141
################################################################################

openmp/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake

-111
This file was deleted.

0 commit comments

Comments
 (0)