CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
85 lines
3.7 KiB
CMake
85 lines
3.7 KiB
CMake
if(NOT LIBC_TARGET_OS_IS_GPU)
|
|
message(FATAL_ERROR
|
|
"libc build: Invalid attempt to set up GPU architectures.")
|
|
endif()
|
|
|
|
# Ensure the compiler is a valid clang when building the GPU target.
|
|
set(req_ver "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
|
|
if(LLVM_VERSION_MAJOR AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" AND
|
|
${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "${req_ver}"))
|
|
message(WARNING "libc for GPU requires an up-to-date clang. CMake compiler "
|
|
"'${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}' "
|
|
" is not 'Clang ${req_ver}'.")
|
|
endif()
|
|
if(NOT LLVM_LIBC_FULL_BUILD)
|
|
message(FATAL_ERROR "LLVM_LIBC_FULL_BUILD must be enabled to build libc for "
|
|
"GPU.")
|
|
endif()
|
|
|
|
# Set the required flags globally so standard CMake utilities can compile.
|
|
if(NOT CMAKE_CXX_COMPILER_TARGET)
|
|
set(CMAKE_REQUIRED_FLAGS "${LIBC_COMPILE_OPTIONS_DEFAULT}")
|
|
endif()
|
|
|
|
# Optionally set up a job pool to limit the number of GPU tests run in parallel.
|
|
# This is sometimes necessary as running too many tests in parallel can cause
|
|
# the GPU or driver to run out of resources.
|
|
set(LIBC_GPU_TEST_JOBS "" CACHE STRING "Number of jobs to use for GPU tests")
|
|
if(LIBC_GPU_TEST_JOBS)
|
|
set_property(GLOBAL PROPERTY JOB_POOLS LIBC_GPU_TEST_POOL=${LIBC_GPU_TEST_JOBS})
|
|
set(LIBC_HERMETIC_TEST_JOB_POOL JOB_POOL LIBC_GPU_TEST_POOL)
|
|
else()
|
|
set(LIBC_GPU_TEST_JOBS 1)
|
|
set_property(GLOBAL PROPERTY JOB_POOLS LIBC_GPU_TEST_POOL=1)
|
|
set(LIBC_HERMETIC_TEST_JOB_POOL JOB_POOL LIBC_GPU_TEST_POOL)
|
|
endif()
|
|
|
|
set(LIBC_GPU_TEST_ARCHITECTURE "" CACHE STRING "Architecture for the GPU tests")
|
|
if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
|
|
check_cxx_compiler_flag(-mcpu=native PLATFORM_HAS_GPU)
|
|
elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
|
|
check_cxx_compiler_flag(-march=native PLATFORM_HAS_GPU)
|
|
endif()
|
|
|
|
set(gpu_test_architecture "")
|
|
if(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU
|
|
AND NOT "AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
set(LIBC_GPU_TESTS_DISABLED TRUE)
|
|
message(STATUS "AMDGPU backend is not available, tests will not be built")
|
|
elseif(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_NVPTX
|
|
AND NOT "NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
set(LIBC_GPU_TESTS_DISABLED TRUE)
|
|
message(STATUS "NVPTX backend is not available, tests will not be built")
|
|
elseif(LIBC_GPU_TEST_ARCHITECTURE)
|
|
set(LIBC_GPU_TESTS_DISABLED FALSE)
|
|
set(gpu_test_architecture ${LIBC_GPU_TEST_ARCHITECTURE})
|
|
message(STATUS "Using user-specified GPU architecture for testing: "
|
|
"'${gpu_test_architecture}'")
|
|
elseif(PLATFORM_HAS_GPU)
|
|
set(LIBC_GPU_TESTS_DISABLED FALSE)
|
|
set(gpu_test_architecture "native")
|
|
message(STATUS "Using GPU architecture detected on the system for testing: "
|
|
"'native'")
|
|
else()
|
|
set(LIBC_GPU_TESTS_DISABLED TRUE)
|
|
message(STATUS "No GPU architecture detected or provided, tests will not be "
|
|
"built")
|
|
endif()
|
|
set(LIBC_GPU_TARGET_ARCHITECTURE "${gpu_test_architecture}")
|
|
|
|
# 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.
|
|
set(LIBC_GPU_CODE_OBJECT_VERSION "6" CACHE STRING "AMDGPU Code object ABI to use")
|
|
|
|
if(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
|
|
# FIXME: This is a hack required to keep the CUDA package from trying to find
|
|
# pthreads. We only link the CUDA driver, so this is unneeded.
|
|
add_library(CUDA::cudart_static_deps IMPORTED INTERFACE)
|
|
|
|
find_package(CUDAToolkit QUIET)
|
|
if(CUDAToolkit_FOUND)
|
|
get_filename_component(LIBC_CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE)
|
|
endif()
|
|
endif()
|