config: add a 'auto' value for the number of parallel jobs
authorMichael Hope <michael.hope@linaro.org>
Thu Sep 29 12:40:42 2011 +1300 (2011-09-29)
changeset 2695f2495884ca3e
parent 2694 2c01a02334ea
child 2696 5f7c6eed805d
config: add a 'auto' value for the number of parallel jobs

When CT_PARALLEL_JOBS is -1, set the number of parallel jobs to the
number of online CPUs + 1. Update documentation to match.

I find this useful when building in the cloud. You can use the same
.config file and have the build adapt to the number of processors
available. Limited testing shows that NCPUS+1 is faster than NCPUS+0
or NCPUS+2.

Signed-off-by: Michael Hope <michael.hope@linaro.org>
config/global/build-behave.in
scripts/crosstool-NG.sh.in
     1.1 --- a/config/global/build-behave.in	Thu Sep 29 12:27:54 2011 +1300
     1.2 +++ b/config/global/build-behave.in	Thu Sep 29 12:40:42 2011 +1300
     1.3 @@ -16,6 +16,8 @@
     1.4        
     1.5        Enter 1 (or 0) to have only one job at a time.
     1.6  
     1.7 +      Enter -1 to set automatically based on how many processors the host has.
     1.8 +
     1.9  config LOAD
    1.10      int
    1.11      prompt "Maximum allowed load" if ! BACKEND
     2.1 --- a/scripts/crosstool-NG.sh.in	Thu Sep 29 12:27:54 2011 +1300
     2.2 +++ b/scripts/crosstool-NG.sh.in	Thu Sep 29 12:40:42 2011 +1300
     2.3 @@ -488,7 +488,11 @@
     2.4  
     2.5      # And help make go faster
     2.6      JOBSFLAGS=
     2.7 -    [ ${CT_PARALLEL_JOBS} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
     2.8 +    # Use the number of processors+1 when automatically setting the number of
     2.9 +    # parallel jobs.  Fall back to 1 if the host doesn't use GLIBC.
    2.10 +    AUTO_JOBS=$((`getconf _NPROCESSORS_ONLN 2> /dev/null || echo 0` + 1))
    2.11 +    [ ${CT_PARALLEL_JOBS} -eq -1 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}"
    2.12 +    [ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
    2.13      [ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}"
    2.14  
    2.15      # We need to save the real .config with kconfig's value,