Skip to content

Commit e8b31e1

Browse files
committed
[Offload][WIP] Move /openmp/libomptarget to /offload
** This is still WIP - Testing is needed ** In a nutshell, this moves our libomptarget code to create the offload subproject. For now, we allow LLVM/Offload only as runtime. Tests and other components still depend on OpenMP and have also not been renamed. The results below are for a build in which OpenMP and Offload are enabled runtimes. In addition to the pure `git mv`, I needed to adjust some CMake files. Nothing is intended to change semantics but some of the things likely broke other build configurations. Testers are needed. ``` ninja -C build/llvm/runtimes/runtimes-bins check-libomptarget ``` Works with the X86 and AMDGPU offload tests ``` ninja -C /build/llvm/ check-openmp ``` Still works but doesn't build offload tests anymore. ``` ls install/lib ``` Shows all expected libraries, incl. - `libomptarget.devicertl.a` - `libomptarget-nvptx-sm_90.bc` - `libomptarget.rtl.amdgpu.so` -> `libomptarget.rtl.amdgpu.so.18git` - `libomptarget.so` -> `libomptarget.so.18git` Fixes: llvm#75124
1 parent 5dd1fc7 commit e8b31e1

File tree

324 files changed

+108
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+108
-42
lines changed

llvm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ endif()
156156
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes
157157
# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
158158
set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
159-
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc")
159+
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload")
160160
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
161161
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
162162
if(LLVM_ENABLE_RUNTIMES STREQUAL "all")

openmp/libomptarget/CMakeLists.txt renamed to offload/CMakeLists.txt

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,98 @@
1010
#
1111
##===----------------------------------------------------------------------===##
1212

13-
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
14-
message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
13+
set(ENABLE_LIBOMPTARGET ON)
14+
# Currently libomptarget cannot be compiled on Windows or MacOS X.
15+
# Since the device plugins are only supported on Linux anyway,
16+
# there is no point in trying to compile libomptarget on other OSes.
17+
# 32-bit systems are not supported either.
18+
if (APPLE OR WIN32 OR NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
19+
set(ENABLE_LIBOMPTARGET OFF)
1520
endif()
1621

17-
# Add cmake directory to search for custom cmake functions.
18-
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
22+
option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
23+
${ENABLE_LIBOMPTARGET})
24+
if (OPENMP_ENABLE_LIBOMPTARGET)
25+
# Check that the library can actually be built.
26+
if (APPLE OR WIN32)
27+
message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
28+
elseif (NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
29+
message(FATAL_ERROR "Host compiler must support C++17 to build libomptarget!")
30+
elseif (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
31+
message(FATAL_ERROR "libomptarget on 32-bit systems are not supported!")
32+
endif()
33+
endif()
34+
35+
# TODO: Leftover from the move, could probably be just LLVM_LIBDIR_SUFFIX everywhere.
36+
set(OFFLOAD_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
37+
38+
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
39+
40+
# Add path for custom modules
41+
list(INSERT CMAKE_MODULE_PATH 0
42+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
43+
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
44+
)
45+
46+
if (OPENMP_STANDALONE_BUILD)
47+
# CMAKE_BUILD_TYPE was not set, default to Release.
48+
if (NOT CMAKE_BUILD_TYPE)
49+
set(CMAKE_BUILD_TYPE Release)
50+
endif()
51+
52+
# Group common settings.
53+
set(OPENMP_ENABLE_WERROR FALSE CACHE BOOL
54+
"Enable -Werror flags to turn warnings into errors for supporting compilers.")
55+
set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING
56+
"Suffix of lib installation directory, e.g. 64 => lib64")
57+
# Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR.
58+
set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}")
59+
60+
# Group test settings.
61+
set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
62+
"C compiler to use for testing OpenMP runtime libraries.")
63+
set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
64+
"C++ compiler to use for testing OpenMP runtime libraries.")
65+
set(OPENMP_TEST_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING
66+
"FORTRAN compiler to use for testing OpenMP runtime libraries.")
67+
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
68+
69+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
70+
set(CMAKE_CXX_STANDARD_REQUIRED NO)
71+
set(CMAKE_CXX_EXTENSIONS NO)
72+
else()
73+
set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
74+
# If building in tree, we honor the same install suffix LLVM uses.
75+
set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
76+
77+
if (NOT MSVC)
78+
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
79+
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
80+
else()
81+
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
82+
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
83+
endif()
84+
85+
# Check for flang
86+
if (NOT MSVC)
87+
set(OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang-new)
88+
else()
89+
set(OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang-new.exe)
90+
endif()
91+
92+
# Set fortran test compiler if flang is found
93+
if (EXISTS "${OPENMP_TEST_Fortran_COMPILER}")
94+
message("Using local flang build at ${OPENMP_TEST_Fortran_COMPILER}")
95+
else()
96+
unset(OPENMP_TEST_Fortran_COMPILER)
97+
endif()
98+
99+
# If not standalone, set CMAKE_CXX_STANDARD but don't set the global cache value,
100+
# only set it locally for OpenMP.
101+
set(CMAKE_CXX_STANDARD 17)
102+
set(CMAKE_CXX_STANDARD_REQUIRED NO)
103+
set(CMAKE_CXX_EXTENSIONS NO)
104+
endif()
19105

