[GRASS-dev] [grass-code I][359] GRASS fails to build with make -j3

code I item #359, was opened at 2007-04-05 12:01
Status: Open
Priority: 4
Submitted By: Maciej Sieczka (msieczka)
Assigned to: Nobody (None)
Summary: GRASS fails to build with make -j3
Issue type: other bug
Issue status: None
GRASS version: CVS HEAD
GRASS component: build
Operating system: all
Operating system version:
GRASS CVS checkout date, if applies (YYMMDD): 050407

Initial Comment:
On multi cpu machines it is possible to speed up compilation time greatly using the -j switch with make (eg. -j3 for 2 cpus).

make -j3 works fine on my dual core Intel with all the software I'm building from source (including eg. PROJ, GEOS, HDF4, POSTGIS, GDAL, QT4).

But when I build GRASS with make -j3, plenty of errors crop out after "Waiting for unfinished jobs...." information. In a result, no single GRASS module is build properly. However, GRASS builds fine on the same machine if -j3 is not used.

configure and make logs attached.

Maciek

----------------------------------------------------------------------

You can respond by visiting:
http://wald.intevation.org/tracker/?func=detail&atid=204&aid=359&group_id=21

grass-codei@wald.intevation.org wrote:

code I item #359, was opened at 2007-04-05 12:01
Status: Open
Priority: 4
Submitted By: Maciej Sieczka (msieczka)
Assigned to: Nobody (None)
Summary: GRASS fails to build with make -j3
Issue type: other bug
Issue status: None
GRASS version: CVS HEAD
GRASS component: build
Operating system: all
Operating system version:
GRASS CVS checkout date, if applies (YYMMDD): 050407

Initial Comment:
On multi cpu machines it is possible to speed up compilation time
greatly using the -j switch with make (eg. -j3 for 2 cpus).

make -j3 works fine on my dual core Intel with all the software I'm
building from source (including eg. PROJ, GEOS, HDF4, POSTGIS, GDAL,
QT4).

But when I build GRASS with make -j3, plenty of errors crop out
after "Waiting for unfinished jobs...." information. In a result, no
single GRASS module is build properly. However, GRASS builds fine on
the same machine if -j3 is not used.

configure and make logs attached.

The first thing I notice is that the first error is usually a missing
header file, e.g.:

copy.c:7:28: error: grass/datetime.h: No such file or directory

adj_cellhd.c:14:23: error: grass/gis.h: No such file or directory

This is due to the "headers" target in the "libs" directory being run
in parallel with other jobs.

This specific issue can probably be solved by changing lib/Makefile
from:

  default: headers subdirs
to:

  default: subdirs

  subdirs: headers

This should prevent the subdirs target from being run before the
headers target has completed.

However: I'm not sure whether parallel make will actually be useful
with the existing Makefiles, due to the use of a shell "for" loop for
building subdirectories:

  subdirs:
    @list='$(SUBDIRS)'; \
    for subdir in $$list; do \
        echo $$subdir ; \
        $(MAKE) -C $$subdir || echo $(CURDIR)/$$subdir >> $(GRASS_HOME)/error.log; \
    done

[From include/Make/Dir.make]

To have the subdirectories built in parallel, you would need to use
something like:

  .PHONY: subdirs $(SUBDIRS)

  subdirs: $(SUBDIRS)

  $(SUBDIRS):
    $(MAKE) -C $@

--
Glynn Clements <glynn@gclements.plus.com>

On Thu, Apr 05, 2007 at 02:05:53PM +0100, Glynn Clements wrote:

grass-codei@wald.intevation.org wrote:

> code I item #359, was opened at 2007-04-05 12:01
> Status: Open
> Priority: 4
> Submitted By: Maciej Sieczka (msieczka)
> Assigned to: Nobody (None)
> Summary: GRASS fails to build with make -j3
> Issue type: other bug
> Issue status: None
> GRASS version: CVS HEAD
> GRASS component: build
> Operating system: all
> Operating system version:
> GRASS CVS checkout date, if applies (YYMMDD): 050407
>
>
> Initial Comment:
> On multi cpu machines it is possible to speed up compilation time
> greatly using the -j switch with make (eg. -j3 for 2 cpus).
>
> make -j3 works fine on my dual core Intel with all the software I'm
> building from source (including eg. PROJ, GEOS, HDF4, POSTGIS, GDAL,
> QT4).
>
> But when I build GRASS with make -j3, plenty of errors crop out
> after "Waiting for unfinished jobs...." information. In a result, no
> single GRASS module is build properly. However, GRASS builds fine on
> the same machine if -j3 is not used.
>
> configure and make logs attached.

The first thing I notice is that the first error is usually a missing
header file, e.g.:

copy.c:7:28: error: grass/datetime.h: No such file or directory

adj_cellhd.c:14:23: error: grass/gis.h: No such file or directory

This is due to the "headers" target in the "libs" directory being run
in parallel with other jobs.

This specific issue can probably be solved by changing lib/Makefile
from:

  default: headers subdirs
to:

  default: subdirs

  subdirs: headers

This should prevent the subdirs target from being run before the
headers target has completed.

However: I'm not sure whether parallel make will actually be useful
with the existing Makefiles, due to the use of a shell "for" loop for
building subdirectories:

  subdirs:
    @list='$(SUBDIRS)'; \
    for subdir in $$list; do \
        echo $$subdir ; \
        $(MAKE) -C $$subdir || echo $(CURDIR)/$$subdir >> $(GRASS_HOME)/error.log; \
    done

