[mpich-discuss] merging intracommuncators

Rajeev Thakur thakur at mcs.anl.gov
Mon Mar 25 21:13:08 CDT 2013


Try doing the second spawn with intracomm instead of MPI_COMM_WORLD as the communicator. However, it would be collective over the first set of children as well, i.e., both the parent and the first set of children would need to call the second spawn in this case.

Rajeev



On Mar 25, 2013, at 5:13 PM, Ali Bouaricha wrote:

> 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
> 
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss




More information about the discuss mailing list