20106
# Set the path of all resulting libraries to a unified location so that it can
21107
# be used for testing.
@@ -36,6 +122,9 @@ include(LibomptargetUtils)
36122
# Get dependencies for the different components of the project.
37123
include(LibomptargetGetDependencies)
38124

125+
# Set up testing infrastructure.
126+
include(OpenMPTesting)
127+
39128
# LLVM source tree is required at build time for libomptarget
40129
if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
41130
message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS")
@@ -129,11 +218,6 @@ set(LIBOMPTARGET_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
129218
message(STATUS "OpenMP tools dir in libomptarget: ${LIBOMP_OMP_TOOLS_INCLUDE_DIR}")
130219
include_directories(${LIBOMP_OMP_TOOLS_INCLUDE_DIR})
131220

132-
# Definitions for testing, for reuse when testing libomptarget-nvptx.
133-
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMP_INCLUDE_DIR}" CACHE STRING
134-
"Path to folder containing omp.h")
135-
set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${LIBOMP_LIBRARY_DIR}" CACHE STRING
136-
"Path to folder containing libomp.so, and libLLVMSupport.so with profiling enabled")
137221
set(LIBOMPTARGET_LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE STRING
138222
"Path to folder containing llvm library libomptarget.so")
139223
set(LIBOMPTARGET_LLVM_LIBRARY_INTDIR "${LIBOMPTARGET_INTDIR}" CACHE STRING

openmp/libomptarget/DeviceRTL/CMakeLists.txt renamed to offload/DeviceRTL/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
228228
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${bclib_name} ${LIBOMPTARGET_LIBRARY_DIR}/${bclib_name})
229229

230230
# Install bitcode library under the lib destination folder.
231-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${bclib_name} DESTINATION "${OPENMP_INSTALL_LIBDIR}")
231+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${bclib_name} DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
232232

233233
set(target_feature "")
234234
if("${target_triple}" STREQUAL "nvptx64-nvidia-cuda")
@@ -307,4 +307,4 @@ set_target_properties(omptarget.devicertl PROPERTIES
307307
)
308308
target_link_libraries(omptarget.devicertl PRIVATE omptarget.devicertl.all_objs)
309309

310-
install(TARGETS omptarget.devicertl ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})
310+
install(TARGETS omptarget.devicertl ARCHIVE DESTINATION ${OFFLOAD_INSTALL_LIBDIR})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

openmp/libomptarget/plugins-nextgen/CMakeLists.txt renamed to offload/plugins-nextgen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
6565

6666
# Install plugin under the lib destination folder.
6767
install(TARGETS "omptarget.rtl.${tmachine_libname}"
68-
LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
68+
LIBRARY DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
6969
set_target_properties("omptarget.rtl.${tmachine_libname}" PROPERTIES
7070
INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
7171
POSITION_INDEPENDENT_CODE ON

openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt renamed to offload/plugins-nextgen/amdgpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ else()
120120
endif()
121121

122122
# Install plugin under the lib destination folder.
123-
install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
123+
install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
124124
set_target_properties(omptarget.rtl.amdgpu PROPERTIES
125125
INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
126126
CXX_VISIBILITY_PRESET protected)

openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt renamed to offload/plugins-nextgen/cuda/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ else()
8181
endif()
8282

8383
# Install plugin under the lib destination folder.
84-
install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
84+
install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
8585
set_target_properties(omptarget.rtl.cuda PROPERTIES
8686
INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
8787
CXX_VISIBILITY_PRESET protected)

openmp/libomptarget/src/CMakeLists.txt renamed to offload/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ set_target_properties(omptarget PROPERTIES
8585
POSITION_INDEPENDENT_CODE ON
8686
INSTALL_RPATH "$ORIGIN"
8787
BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
88-
install(TARGETS omptarget LIBRARY COMPONENT omptarget DESTINATION "${OPENMP_INSTALL_LIBDIR}")
88+
install(TARGETS omptarget LIBRARY COMPONENT omptarget DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)