Ticket #711 (accepted bug)

Opened 4 months ago

Last modified 3 weeks ago

Parallel builds in MPICH2

Reported by: Joe Ratterman <jratt0@…> Owned by: goodell
Priority: minor Milestone: mpich2-1.3
Component: mpich2 Keywords:
Cc: smithbr@…, archerc@…, jratt@…

Description (last modified by goodell) (diff)

I'm looking into building more of our system in parallel, but I've seen
lib*.a corruption in MPICH2 before.  When reviewing build output in -j2, I
will often see things like this:
$ pwd
/bgusr/jratt/bgp.01/bgp/comm/build/mpich2/dcmf-8aint/src/mpi/pt2pt
$ touch /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
$ make -s  # NORMAL:
  CC
 /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
  AR cr ../../../lib/libmpich.cnk.a send.o
  RANLIB          libmpich.cnk.a
  CC
 /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
  AR cr ../../../lib/libmpich.cnk.la send.lo
$ touch /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
$ make -j -s  # ODD:
  CC
 /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
*  AR cr ../../../lib/libmpich.cnk.a send.o*
*  AR cr ../../../lib/libmpich.cnk.a send.o*
*  RANLIB          libmpich.cnk.a*
*  RANLIB          libmpich.cnk.a*
  CC
 /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
  AR cr ../../../lib/libmpich.cnk.la send.lo

In parallel, it appears to be running AR and RANLIB twice.  Adding $$$$ to
the echo commands in the Makefile (shell $$, the pid), I see this:

$ touch /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
$ make -j -s
  CC
 /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
*  AR cr ../../../lib/libmpich.cnk.a send.o 12867*
*  AR cr ../../../lib/libmpich.cnk.a send.o 12868*
*  RANLIB          libmpich.cnk.a 12871*
*  RANLIB          libmpich.cnk.a 12873*
  CC
 /bgusr/jratt/bgp.01/bgp/comm/lib/dev/mpich2/src/mpi/pt2pt/send.c
  AR cr ../../../lib/libmpich.cnk.la send.lo

It appears to be running the commands simultaneously in two processes.  That
cannot be a good thing.  I think it comes from this sort of section in the
Makefile.in:

*all-redirect: .libstamp0 ../../../lib/lib${MPILIBNAME}.a*
*.libstamp0 ../../../lib/lib${MPILIBNAME}.a*: bsend.o bsend_init.o
bufattach.o \
buffree.o cancel.o greq_start.o greq_complete.o ibsend.o iprobe.o \
 irecv.o irsend.o isend.o issend.o probe.o recv.o recv_init.o \
request_free.o request_get_status.o rsend.o rsend_init.o send.o \
 send_init.o sendrecv.o sendrecv_rep.o status_set_cancelled.o ssend.o \
ssend_init.o start.o startall.o test.o test_cancelled.o testall.o \
 testany.o testsome.o wait.o waitall.o waitany.o waitsome.o \
bsendutil.o mpir_request.o
 @if [ "x$(VERBOSE)" != "x1" ] ; then \
  echo "  AR cr ../../../lib/lib${MPILIBNAME}.a $?" ; \
 else \
  echo ${AR} cr ../../../lib/lib${MPILIBNAME}.a $? ; \
fi
 @${AR} cr ../../../lib/lib${MPILIBNAME}.a $?
@if [ "x$(VERBOSE)" != "x1" ] ; then \
  echo "  RANLIB          lib${MPILIBNAME}.a" ; \
else \
  echo ${RANLIB} ../../../lib/lib${MPILIBNAME}.a ; \
 fi
@${RANLIB} ../../../lib/lib${MPILIBNAME}.a
date > .libstamp0

all-redirect is the default rule in use.  It depends on two things, which
don't depend on each other, so make appears to parallelize the building of
those two things.  However, those two things aren't independent and in fact
build each other.  Removing the library as a dependency all over the
Makefile removes the double-AR and the build still works with dep checking.
 I think this simple Makefile illustrates the problem well:

all-redirect: stamp lib
stamp lib: source
sleep 1
echo $@ > stamp
 echo $@ > lib

Drop that in an (empty) dir and run:
touch source ; make -j ; head stamp lib

You can see that it updates stamp and lib twice simultaneously after
sleeping 1 sec:

sleep 1
sleep 1
echo stamp > stamp
echo lib > stamp
echo stamp > lib
echo lib > lib

That will clearly result in non-deterministic data in lib and stamp.


To fix parallel builds, I believe that steps need to be taken to remove
those sort of double-target rules.  I understand that the Makefile.in files
are built by "simplemake", but that is the end of my understanding.  Is
there someone who still knows how it works and can help get parallel builds
working?



Thanks,
Joe Ratterman
jratt@us.ibm.com

Attachments

part0001.html (10.5 KB) - added by Joe Ratterman 4 months ago.
Added by email2trac
part0001.2.html (5.5 KB) - added by Joe Ratterman 4 months ago.
Added by email2trac

Change History

Changed 4 months ago by Joe Ratterman

Added by email2trac

Changed 4 months ago by Joe Ratterman

  • id set to 711

This message has 1 attachment(s)

Changed 4 months ago by goodell

  • owner set to goodell
  • priority changed from major to minor
  • status changed from new to assigned
  • milestone set to mpich2-1.1.2

Hi Joe,

We have an intern this summer here at ANL working on getting parallel builds working. He's had pretty good success so far, although there are still a number of issues that we just need to slog through. If you can just hold out for about another month we should be able to deliver a parallel-make-safe build system to you with little or no work on your end.

