Reference

MPI_Spawn(2)

Spawn MPI processes under LAM.

NAME

MPI_Spawn - Spawn MPI processes under LAM.

C SYNOPSIS

#include <mpi.h>

int MPI_Spawn (char *program, char *argv[], int maxprocs, MPI_Info info, int root, MPI_Comm parents, MPI_Comm *children, int errors[]);

FORTRAN SYNOPSIS

subroutine MPI_SPAWN (program, argv, maxprocs, info, root, parents, children, ierrors, ierr)

character*(*) program, argv(*)
integer info, maxprocs, root, parents, children, ierrors(*)

DESCRIPTION

A group of processes can create another group of processes with MPI_Spawn(). The parent group is indicated by the first communicator argument. MPI_Spawn() is a collective operation over the parent processes. The child group starts up like any MPI application. The processes must begin by calling MPI_Init(), after which the pre-defined communicator, MPI_COMM_WORLD, may be used. This world communicator contains only the child processes. It is distinct from the MPI_COMM_WORLD of the parent processes.

Communication With Spawned Processes

The natural communication mechanism between two groups is the intercommunicator. The second communicator argument to MPI_Spawn() returns an intercommunicator whose local group contains the parent processes (same as the first communicator argument) and whose remote group contains child processes. The child processes access the same intercommunicator under the pre-defined name, MPI_COMM_PARENT. The remote group size of MPI_COMM_PARENT is zero if the process was created by mpirun(1) instead of MPI_Spawn(). Both groups can decide to merge the intercommunicator into an intracommunicator and take advantage of other MPI collective operations. They can then use the merged intracommunicator to create new intercommunicators and reach other processes in the MPI application.

Resource Allocation

LAM tends not to offer MPI features that are not portable in production applications. The info argument to MPI_Spawn() is where non-portable resource specification may be made. LAM does not interpret this parameter. The portable value MPI_INFO_NULL should be given.

LAM schedules the given number of processes onto LAM nodes by starting with node 0 (or the lowest numbered node), and continuing through higher node numbers, placing one process on each node. If the process count is greater than the node count, the procedure repeats.

Process Count

The maxprocs parameter is the exact number of processes that will be started. If it is not possible to start maxprocs processes, MPI_Spawn() returns an error code.

Frequently, an application wishes to chooses a process count so as to fill all processors available to a job. MPI indicates the maximum number of processes recommended for a job in the pre-defined attribute, MPI_UNIVERSE_SIZE, which is cached on MPI_COMM_WORLD. The typical usage is to subtract the value of MPI_UNIVERSE_SIZE from the number of processes currently in the job and spawn the difference. LAM sets MPI_UNIVERSE_SIZE to the number of nodes in the user's LAM session.

Locating an Executable Program

The executable program file must be located on the node(s) where the process(es) will run. On any node, the directories specified by the user's PATH environment variable are searched to find the program.

All MPI runtime options selected by mpirun(1) in the initial application launch remain in effect for all child processes created by MPI_Spawn() .

Command-line Arguments

The argv parameter to MPI_Spawn should not contain the program name, as given in the first parameter. The command line passed to the newly launched program will be the program name followed by the strings in argv.

SEE ALSO

mpirun(1)