Skip to content

[19.x] Backport standalone build fixes for offload #118643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions offload/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ include(LibomptargetGetDependencies)
# Set up testing infrastructure.
include(OpenMPTesting)

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Werror=global-constructors OFFLOAD_HAVE_WERROR_CTOR)

# LLVM source tree is required at build time for libomptarget
Expand Down Expand Up @@ -282,6 +283,26 @@ if(OPENMP_STANDALONE_BUILD)
${LLVM_LIBRARY_DIRS}
REQUIRED
)

find_path (
LIBOMP_INCLUDE_DIR
NAMES
omp.h
HINTS
${COMPILER_RESOURCE_DIR}/include
${CMAKE_INSTALL_PREFIX}/include
)

get_filename_component(LIBOMP_LIBRARY_DIR ${LIBOMP_STANDALONE} DIRECTORY)

set(OPENMP_TEST_FLAGS "" CACHE STRING
"Extra compiler flags to send to the test compiler.")
set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMP_INCLUDE_DIR}" CACHE STRING
"Path to folder containing omp.h")
set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${LIBOMP_LIBRARY_DIR}" CACHE STRING
"Path to folder containing libomp.so, and libLLVMSupport.so with profiling enabled")
endif()

macro(pythonize_bool var)
Expand Down
2 changes: 1 addition & 1 deletion offload/cmake/OpenMPTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if (${OPENMP_STANDALONE_BUILD})
# project is built which is too late for detecting the compiler...
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DetectTestCompiler)
execute_process(
COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${CMAKE_CURRENT_LIST_DIR}/DetectTestCompiler
COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${CMAKE_CURRENT_SOURCE_DIR}/../openmp/cmake/DetectTestCompiler
-DCMAKE_C_COMPILER=${OPENMP_TEST_C_COMPILER}
-DCMAKE_CXX_COMPILER=${OPENMP_TEST_CXX_COMPILER}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DetectTestCompiler
Expand Down
16 changes: 9 additions & 7 deletions offload/plugins-nextgen/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ add_dependencies(PluginCommon intrinsics_gen)

# Only enable JIT for those targets that LLVM can support.
set(supported_jit_targets AMDGPU NVPTX)
foreach(target IN LISTS supported_jit_targets)
if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${target}")
llvm_map_components_to_libnames(llvm_libs ${target})
target_link_libraries(PluginCommon PRIVATE ${llvm_libs})
endif()
endforeach()
if (NOT LLVM_LINK_LLVM_DYLIB)
foreach(target IN LISTS supported_jit_targets)
if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${target}")
llvm_map_components_to_libnames(llvm_libs ${target})
target_link_libraries(PluginCommon PRIVATE ${llvm_libs})
endif()
endforeach()
endif()

# Include the RPC server from the `libc` project if availible.
if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT})
Expand Down
11 changes: 8 additions & 3 deletions offload/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ if(CUDAToolkit_FOUND)
get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
endif()

set(OMP_DEPEND)
if(TARGET omp)
set(OMP_DEPEND omp)
endif()

string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}")
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)

add_offload_testsuite(check-libomptarget-${CURRENT_TARGET}
"Running libomptarget tests"
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
list(APPEND LIBOMPTARGET_LIT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET})

Expand All @@ -43,12 +48,12 @@ add_offload_testsuite(check-libomptarget
"Running libomptarget tests"
${LIBOMPTARGET_LIT_TESTSUITES}
EXCLUDE_FROM_CHECK_ALL
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})

add_offload_testsuite(check-offload
"Running libomptarget tests"
${LIBOMPTARGET_LIT_TESTSUITES}
EXCLUDE_FROM_CHECK_ALL
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
Loading