[mpich-discuss] MPI_Comm_Spawn question
Dave Goodell
goodell at mcs.anl.gov
Wed Jun 29 13:33:40 CDT 2011
It does include both the parent processes and the child processes. But it is still an *intercommunicator*. From your earlier email it sounded like you wanted an *intracommunicator* instead. To obtain that you will need to perform either an MPI_Intercomm_merge or some set of MPI_Group operations.
MPI_Comm_get_parent will return MPI_COMM_NULL in the parent process (assuming it does not itself have a separate parent), and in the child processes it will return the intercommunicator for communication with the parent. That is, it is the "other half" of the intercomm that is returned by MPI_Comm_spawn in the parent processes.
-Dave
On Jun 29, 2011, at 12:53 PM CDT, Eric Hui wrote:
> Hi Dave,
>
> I was reading section 10.3.2 in the MPI 2.2 spec and here is what it says for MPI_Comm_Spawn:
>
> The intercommunicator returned by MPI_COMM_SPAWN contains the parent processes in the local group and the child processes in the remote group. The ordering of processes in the local and remote groups is the same as the ordering of the group of the comm in the parents and of MPI_COMM_WORLD of the children, respectively. This intercommunicator can be obtained in the children through the function MPI_COMM_GET_PARENT.
>
> From the above paragraph, it sounds to me like this new intercommunicator should include both the parent and the child processes. Did I misinterpret the spec?
>
> When I call MPI_Comm_get_parent in the child, it only include the children processes, but not the parent. I am not sure how I can get the parent included if MPI_Comm_get_parent does not return it.
>
> Actually the example code that I am using is based on the example I found here in the MPI forum here:
> http://www.mpi-forum.org/docs/mpi22-report/node210.htm#Node210
>
> Regards,
> Eric
>
> From: Eric Hui
> Sent: Wednesday, June 29, 2011 11:27 AM
> To: mpich-discuss at mcs.anl.gov
> Subject: MPI_Comm_Spawn question
>
> I started my MPI program with one process only and tried to use MPI_Comm_Spawn to launch three more copies like this:
>
> //main
> MPI_Comm ParentComm;
> MPI_Comm InterComm;
>
> MPI_Comm_get_parent (&ParentComm);
>
> if (ParentComm == MPI_COMM_NULL)
> {
> MPI_Comm_spawn("myapp.exe", argv, NumMPIHelpers, MPI_INFO_NULL, 0, MPI_COMM_SELF, &InterComm, MPI_ERRCODES_IGNORE);
>
> ShowRank (InterComm); //*ß this shows size = 1, rank = 0
> }
> else
> {
> ShowRank (ParentComm); //* this shows size = 3, rank = 0, 1 or 2 for the childs
> }
>
> //showrank function
> void ShowRank (MPI_Comm Com)
> {
> MPI_Comm_rank (Com, &MPIRank); /* get current process id */
> MPI_Comm_size (Com, &MPISize); /* get number of processes */
>
> DWORD Pid = GetCurrentProcessId();
>
> CString Msg;
>
> Msg.Format ("MPI_Comm = %ld, Process ID = %ld, Size = %ld, Rank = %ld", Com, Pid, MPISize, MPIRank);
>
> AddMsg (Msg);
> }
>
> I am trying to join the parents and the children together into one group.
>
> Do I need to call MPI_Intercomm_merge? I thought the "InterComm" is already supposed to have size = 4 with rank = 0, 1, 2 and 3.
>
> Thanks,
> Eric
More information about the mpich-discuss
mailing list