beautypg.com

HP XC System 3.x Software User Manual

Page 120

background image

One way is to prefix the actual compilation line in the rule with an srun command. So, instead
of executing cc foo.c -o foo.o it would execute srun cc foo.c -o foo.o. With
concurrency, multiple command nodes would have multiple srun commands instead of multiple
cc

commands. For projects that recursively run make on subdirectories, the recursive make can

be run on the compute nodes. For example:

$ cd subdir; srun $(MAKE)...

Further, if the recursive make is run remotely, it can be told to use concurrency on the remote
node. For example:

$ cd subdir; srun -n1 -N1 $(MAKE) -j4...

This can cause multiple makes to run concurrently, each building their targets concurrently. The
-N1

option is used to reserve the entire node, because it is intended to be used for multiple

compilations. The following examples illustrate these ideas. In GNU make, a $(VARIABLE) that
is unspecified is replaced with nothing. Therefore, not specifying PREFIX keeps the original
Makefile's behavior, but specifying PREFIX to appropriate srun command prefixes will cause
concurrency within the build.

For more information about GNU parallel make, see the make manpage. For additional sources
of GNU information, see the references provided in

“About This Document”

.

In this section, three different ways to parallelize a make procedure are illustrated. The smg98
package is used to illustrate these three procedures. The smg98 package is available at the
following URL:

http://www.llnl.gov/asci/applications/SMG98README.html

These procedures take advantage of the GNU make -j switch, which specifies the number of
jobs to run simultaneously. See the make manpage for more information about this switch.

The following parallel make approaches are described:

“Example Procedure 1”

— Go through the directories serially and have the make procedure

within each directory be parallel. (Modified Makefile: Makefile_type1).

“Example Procedure 2”

— Go through the directories in parallel and have the make procedure

within each directory be serial (Modified Makefile: Makefile_type2).

“Example Procedure 3”

— Go through the directories in parallel and have the make procedure

within each directory be parallel (Modified Makefile: Makefile_type3).

The original Makefile is shown below:

#BHEADER***********************************************************
# (c) 1998 The Regents of the University of California
#
# See the file COPYRIGHT_and_DISCLAIMER for a complete copyright
# notice, contact person, and disclaimer.
#
# $Revision: 1.1 $
#EHEADER***********************************************************

SHELL = /bin/sh

srcdir = .

HYPRE_DIRS =\
utilities\
struct_matrix_vector\
struct_linear_solvers\
test

all:
@ \
for i in ${HYPRE_DIRS}; \
do \
if [ -d $$i ]; \

120

Advanced Topics