help-make
[Top][All Lists]
Advanced

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

Re: looking for build order doc in parallel build


From: Paul Smith
Subject: Re: looking for build order doc in parallel build
Date: Thu, 19 Nov 2009 01:17:43 -0500

On Thu, 2009-11-19 at 13:04 +0900, Yasushi SHOJI wrote:
>         all: 1.pdf 2.pdf 3.pdf
>                 @echo Making $@
>         
>         %.pdf: %.fo
>                 touch $@
>         
>         %.fo:
>                 touch $@

> see that with "-j1", the order is interleaved. but with "-j2", all fo
> is created first and then pdf.  it does not seems to matter if I
> increase either a number of pdf (say 1 to 10.pdf) or -j10.  except
> -j1,

Well, -j1 (run one job at a time) is exactly the same thing as not
providing any -j option at all: it results in no parallelism.

The exact results you got are surprising, just from a timing point of
view, but the general idea is not at all surprising.

Without -j, make will always build exactly one target at a time.  In
this case, the first target is "all", which depends on "1.pdf", which
depends on "1.fo", so make builds 1.fo then 1.pdf, then it goes on to
the next prerequisite of "all" which is 2.pdf and depends on 2.fo, so
make then builds 2.fo then 2.pdf, etc.  Finally, it builds "all".

If you enable parallelism, then make will try to build that many jobs AT
THE SAME TIME (that's what parallelism is).

In this case, make sees that all depends on 1.pdf which depends on 1.fo,
so it builds 1.fo.  Then it sees that it still has room to build more
things (due to parallelism).  It can't build 1.pdf yet, because 1.fo is
not done and 1.pdf depends on 1.fo, so it looks at the next prerequisite
of all which is 2.pdf, and that depends on 2.fo, and that doesn't depend
on 1.fo so make knows they can be built in parallel, and it does so.
Same things happens with 3.pdf and 3.fo: now make has built 1.fo, 2.fo,
and 3.fo in parallel.

Then 1.fo finishes, so make kicks off 1.pdf.  Then 2.fo finishes, so
make kicks off 2.pdf, and then 3.pdf.  Finally it builds "all".

So, everything is just as it should be.

You ask:

> so, what I am missing? is there implicit rule I have to take care?

But so far as I can see your makefile is fine and make is building
everything just fine.  If there is a problem here, you haven't described
what it is.  If you describe the behavior you're seeing that you don't
like, we can help you figure out what you need to do in your makefile to
fix it.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "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]