diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -725,6 +725,7 @@ COMMAND ${test_cmd} COMMAND_EXPAND_LISTS COMMENT "Running hermetic test ${fq_target_name}" + ${LIBC_HERMETIC_TEST_JOB_POOL} ) add_dependencies(${HERMETIC_TEST_SUITE} ${fq_target_name}) diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake --- a/libc/cmake/modules/prepare_libc_gpu_build.cmake +++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake @@ -71,6 +71,16 @@ "build") 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 run in parallel 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) +endif() + set(LIBC_GPU_TEST_ARCHITECTURE "" CACHE STRING "Architecture for the GPU tests") set(gpu_test_architecture "")