diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake --- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake @@ -118,6 +118,7 @@ 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 @@ 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... ################################################################################ diff --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt --- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt +++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt @@ -111,7 +111,8 @@ # 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) diff --git a/openmp/libomptarget/plugins/cuda/CMakeLists.txt b/openmp/libomptarget/plugins/cuda/CMakeLists.txt --- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt +++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt @@ -98,7 +98,8 @@ # 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)