By the way, the double-target rules might be one problem, although they are probably a minor problem in the scheme of things. The single greatest problem that must be overcome in order to get parallel builds working is that the AR (and RANLIB) step can't be run concurrently on the same archives because ar doesn't inherently do anything to prevent one instance from stomping on another (such as file locking). However, the whole MPICH2 build is setup to perform archiving in each subdir, which leads to concurrent ARs when using parallel make.

To deal with this the AR step must happen all at one time after all compilation or the ARs must somehow be synchronized to avoid stepping on each other. We've elected for the former solution since it will likely result in the greatest performance gains and best portability for builds on wonky file systems like NFS.

-Dave

Changed 4 months ago by Joe Ratterman

Added by email2trac

Changed 4 months ago by Joe Ratterman

In the near-term, I don't think that multiple AR commands in different
directories should be a problem.  For example, this is the all-redirect
target from the mpid/dmcfd/src Makefile.in:
all-redirect:
${MAKE} all-local
@(cd impl && ${MAKE} all )
@(cd misc && ${MAKE} all )
@(cd pt2pt && ${MAKE} all )
@(cd persistent && ${MAKE} all )
@(cd onesided && ${MAKE} all )
@(cd comm && ${MAKE} all )
@(cd coll && ${MAKE} all )

Regardless of the level of parallelism, make will execute each of those
commands serially.  I don't think that you should ever have make in two
different directories, unless there are other places that look different.


I'm not in a hurry, and I'm glad to hear that it is being worked on.
Joe Ratterman
jratt@us.ibm.com


On Fri, Jul 10, 2009 at 10:51 AM, mpich2 <mpich2-maint@mcs.anl.gov> wrote:

>
> ----------------------------------------------+-----------------------------
>  Reporter:  Joe Ratterman <jratt0@gmail.com>  |        Owner:  goodell
>     Type:  bug                               |       Status:  assigned
>  Priority:  minor                             |    Milestone:  mpich2-1.1.2
> Component:  mpich2                            |   Resolution:
>  Keywords:                                    |
>
> ----------------------------------------------+-----------------------------
>
> Changes (by goodell):
>
>  * owner:  => goodell
>  * priority:  major => minor
>  * status:  new => assigned
>  * milestone:  => mpich2-1.1.2
>
> Comment:
>
>  Hi Joe,
>
>  We have an intern this summer here at ANL working on getting parallel
>  builds working.  He's had pretty good success so far, although there are
>  still a number of issues that we just need to slog through.  If you can
>  just hold out for about another month we should be able to deliver a
>  parallel-make-safe build system to you with little or no work on your end.
>
>  By the way, the double-target rules might be one problem, although they
>  are probably a minor problem in the scheme of things.  The single greatest
>  problem that must be overcome in order to get parallel builds working is
>  that the AR (and RANLIB) step can't be run concurrently on the same
>  archives because ar doesn't inherently do anything to prevent one instance
>  from stomping on another (such as file locking).  However, the whole
>  MPICH2 build is setup to perform archiving in each subdir, which leads to
>  concurrent ARs when using parallel make.
>
>  To deal with this the AR step must happen all at one time after all
>  compilation or the ARs must somehow be synchronized to avoid stepping on
>  each other.  We've elected for the former solution since it will likely
>  result in the greatest performance gains and best portability for builds
>  on wonky file systems like NFS.
>
>  -Dave
>
> --
> Ticket URL: <https://trac.mcs.anl.gov/projects/mpich2/ticket/711#comment:2
> >
>

Changed 4 months ago by goodell

(housekeeping notes)

related tickets: #691,#297

Changed 4 months ago by thakur

FYI, with the parallel make branch, I can build MPICH2 in under 20 seconds with a make -j 8. Still need to disable romio, mpe, and f90 though (being worked on).

Changed 4 months ago by Anthony Chan


Was the build done on NFS or on local sandbox ?

----- "mpich2" <mpich2-maint@mcs.anl.gov> wrote:

> ----------------------------------------------+-----------------------------
>  Reporter:  Joe Ratterman <jratt0@gmail.com>  |        Owner:  goodell
>
>      Type:  bug                               |       Status:
> assigned
>  Priority:  minor                             |    Milestone:
> mpich2-1.1.2
> Component:  mpich2                            |   Resolution:
>
>  Keywords:                                    |
> ----------------------------------------------+-----------------------------
>
>
> Comment (by thakur):
>
>  FYI, with the parallel make branch, I can build MPICH2 in under 20
> seconds
>  with a make -j 8. Still need to disable romio, mpe, and f90 though
> (being
>  worked on).
>
> --
> Ticket URL:
> <https://trac.mcs.anl.gov/projects/mpich2/ticket/711#comment:5>

Changed 4 months ago by Rajeev Thakur

>  Was the build done on NFS or on local sandbox ?

sandbox

Changed 3 months ago by balaji

  • milestone changed from mpich2-1.1.2 to mpich2-1.2

Milestone mpich2-1.1.2 deleted

Changed 7 weeks ago by goodell

  • status changed from assigned to accepted
  • description modified (diff)
  • milestone changed from mpich2-1.2 to mpich2-1.2.1

This isn't going to happen for the upcoming release.

Changed 3 weeks ago by goodell

  • description modified (diff)
  • milestone changed from mpich2-1.2.1 to mpich2-1.3

WARNING! You need to either login using OpenID here or enter your email address here before you can create or edit tickets. Otherwise the ticket will get treated as spam. More information on creating tickets can be found here.

Don't forget to add your email address to the cc list to make sure that you get updated of the ticket status.

Add/Change #711 (Parallel builds in MPICH2)

Author



Change Properties
Action
as accepted
 
Note: See TracTickets for help on using tickets.