From 1db6cd5d16a084bffbc319467d70942d0307cc9f Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Tue, 30 Mar 2021 21:03:50 +0200 Subject: Make -j flag less exceptional (#22360) * Make -j flag less exceptional The -j flag in spack behaves differently from make, ctest, ninja, etc, because it caps the number of jobs to an arbitrary number 16. Spack will behave like other tools if `spack install` uses a reasonable default, and `spack install -j ` *overrides* that default. This will be particularly useful for Spack usage outside of a traditional HPC context and for HPC centers that encourage users to compile on login nodes with many cores instead of on compute nodes, which has become increasingly common as individual nodes have more cores. This maintains the existing default value of min(num_cpus, 16). However, as it is right now, Spack does a poor job at determining the number of cpus on linux, since it doesn't take cgroups into account. This is particularly problematic when using distributed builds with slurm. This PR also introduces `spack.util.cpus.cpus_available()` to consolidate knowledge on determining the number of available cores, and improves core detection for linux. This should also improve core detection for Docker/ Kubernetes, which also use cgroups. --- etc/spack/defaults/config.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'etc') diff --git a/etc/spack/defaults/config.yaml b/etc/spack/defaults/config.yaml index 7f0b9276ba..61c23f42df 100644 --- a/etc/spack/defaults/config.yaml +++ b/etc/spack/defaults/config.yaml @@ -142,11 +142,13 @@ config: locks: true - # The maximum number of jobs to use when running `make` in parallel, - # always limited by the number of cores available. For instance: - # - If set to 16 on a 4 cores machine `spack install` will run `make -j4` - # - If set to 16 on a 18 cores machine `spack install` will run `make -j16` - # If not set, Spack will use all available cores up to 16. + # The maximum number of jobs to use for the build system (e.g. `make`), when + # the -j flag is not given on the command line. Defaults to 16 when not set. + # Note that the maximum number of jobs is limited by the number of cores + # available, taking thread affinity into account when supported. For instance: + # - With `build_jobs: 16` and 4 cores available `spack install` will run `make -j4` + # - With `build_jobs: 16` and 32 cores available `spack install` will run `make -j16` + # - With `build_jobs: 2` and 4 cores available `spack install -j6` will run `make -j6` # build_jobs: 16 -- cgit v1.2.3-70-g09d2