[libc-commits] [libc] 27f3263 - [libc] Add an option to use a job pool for GPU tests

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Jun 16 12:06:23 PDT 2023


Author: Joseph Huber
Date: 2023-06-16T14:06:16-05:00
New Revision: 27f326334f35183fcb716cdd1f104f8d168b8505

URL: https://github.com/llvm/llvm-project/commit/27f326334f35183fcb716cdd1f104f8d168b8505
DIFF: https://github.com/llvm/llvm-project/commit/27f326334f35183fcb716cdd1f104f8d168b8505.diff

LOG: [libc] Add an option to use a job pool for GPU tests

Currently the GPU has restrictions on how many tests can be run in
parallel due to resource constraints. However, building these tests can
take a long time so we want to be able to build them in parallel. This
patch introduces the option `LIBC_GPU_TEST_JOBS` which is set to the
number of threads to run in parallel.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D153157

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCTestRules.cmake
    libc/cmake/modules/prepare_libc_gpu_build.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 9b850b963f12f..803d5854dae05 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -725,6 +725,7 @@ function(add_libc_hermetic_test test_name)
     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
index 79afa383b00e3..29e54cd03a105 100644
--- a/libc/cmake/modules/prepare_libc_gpu_build.cmake
+++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -71,6 +71,16 @@ if(NOT LIBC_CLANG_OFFLOAD_PACKAGER)
                       "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 "")


        


More information about the libc-commits mailing list