[libc] Use CMAKE_CROSSCOMPILING_EMULATOR instead searching for `llvm-gpu-loader' (#189417)
Summary: We already handle this with other targets, we should be able to unify the handling here.
This commit is contained in:
parent
11d65dc8c2
commit
1484e0f16a
@ -34,7 +34,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions("-D_DEBUG")
|
||||
endif()
|
||||
|
||||
|
||||
# Default to C++17
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
|
||||
@ -643,12 +643,6 @@ function(add_integration_test test_name)
|
||||
libc.test.IntegrationTest.test
|
||||
${INTEGRATION_TEST_DEPENDS})
|
||||
|
||||
# Tests on the GPU require an external loader utility to launch the kernel.
|
||||
if(TARGET libc.utils.gpu.loader)
|
||||
add_dependencies(${fq_build_target_name} libc.utils.gpu.loader)
|
||||
get_target_property(gpu_loader_exe libc.utils.gpu.loader "EXECUTABLE")
|
||||
endif()
|
||||
|
||||
# We have to use a separate var to store the command as a list because
|
||||
# the COMMAND option of `add_custom_target` cannot handle empty vars in the
|
||||
# command. For example, if INTEGRATION_TEST_ENV is empty, the actual
|
||||
@ -658,7 +652,6 @@ function(add_integration_test test_name)
|
||||
set(test_cmd
|
||||
${INTEGRATION_TEST_ENV}
|
||||
$<$<BOOL:${LIBC_TARGET_ARCHITECTURE_IS_NVPTX}>:LIBOMPTARGET_STACK_SIZE=3072>
|
||||
$<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}>
|
||||
${CMAKE_CROSSCOMPILING_EMULATOR}
|
||||
${INTEGRATION_TEST_LOADER_ARGS}
|
||||
$<TARGET_FILE:${fq_build_target_name}> ${INTEGRATION_TEST_ARGS})
|
||||
@ -896,12 +889,6 @@ function(add_libc_hermetic test_name)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Tests on the GPU require an external loader utility to launch the kernel.
|
||||
if(TARGET libc.utils.gpu.loader)
|
||||
add_dependencies(${fq_build_target_name} libc.utils.gpu.loader)
|
||||
get_target_property(gpu_loader_exe libc.utils.gpu.loader "EXECUTABLE")
|
||||
endif()
|
||||
|
||||
if(NOT HERMETIC_TEST_NO_RUN_POSTBUILD)
|
||||
if (LIBC_TEST_CMD)
|
||||
# In the form of "<command> binary=@BINARY@", e.g. "qemu-system-arm -loader$<COMMA>file=@BINARY@"
|
||||
@ -910,7 +897,7 @@ function(add_libc_hermetic test_name)
|
||||
else()
|
||||
set(test_cmd ${HERMETIC_TEST_ENV}
|
||||
$<$<BOOL:${LIBC_TARGET_ARCHITECTURE_IS_NVPTX}>:LIBOMPTARGET_STACK_SIZE=3072>
|
||||
$<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${HERMETIC_TEST_LOADER_ARGS}
|
||||
${CMAKE_CROSSCOMPILING_EMULATOR} ${HERMETIC_TEST_LOADER_ARGS}
|
||||
$<TARGET_FILE:${fq_build_target_name}> ${HERMETIC_TEST_ARGS})
|
||||
endif()
|
||||
|
||||
|
||||
@ -66,24 +66,6 @@ else()
|
||||
endif()
|
||||
set(LIBC_GPU_TARGET_ARCHITECTURE "${gpu_test_architecture}")
|
||||
|
||||
# Identify the GPU loader utility used to run tests.
|
||||
set(LIBC_GPU_LOADER_EXECUTABLE "" CACHE STRING "Executable for the GPU loader.")
|
||||
if(LIBC_GPU_LOADER_EXECUTABLE)
|
||||
set(gpu_loader_executable ${LIBC_GPU_LOADER_EXECUTABLE})
|
||||
else()
|
||||
find_program(gpu_loader_executable
|
||||
NAMES llvm-gpu-loader NO_DEFAULT_PATH
|
||||
PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path})
|
||||
endif()
|
||||
if(NOT TARGET libc.utils.gpu.loader AND gpu_loader_executable)
|
||||
add_custom_target(libc.utils.gpu.loader)
|
||||
set_target_properties(
|
||||
libc.utils.gpu.loader
|
||||
PROPERTIES
|
||||
EXECUTABLE "${gpu_loader_executable}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# The AMDGPU environment uses different code objects to encode the ABI for
|
||||
# kernel calls and intrinsic functions. We want to expose this to conform to
|
||||
# whatever the test suite was built to handle.
|
||||
|
||||
@ -195,6 +195,7 @@ standard runtime build.
|
||||
commonly run out of resources if this is not constrained so it is recommended
|
||||
to keep it low. The default value is a single thread.
|
||||
|
||||
**LIBC_GPU_LOADER_EXECUTABLE**:STRING
|
||||
Overrides the default loader used for running GPU tests. If this is not
|
||||
provided the standard one will be built.
|
||||
**CMAKE_CROSSCOMPILING_EMULATOR**:STRING
|
||||
Overrides the default loader used for running GPU tests. This is set
|
||||
automatically to ``llvm-gpu-loader`` for GPU runtime targets when building
|
||||
via the runtimes build.
|
||||
|
||||
@ -94,7 +94,7 @@ Running tests
|
||||
|
||||
Tests will only be built and run if a GPU target architecture is set and the
|
||||
corresponding loader utility was built. These can be overridden with the
|
||||
``LIBC_GPU_TEST_ARCHITECTURE`` and ``LIBC_GPU_LOADER_EXECUTABLE`` :ref:`CMake
|
||||
``LIBC_GPU_TEST_ARCHITECTURE`` and ``CMAKE_CROSSCOMPILING_EMULATOR`` :ref:`CMake
|
||||
options <gpu_cmake_options>`. Once built, they can be run like any other tests.
|
||||
The CMake target depends on how the library was built.
|
||||
|
||||
|
||||
@ -16,11 +16,6 @@ add_custom_target(libc-hermetic-tests-build)
|
||||
add_custom_target(libc-integration-tests-build)
|
||||
add_custom_target(libc_include_tests-build)
|
||||
|
||||
# Resolve the GPU loader executable path for the lit site config.
|
||||
if(TARGET libc.utils.gpu.loader)
|
||||
get_target_property(LIBC_GPU_LOADER_EXECUTABLE libc.utils.gpu.loader "EXECUTABLE")
|
||||
endif()
|
||||
|
||||
# Configure the site config file for lit
|
||||
configure_lit_site_cfg(
|
||||
${LIBC_SOURCE_DIR}/test/lit.site.cfg.py.in
|
||||
@ -34,7 +29,7 @@ configure_lit_site_cfg(
|
||||
"LLVM_LIBS_DIR"
|
||||
"LIBC_SOURCE_DIR"
|
||||
"LIBC_BUILD_DIR"
|
||||
"LIBC_GPU_LOADER_EXECUTABLE"
|
||||
"CMAKE_CROSSCOMPILING_EMULATOR"
|
||||
)
|
||||
|
||||
add_lit_testsuite(check-libc-lit
|
||||
@ -46,8 +41,8 @@ add_lit_testsuite(check-libc-lit
|
||||
add_subdirectory(UnitTest)
|
||||
|
||||
if(LIBC_TARGET_OS_IS_GPU)
|
||||
if(NOT TARGET libc.utils.gpu.loader)
|
||||
message(WARNING "Cannot build libc GPU tests, missing loader.")
|
||||
if(NOT CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
message(WARNING "Cannot build libc GPU tests, set CMAKE_CROSS_COMPILING_EMULATOR.")
|
||||
return()
|
||||
elseif(LIBC_GPU_TESTS_DISABLED)
|
||||
message(WARNING "Cannot build libc GPU tests, missing target architecture.")
|
||||
|
||||
@ -8,11 +8,11 @@ config.llvm_tools_dir = lit_config.substitute(path(r"@LLVM_TOOLS_DIR@"))
|
||||
config.libc_src_root = path(r"@LIBC_SOURCE_DIR@")
|
||||
config.libc_obj_root = path(r"@LIBC_BUILD_DIR@")
|
||||
config.libc_test_cmd = "@LIBC_TEST_CMD@"
|
||||
config.libc_gpu_loader = path(r"@LIBC_GPU_LOADER_EXECUTABLE@")
|
||||
config.libc_crosscompiling_emulator = path(r"@CMAKE_CROSSCOMPILING_EMULATOR@")
|
||||
|
||||
# If running GPU tests and no explicit test command is set, use the GPU loader.
|
||||
if not config.libc_test_cmd and config.libc_gpu_loader:
|
||||
config.libc_test_cmd = config.libc_gpu_loader + " @BINARY@"
|
||||
# If no explicit test command is set, use the cross-compiling emulator.
|
||||
if not config.libc_test_cmd and config.libc_crosscompiling_emulator:
|
||||
config.libc_test_cmd = config.libc_crosscompiling_emulator + " @BINARY@"
|
||||
|
||||
# Add libc's utils directory to the path so we can import the test format.
|
||||
site.addsitedir(os.path.join(config.libc_src_root, "utils"))
|
||||
|
||||
@ -591,6 +591,12 @@ if(build_runtimes)
|
||||
endforeach()
|
||||
endif()
|
||||
if(LLVM_LIBC_GPU_BUILD)
|
||||
set(_gpu_loader "${LLVM_TOOLS_BINARY_DIR}/llvm-gpu-loader${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
foreach(name ${LLVM_RUNTIME_TARGETS})
|
||||
if(name MATCHES "^(amdgcn|nvptx)")
|
||||
set(RUNTIMES_${name}_CMAKE_CROSSCOMPILING_EMULATOR "${_gpu_loader}" CACHE STRING "")
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND extra_cmake_args "-DLLVM_LIBC_GPU_BUILD=ON")
|
||||
if(TARGET llvm-offload-binary)
|
||||
list(APPEND extra_deps llvm-offload-binary)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user