LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2004-12-07 16:28:30


On Dec 7, 2004, at 4:07 AM, Gabriel Antoine Louis Paillard wrote:

> Now I really understood the function of the root, but the problem,
> using the MPI_Comm_spawn function is that: for example, using my
> program
> below, for the rank (mon_rang) equal to 0, it will execute 8 times with
> for the process which corresponds to the rank 0 and seven more times to
> the othes 7 processes and not just one time for each process. How can I
> remedy that ?

I'm not quite sure that I understand... I'm not sure where you got the
8+7 numbers of there. The last version of your program that you sent,
assuming that you "mpirun -np 8 your_program", will run MPI_COMM_SPAWN
exactly 8 times -- once in each process that was launched by mpirun.
Since you used MPI_COMM_SELF as the communicator to MPI_COMM_SPAWN and
specified the root as 0, then each of the 8 processes will be the root,
and therefore each will launch (numprocs) new processes with the (argv)
that was constructed for that spawning process.

In your last mail, I think you had numprocs == 1, so each process
launched 1 new process (for a total of 8 original + 8*1 new = 16
processes). In the program you included below, you have numprocs == 8,
so each process will launch 8 new processes (for a whopping total of 8
original + 8*8 new = 72 processes).

Each MPI_COMM_SPAWN will spawn a whole new MPI application with its own
MPI_COMM_WORLD. So when you specified numprocs == 1, each spawned MPI
application had an MPI_COMM_WORLD of size 1, and the one and only
process in it had a MCW rank of 0. When you specified numprocs == 8,
each spawned MPI application had an MPI_COMM_WORLD size of 8, and had
processes with MCW ranks 0 through 7.

>> "If you want to launch N processes, each with different arguments,
>> then
>> you need to use either multiple calls to MPI_COMM_SPAWN (i.e., each
>> one with a different argv), or MPI_COMM_SPAWN_MULTIPLE, where you can
>> specify an array of argv."
>
> But what I want, is to launch a new process from every process
> existing,
> and try to merge all worlds after that. And for that, I can't employ
> MPI_comm_spawn_multiple, because if I start the program with 8
> processes, just the root process will launch the new processes and
> it isn't the purpose of the program.

Ok. Then you need to use multiple calls to MPI_COMM_SPAWN (which you
have effectively done by using MPI_COMM_SELF). Merging all the spawned
process into one communicator will take a bit of work -- you may need
to use MPI_COMM_ACCEPT and MPI_COMM_CONNECT in a creative,
deterministic way.

If having each process spawn one other is not a hard requirement (i.e.,
if the only requirement is to spawn one new process for each old
process), using MPI_COMM_SPAWN_MULTIPLE will be a far easier solution
for having a merged communicator at the end (IMHO).

Hope that helps.

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/