[From include/Make/Dir.make]

To have the subdirectories built in parallel, you would need to use
something like:

  .PHONY: subdirs $(SUBDIRS)

  subdirs: $(SUBDIRS)

  $(SUBDIRS):
    $(MAKE) -C $@

I am interested to get this working but failed to get the
second part in include/Make/Dir.make successfully running.

Any further hints? My Makefile knowledge is fairly limited
unfortunately.

Markus

Markus Neteler wrote:

> > code I item #359, was opened at 2007-04-05 12:01
> > Summary: GRASS fails to build with make -j3

> However: I'm not sure whether parallel make will actually be useful
> with the existing Makefiles, due to the use of a shell "for" loop for
> building subdirectories:
>
> subdirs:
> @list='$(SUBDIRS)'; \
> for subdir in $$list; do \
> echo $$subdir ; \
> $(MAKE) -C $$subdir || echo $(CURDIR)/$$subdir >> $(GRASS_HOME)/error.log; \
> done
>
> [From include/Make/Dir.make]
>
> To have the subdirectories built in parallel, you would need to use
> something like:
>
> .PHONY: subdirs $(SUBDIRS)
>
> subdirs: $(SUBDIRS)
>
> $(SUBDIRS):
> $(MAKE) -C $@

I am interested to get this working but failed to get the
second part in include/Make/Dir.make successfully running.

Any further hints? My Makefile knowledge is fairly limited
unfortunately.

Note that this cannot be done for all directories. In particular, the
inter-dependencies between libraries mean that you cannot build the
lib/* directories in an arbitrary order. You would have to either use
the existing "for" loop in lib/Makefile, or explicitly list the
dependencies, e.g.:

  gis: datetime
  driver: gis
  pngdriver: driver gis
  psdriver: driver gis
  raster: driver gis pngdriver psdriver
  display: gis raster

Using the naïve parallel version for the lib directory will result in
severe failure, due to attempting to link other libraries against
libgis before libgis has been generated.

The top-level directories may as well be built sequentially, but
presumably you would want to parallelise within the raster, vector,
general etc directories. Parallelising lib is less important as most
of the subdirectories contain enough files that parallelising within
individual lib/* subdirectories would probably be sufficient.

As a first attempt, I'd suggest trying the above idiom in Dir.make,
and using the existing loop in lib/Makefile (name the target somthing
other than "subdirs" to avoid a conflict with Dir.make). Hopefully,
that should keep the number of errors down to manageable proportions
(it's a safe bet that at least some of the individual module/lib
Makefiles rely upon sequential processing).

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote:

Markus Neteler wrote:

> > code I item #359, was opened at 2007-04-05 12:01
> > Summary: GRASS fails to build with make -j3

> However: I'm not sure whether parallel make will actually be useful
> with the existing Makefiles, due to the use of a shell "for" loop for
> building subdirectories:
>
> subdirs:
> @list='$(SUBDIRS)'; \
> for subdir in $$list; do \
> echo $$subdir ; \
> $(MAKE) -C $$subdir || echo $(CURDIR)/$$subdir >>
$(GRASS_HOME)/error.log; \
> done
>
> [From include/Make/Dir.make]
>
> To have the subdirectories built in parallel, you would need to use
> something like:
>
> .PHONY: subdirs $(SUBDIRS)
>
> subdirs: $(SUBDIRS)
>
> $(SUBDIRS):
> $(MAKE) -C $@

I am interested to get this working but failed to get the
second part in include/Make/Dir.make successfully running.

Any further hints? My Makefile knowledge is fairly limited
unfortunately.

Note that this cannot be done for all directories. In particular, the
inter-dependencies between libraries mean that you cannot build the
lib/* directories in an arbitrary order. You would have to either use
the existing "for" loop in lib/Makefile, or explicitly list the
dependencies, e.g.:

  gis: datetime
  driver: gis
  pngdriver: driver gis
  psdriver: driver gis
  raster: driver gis pngdriver psdriver
  display: gis raster

Using the naïve parallel version for the lib directory will result in
severe failure, due to attempting to link other libraries against
libgis before libgis has been generated.

Yes, confirmed.

The top-level directories may as well be built sequentially, but
presumably you would want to parallelise within the raster, vector,
general etc directories. Parallelising lib is less important as most
of the subdirectories contain enough files that parallelising within
individual lib/* subdirectories would probably be sufficient.

As a first attempt, I'd suggest trying the above idiom in Dir.make,
and using the existing loop in lib/Makefile (name the target somthing
other than "subdirs" to avoid a conflict with Dir.make). Hopefully,
that should keep the number of errors down to manageable proportions
(it's a safe bet that at least some of the individual module/lib
Makefiles rely upon sequential processing).

Will do.
Concerning modules: candidates for sequential processing are certainly the
r.li suite (r.li.daemon comes first), raster/simwe/lib/, vector/v.lrs/lib/
vector/lidar/lidarlib/ and so forth. For these subdirectories some trick
must
be implemented to get them sequentially processed (which this could go in
parallel with other raster/vector programs).

Anyway, slowly we'll arrive.

Markus
--
View this message in context: http://www.nabble.com/-grass-code-I--359--GRASS-fails-to-build-with-make--j3-tf3530677.html#a11525174
Sent from the Grass - Dev mailing list archive at Nabble.com.