MAKEALL: Automatically use parallel builds
PATCH 1/1 MAKEALL: Automatically use parallel builds
Add logic to the MAKEALL script to determine the number of CPU cores on the system, and run a parallel build if there is more than one. Usually this significantrly accelerates builds.
Allow to manually adjust the number of parallel make jobs by using the "BUILD_NCPUS" environment variable.
--- MAKEALL | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
MAKEALL +10 -1
@@ -1,6 +1,15 @@ #!/bin/sh -: ${JOBS:=} +# Determine number of CPU cores if no default was set +: ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"} + +if [ "$BUILD_NCPUS" -gt 1 ] +then + JOBS=-j`expr "$BUILD_NCPUS" + 1` +else + JOBS="" +fi + if [ "${CROSS_COMPILE}" ] ; then MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
Signature · 1 line
1.5.6.5
PATCH 1/1 MAKEALL: Automatically use parallel builds
Quoted 17 lines · On Monday 08 December 2008 18:41:25 Wolfgang Denk wrote:
Add logic to the MAKEALL script to determine the number of CPU cores on the system, and run a parallel build if there is more than one. Usually this significantrly accelerates builds.
Allow to manually adjust the number of parallel make jobs by using the "
BUILD_NCPUS" environment variable.Signed-off-by Wolfgang Denk <[email protected]>--- MAKEALL | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)MAKEALL +0
-0
MAKEALL line 6
Quoted 7 lines
MAKEALL +4
-1@@ -1,6 +1,15 @@ #!/bin/sh -: ${JOBS:=} +# Determine number of CPU cores if no default was set +: ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"} + +if [ "$BUILD_NCPUS" -gt 1 ]
no point in quoting here ... if it isnt numeric, then -gt will fail, and all numeric values lack whitespace ...
MAKEALL line 11
Quoted 5 lines
MAKEALL +5
-0+then + JOBS=-j`expr "$BUILD_NCPUS" + 1` +else + JOBS="" +fi
i generally see the heuristic (cpus * 2) rather than (cpus + 1) ... benchmarks tend to favor that as well ...
but this is certainly better than previous behavior: always use -j1 ... -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20081209/f27dd735/attachment.pgp
PATCH 1/1 MAKEALL: Automatically use parallel builds
Dear Mike,
Quoted 9 lines · In message <[email protected]> you wrote:
MAKEALL line 6
Quoted 6 lines
-: ${JOBS:=}
MAKEALL +4
-0+# Determine number of CPU cores if no default was set +: ${BUILD_NCPUS:"`getconf _NPROCESSORS_ONLN`"} + +if [ "$BUILD_NCPUS" -gt 1 ]no point in quoting here ... if it isnt numeric, then -gt will fail, and all numeric values lack whitespace ...
You are wrong. This is defensive programming against invalid user input.
Assume the user runs
BUILD_NCPUS=' ' MAKEALL
...
Without the quoting, we get a "[: -gt: unary operator expected" error message; with the quotes we single process build as (probably) expected.
Quoted 8 lines
MAKEALL line 11
Quoted 5 lines
MAKEALL +5
-0+then + JOBS-j`expr "$BUILD_NCPUS" + 1` +else + JOBS"" +fii generally see the heuristic (cpus * 2) rather than (cpus + 1) ... benchmarks tend to favor that as well ...
This obviously depends onyour benchmarks. For U-Boot builds, all systems I've checked (with 512 MB or more of RAM) tend to have all required files in RAM, so the only I/O is writing the object files and binaries out - which is negligable. In other words, the system is nearly 100% CPU bound. In this case, (cpus + 1) seems more appropriate to me. But YMMV ...
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The software required `Windows 95 or better', so I installed Linux.