From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25926 invoked by alias); 28 Sep 2011 23:42:09 -0000 Received: (qmail 25917 invoked by uid 22791); 28 Sep 2011 23:42:08 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from snapmx1.ironport.snap.net.nz (HELO snapmx1.ironport.snap.net.nz) (202.37.100.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Sep 2011 23:41:41 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAK+vg057/y/M/2dsb2JhbABCqAeCTT8/PBUfThO/eIcMBJh3jCk Received: from rupert.snap.net.nz ([202.37.100.140]) by smtp1.ironport.snap.net.nz with ESMTP; 29 Sep 2011 12:41:40 +1300 X-Sender-IP: 123.255.47.204 X-Sender-IP: 123.255.47.204 Received: from [127.0.1.1] (204.47.255.123.static.snap.net.nz [123.255.47.204]) by rupert.snap.net.nz (Postfix) with ESMTPS id DDE75255B9; Thu, 29 Sep 2011 12:41:39 +1300 (NZDT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PATCH] Add a 'auto' value for the number of parallel jobs X-Mercurial-Node: 69e6e581338dc4558d87fdcde9d9cbf8466893c9 Message-Id: <69e6e581338dc4558d87.1317253299@crucis> User-Agent: Mercurial-patchbomb/1.4.3 Date: Wed, 28 Sep 2011 23:42:00 -0000 From: Michael Hope To: "Yann E. MORIN" Cc: crossgcc@sourceware.org X-IsSubscribed: yes Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00050.txt.bz2 # HG changeset patch # User Michael Hope # Date 1317253242 -46800 # Node ID 69e6e581338dc4558d87fdcde9d9cbf8466893c9 # Parent 780d29fbc4c574ded2248f55e77dd7cb1540aea4 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 diff -r 780d29fbc4c5 -r 69e6e581338d config/global/build-behave.in --- a/config/global/build-behave.in Thu Sep 29 12:27:54 2011 +1300 +++ b/config/global/build-behave.in Thu Sep 29 12:40:42 2011 +1300 @@ -16,6 +16,8 @@ Enter 1 (or 0) to have only one job at a time. + Enter -1 to set automatically based on how many processors the host has. + config LOAD int prompt "Maximum allowed load" if ! BACKEND diff -r 780d29fbc4c5 -r 69e6e581338d scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Thu Sep 29 12:27:54 2011 +1300 +++ b/scripts/crosstool-NG.sh.in Thu Sep 29 12:40:42 2011 +1300 @@ -488,7 +488,11 @@ # And help make go faster JOBSFLAGS= - [ ${CT_PARALLEL_JOBS} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" + # Use the number of processors+1 when automatically setting the number of + # parallel jobs. Fall back to 1 if the host doesn't use GLIBC. + AUTO_JOBS=$((`getconf _NPROCESSORS_ONLN 2> /dev/null || echo 0` + 1)) + [ ${CT_PARALLEL_JOBS} -eq -1 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}" + [ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" [ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}" # We need to save the real .config with kconfig's value, -- For unsubscribe information see http://sourceware.org/lists.html#faq