help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is Parallel Execution Safe?


From: Paul D. Smith
Subject: Re: Is Parallel Execution Safe?
Date: Tue, 22 Mar 2005 09:12:02 -0500

%% "Mathew Koshy " <address@hidden> writes:

  mk> I would like to know how efficient is -j option for large projects
  mk> and is it enough to specify -j option in the top level makefile?

If you have >1 CPU (and an SMP OS), -j can provide a lot of build speed
improvements.  If you have only 1 CPU, you will get a bit of improvement
with -j2 (especially if you are building on a networked filesystem
rather than a local disk) but anything higher than that is not going to
buy you much, and could actually slow down your build.

Various make options, including -j, are automatically passed down to all
sub-makes (as long as you don't break this by resetting MAKEFLAGS or
using "make" instead of "$(MAKE)" when invoking the sub-make, etc.)

  mk> i.e does GNU Make parses all makefile in a project before
  mk> beginning to build targets so that it knows the full dependency
  mk> graph

GNU make with -j behaves EXACTLY as GNU make without -j does, except
that wherever possible it will invoke multiple commands.

If your makefiles are written to parse all the makefiles in a project
before beginning to build targets, then that is what make will do,
whether you give -j or not.  If your makefiles are written to
recursively invoke make in subdirectories, then that is what make will
do, whether you give -j or not.

  mk> and can do parallel builds *safely* with the "-j" flag?

Builds with -j are exactly as safe as your makefiles are correct.  If
you've declared all the prerequisite relationships properly, then
parallel builds are very safe.  If you've not done that and instead are
relying on the order in which prerequisites are listed to provide an
"implicit prerequisite" relationship, then that won't work with -j.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]