On Sat, 31 May 2003, Sherif Abd El-Momen wrote:
> I have a problem spawning processes. In MPI standerd it mentioned that
> MPI_Comm_spawn is a collective operation. so as I understand all the
> parent group should call MPI_Comm_spawn. I want to create one process at
Mostly correct -- it's the parent communicator, not the parent group.
Hence, MPI_COMM_SPAWN (and friends) are collective across the
communicator, not the group.
> a time. but when th parents group call the spawn function. a number of
> processes is created not one. is it a bug or I am doing something wrong.
MPI_COMM_SPAWN will create as many processes as you tell it to; the
arguments should be the same across all processes in the communicator
(e.g., number of processes to create). For example, if I have a
communicator with 4 processes in it, and they all call MPI_COMM_SPAWN
saying to create 8 processes, a total of 12 processes should exist at the
end of the call -- not (4 + 4*8) = 36.
> /* manager */
> [snipped]
>
> MPI_Comm_spawn(worker_program,MPI_ARGV_NULL,1 ,
> MPI_INFO_NULL, 0, MPI_COMM_SELF, &everyone,
> MPI_ERRCODES_IGNORE);
Here's the problem -- in the manager, you're using MPI_COMM_SELF as
the parent communicator. Hence, there's only 1 process in the parent
communicator, and every one of the 4 original MPI processes is the
root (and therefore the parent) of a slave process. Hence, you get 8
processes instead of what you expect (5). If you change this to
MPI_COMM_WORLD, you'll get 5 resulting processes (and the slave will
report that it has a Simulation size of 5).
--
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/
|