<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi Dave,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I was reading section 10.3.2 in the MPI 2.2 spec and here is what it says for MPI_Comm_Spawn:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">From the above paragraph, it sounds to me like this new intercommunicator should include both the parent and the child processes.&nbsp; Did I misinterpret the spec?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">When I call MPI_Comm_get_parent in the child, it only include the children processes, but not the parent.&nbsp; I am not sure how I can get the parent included if MPI_Comm_get_parent does not return it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Actually the example code that I am using is based on the example I found here in the MPI forum here:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">http://www.mpi-forum.org/docs/mpi22-report/node210.htm#Node210<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Eric<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Eric Hui
<br>
<b>Sent:</b> Wednesday, June 29, 2011 11:27 AM<br>
<b>To:</b> mpich-discuss@mcs.anl.gov<br>
<b>Subject:</b> MPI_Comm_Spawn question<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span lang="EN-CA">I started my MPI program with one process only and tried to use MPI_Comm_Spawn to launch three more copies like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">//main<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MPI_Comm ParentComm;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MPI_Comm InterComm;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MPI_Comm_get_parent (&amp;ParentComm);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ParentComm == MPI_COMM_NULL)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MPI_Comm_spawn(&quot;myapp.exe&quot;, argv, NumMPIHelpers, MPI_INFO_NULL, 0, MPI_COMM_SELF, &amp;InterComm, MPI_ERRCODES_IGNORE);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShowRank (InterComm);&nbsp; //*</span><span lang="EN-CA" style="font-family:Wingdings">ß</span><span lang="EN-CA"> this shows size = 1, rank = 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShowRank (ParentComm);&nbsp; //* this shows size = 3, rank = 0, 1 or 2 for the childs<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">//showrank function<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">void ShowRank (MPI_Comm Com)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp; MPI_Comm_rank (Com, &amp;MPIRank);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* get current process id */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp; MPI_Comm_size (Com, &amp;MPISize);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* get number of processes */&nbsp;&nbsp;&nbsp;
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp; DWORD Pid = GetCurrentProcessId();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp; CString Msg;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp; Msg.Format (&quot;MPI_Comm = %ld, Process ID = %ld, Size = %ld, Rank = %ld&quot;, Com, Pid, MPISize, MPIRank);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">&nbsp;&nbsp; AddMsg (Msg);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">I am trying to join the parents and the children together into one group.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">Do I need to call MPI_Intercomm_merge?&nbsp; I thought the &quot;InterComm&quot; is already supposed to have size = 4 with rank = 0, 1, 2 and 3.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">Eric<o:p></o:p></span></p>
</div>
</body>
</html>