<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;}
/* 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-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@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 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> </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"> MPI_Comm ParentComm;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"> MPI_Comm InterComm;<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"> MPI_Comm_get_parent (&ParentComm);<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"> if (ParentComm == MPI_COMM_NULL)<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"> MPI_Comm_spawn("myapp.exe", argv, NumMPIHelpers, MPI_INFO_NULL, 0, MPI_COMM_SELF, &InterComm, MPI_ERRCODES_IGNORE);<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"> ShowRank (InterComm); //*</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"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"> else<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"> ShowRank (ParentComm); //* 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"> }<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">//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"> MPI_Comm_rank (Com, &MPIRank); /* get current process id */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA"> MPI_Comm_size (Com, &MPISize); /* get number of processes */
<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"> DWORD Pid = GetCurrentProcessId();<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"> CString 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"> Msg.Format ("MPI_Comm = %ld, Process ID = %ld, Size = %ld, Rank = %ld", Com, Pid, MPISize, MPIRank);<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"> 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> </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> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">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.<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">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-CA">Eric<o:p></o:p></span></p>
</div>
</body>
</html>