[llvm] [cmake] Option to create Ninja job pools depending on available resources (PR #65274)

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 5 07:42:48 PDT 2023


================
@@ -36,6 +36,21 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
 # The following only works with the Ninja generator in CMake >= 3.0.
 set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
   "Define the maximum number of concurrent compilation jobs (Ninja only).")
+if(LLVM_RAM_PER_COMPILE_JOB OR LLVM_RAM_PER_LINK_JOB)
+  cmake_host_system_information(RESULT available_physical_memory QUERY AVAILABLE_PHYSICAL_MEMORY)
+  cmake_host_system_information(RESULT number_of_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
+endif()
+if(LLVM_RAM_PER_COMPILE_JOB)
+  math(EXPR memory_available_jobs "${available_physical_memory} / ${LLVM_RAM_PER_COMPILE_JOB}" OUTPUT_FORMAT DECIMAL)
----------------
compnerd wrote:

Sure, `jobs_with_sufficient_memory` should be fine.

https://github.com/llvm/llvm-project/pull/65274


More information about the llvm-commits mailing list