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

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 5 04:06: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)
----------------
jusito wrote:

Sure I can change it, is `jobs_with_sufficient_memory` fine for you ?
`max_parallelism` would seem imprecise, I would expect `max_parallelism` to be equal to `LLVM_PARALLEL_COMPILE_JOBS` so the result of last branch. Same for `possible_threads`, even `possible_jobs` because all around is talked about jobs.

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


More information about the llvm-commits mailing list