Patrick Georgi ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/409

-gerrit

commit 991d0403fc05ab37d61078d98a6edd9245137c54
Author: Patrick Georgi <[email protected]>
Date:   Sat Nov 5 14:44:41 2011 +0100

    abuild: Build boards in parallel if possible
    
    Determine if xargs -P works. If yes, use that to build multiple
    boards in parallel, instead of relying on make -j X, when doing
    a full abuild run (instead of single boards).
    
    make -j X isn't able to make use of several cores at various
    serialization points in our build process, so this change results
    in a >25% speed up for a full abuild run in my tests.
    
    Change-Id: Id484a4211c84a3a24115278e0fbe92345f346596
    Signed-off-by: Patrick Georgi <[email protected]>
---
 util/abuild/abuild |   49 ++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/util/abuild/abuild b/util/abuild/abuild
index 8b81ea1..5228cdb 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -583,6 +583,9 @@ test -f util/sconfig/sconfig.l && ROOT=$( pwd )
 test -f ../util/sconfig/sconfig.l && ROOT=$( cd ..; pwd )
 test "$ROOT" = "" && ROOT=$( cd ../..; pwd )
 
+# command line for xargs parallelization. Thus overwrite -c X
+cmdline="$* -c 1"
+
 # parse parameters.. try to find out whether we're running GNU getopt
 getoptbrand="`getopt -V`"
 if [ "${getoptbrand:0:6}" == "getopt" ]; then
@@ -628,8 +631,43 @@ while true ; do
        esac
 done
 
+USE_XARGS=0
 if [ "$cpus" != "1" ]; then
-       export MAKEFLAGS="-j $cpus"
+       if [ "$target" = "" ]; then
+               # Test if xargs supports the non-standard -P flag
+               echo | xargs -P 0$cpus -n 1 echo 2>/dev/null >/dev/null && 
USE_XARGS=1
+       fi
+fi
+
+if [ "$USE_XARGS" = "0" ]; then
+export MAKEFLAGS="-j $cpus"
+build_all_targets()
+{
+       for VENDOR in $( vendors ); do
+               for MAINBOARD in $( mainboards $VENDOR ); do
+                       build_target $VENDOR $MAINBOARD
+                       test_target $VENDOR $MAINBOARD
+                       remove_target $VENDOR $MAINBOARD
+               done
+       done
+}
+else
+# Limit to 32 parallel builds for now.
+# Thrashing all caches because we run
+# 160 abuilds in parallel is no fun.
+if [ "$cpus" = "" ]; then
+       cpus=32
+fi
+build_all_targets()
+{
+       # seed shared utils
+       MAKEFLAGS="-j $cpus" $0 $cmdline -t emulation/qemu-x86
+       for VENDOR in $( vendors ); do
+               for MAINBOARD in $( mainboards $VENDOR ); do
+                       echo $VENDOR/$MAINBOARD
+               done
+       done | xargs -P 0$cpus -n 1 $0 $cmdline -t
+}
 fi
 
 # /path/to/freebios2/
@@ -659,14 +697,7 @@ if [ "$target" != "" ]; then
        cat $TARGET/${VENDOR}_${MAINBOARD}/abuild.xml >> $REAL_XMLFILE
        XMLFILE=$REAL_XMLFILE
 else
-       # build all boards per default
-       for VENDOR in $( vendors ); do
-               for MAINBOARD in $( mainboards $VENDOR ); do
-                       build_target $VENDOR $MAINBOARD
-                       test_target $VENDOR $MAINBOARD
-                       remove_target $VENDOR $MAINBOARD
-               done
-       done
+       build_all_targets
        for xmlfile in $TARGET/*_*/abuild.xml; do
                cat $xmlfile >> $REAL_XMLFILE
        done

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to