mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-07 19:03:57 +00:00
[Libomptarget] Only build GPU tests if a GPU is found on the system
Currently we build tests as long as the libraries are found on the machine. This doesn't necessarily mean there is a GPU to use though. This patch changes it to where we only will build the tests if we found a compatible GPU via `nvptx-arch` or `amdgpu-arch`. The only downside to this I could see if someone were to build LLVM on a home node of a cluster and then wished to run the tests after switching to a compute node. For this I think we should allow it to be overridden. I think that's better than allowing us to run tests that will fail by default. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D142018
This commit is contained in:
parent
f8bed13694
commit
ea0eee80d8
@ -118,6 +118,7 @@ if(LIBOMPTARGET_NVPTX_ARCH)
|
||||
string(SUBSTRING "${LIBOMPTARGET_NVPTX_ARCH_OUTPUT}" 0 ${first_arch_string}
|
||||
arch_string)
|
||||
if(arch_string)
|
||||
set(LIBOMPTARGET_FOUND_NVIDIA_GPU TRUE)
|
||||
set(LIBOMPTARGET_DEP_CUDA_ARCH "${arch_string}")
|
||||
endif()
|
||||
endif()
|
||||
@ -158,6 +159,25 @@ find_package_handle_standard_args(
|
||||
|
||||
mark_as_advanced(LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES)
|
||||
|
||||
################################################################################
|
||||
# Looking for AMD GPUs...
|
||||
################################################################################
|
||||
|
||||
find_program(LIBOMPTARGET_AMDGPU_ARCH NAMES amdgpu-arch PATHS ${LLVM_BINARY_DIR}/bin)
|
||||
if(LIBOMPTARGET_AMDGPU_ARCH)
|
||||
execute_process(COMMAND ${LIBOMPTARGET_AMDGPU_ARCH}
|
||||
OUTPUT_VARIABLE LIBOMPTARGET_AMDGPU_ARCH_OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(FIND "${LIBOMPTARGET_AMDGPU_ARCH_OUTPUT}" "\n" first_arch_string)
|
||||
string(SUBSTRING "${LIBOMPTARGET_AMDGPU_ARCH_OUTPUT}" 0 ${first_arch_string}
|
||||
arch_string)
|
||||
if(arch_string)
|
||||
set(LIBOMPTARGET_FOUND_AMDGPU_GPU TRUE)
|
||||
set(LIBOMPTARGET_DEP_AMDGPU_ARCH "${arch_string}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
# Looking for VEO...
|
||||
################################################################################
|
||||
|
@ -111,7 +111,8 @@ set_target_properties(omptarget.rtl.amdgpu PROPERTIES
|
||||
# This controls whether tests are run for the nvptx offloading target
|
||||
# Run them if libhsa is available, or if the user explicitly asked for dlopen
|
||||
# Otherwise this plugin is being built speculatively and there may be no hsa available
|
||||
if (${hsa-runtime64_FOUND} OR LIBOMPTARGET_FORCE_DLOPEN_LIBHSA)
|
||||
option(LIBOMPTARGET_FORCE_AMDGPU_TESTS "Build AMDGPU libomptarget tests" OFF)
|
||||
if (LIBOMPTARGET_FOUND_AMDGPU_GPU OR LIBOMPTARGET_FORCE_AMDGPU_TESTS)
|
||||
# Report to the parent scope that we are building a plugin for amdgpu
|
||||
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa amdgcn-amd-amdhsa-oldDriver" PARENT_SCOPE)
|
||||
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa amdgcn-amd-amdhsa-LTO" PARENT_SCOPE)
|
||||
|
@ -98,7 +98,8 @@ target_include_directories(omptarget.rtl.cuda PRIVATE
|
||||
# This controls whether tests are run for the nvptx offloading target
|
||||
# Run them if libcuda is available, or if the user explicitly asked for dlopen
|
||||
# Otherwise this plugin is being built speculatively and there may be no cuda available
|
||||
if (LIBOMPTARGET_CAN_LINK_LIBCUDA OR LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
|
||||
option(LIBOMPTARGET_FORCE_NVIDIA_TESTS "Build NVIDIA libomptarget tests" OFF)
|
||||
if (LIBOMPTARGET_FOUND_NVIDIA_GPU OR LIBOMPTARGET_FORCE_NVIDIA_TESTS)
|
||||
libomptarget_say("Enable tests using CUDA plugin")
|
||||
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda nvptx64-nvidia-cuda-oldDriver" PARENT_SCOPE)
|
||||
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda nvptx64-nvidia-cuda-LTO" PARENT_SCOPE)
|
||||
|
Loading…
Reference in New Issue
Block a user