[mpich-discuss] merging intracommuncators

Ali Bouaricha alib at cadence.com
Mon Mar 25 17:13:32 CDT 2013


Hello,

I'm using MPI_Comm_Spawn to spawn processes dynamically. I spawn 
few processes, then I execute something, then I spawn few more processes.
I want to merge intracommunicators in such way that the master 
Processes including all the spawn children processes (the first and
Second time) would have rank
0, 1, 2, 3, .... p-1. 

My problem is that I cannot merge intracommunicators. Here is what I mean:

Parent code:
===========

error = MPI_Comm_spawn("child", MPI_ARGV_NULL, 2,
         info, 0, MPI_COMM_WORLD, &intercomm, errcodes);

MPI_Intercomm_merge(intercomm, 0, &intracomm);
 .....

do something

 ....
error = MPI_Comm_spawn("child", MPI_ARGV_NULL, 3,
         info, 0, MPI_COMM_WORLD, &intercomm, errcodes);

MPI_Intercomm_merge(intercomm, 0, &intracomm);



The child code:
===============

MPI_Comm_get_parent(&intercomm);

MPI_Comm_size(intercomm,&nprocs);
printf(" child nprocs = %d\n", nprocs);

MPI_Intercomm_merge(intercomm, 0, &intracomm);

MPI_Comm_rank(intracomm, &rank);
printf(" child rank = %d\n", rank);

=====

The outptut after executing: mpiexec -n 1 ./parent 


Gives: child rank 1, 2             (for the first spawn)
       Child rank 1, 2, 3          (for the second spawn)

The question is that how I can merge so that my processes would have ranks
1, 2, 3, 4, 5?

Thanks a lot, 

Ali



More information about the discuss mailing list