<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Thanks, Bland and Lu.</div><div><br></div><div>You are right.</div><div>These functions (such as MPI_Comm_accept, MPI_Comm_connect, MPI_Intercomm_merge) can help me to get a new<span style="line-height: 23.7999992370605px;"> </span><span style="line-height: 23.7999992370605px;">intra-communicator which </span>contains ALL MPI processes.</div><div><br></div><div>Now, I have a more complicated example:</div><div>    I have a server and a client. </div><div>    After they merge into an <span style="line-height: 23.7999992370605px;">intra-communicator by using connect/accept/merge fucntions, another client would plant to join them, too.</span></div><div><span style="line-height: 23.7999992370605px;">    I thought that the code is simular, but the code CAN'T work: Second client CAN'T connect. The new comm CAN'T accept. They all BLOCK.</span></div><div><div style="line-height: 23.7999992370605px;"><br class="Apple-interchange-newline">    As you see, the second client BLOCKs at <span style="line-height: 23.7999992370605px;">MPI_Comm_connect, and processes of newcomm BLOCK at </span><span style="line-height: 23.7999992370605px;">MPI_Comm_accept.</span></div><div style="line-height: 23.7999992370605px;"><span style="line-height: 23.7999992370605px;">    What's Wrong with my code? </span></div></div><div style="line-height: 23.7999992370605px;"><span style="line-height: 23.7999992370605px;"><br></span></div><div>//server</div><div><div>#include "mpi.h"</div><div>int main(int argc, char *argv[])</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>MPI_Comm client, client2, newcomm, newcomm2;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>MPI_Status status;</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>char port_name[MPI_MAX_PORT_NAME];</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>char port_name2[MPI_MAX_PORT_NAME];</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>int size, again, rank, myrank;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Init(&argc, &argv);</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Open_port(MPI_INFO_NULL, port_name);<span style="line-height: 23.7999992370605px;">//OK</span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&client);<span style="line-height: 23.7999992370605px;">//OK</span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>MPI_Intercomm_merge(client,11,&newcomm);//OK</div><div><br></div><div>    <span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Barrier(newcomm);//OK</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>MPI_Open_port(MPI_INFO_NULL, port_name2);// OK</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Comm_accept(port_name2, MPI_INFO_NULL, 0, newcomm,&client2);// BLOCK here, Wath's wrong?</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>MPI_Intercomm_merge(client2,12,&newcomm2);</div><div><br></div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Barrier(newcomm2);</div><div><br></div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Close_port(port_name);</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>MPI_Comm_disconnect(&client);</div><div>    <span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Close_port(port_name2);</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>MPI_Comm_disconnect(&client2);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">  </span>MPI_Finalize();</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>return 0;</div><div>}</div></div><div><br></div><div>//first client</div><div><div>#include "mpi.h"</div><div><span style="line-height: 1.7;">int main( int argc, char **argv )</span></div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>MPI_Comm server,newcomm,newcomm2,client2;</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>char port_name[MPI_MAX_PORT_NAME];</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>char port_name2[MPI_MAX_PORT_NAME];</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>int size,rank;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Init( &argc, &argv );</div><div><span class="Apple-tab-span" style="white-space:pre">    </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>strcpy( port_name, argv[1] );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF,&server );<span style="line-height: 23.7999992370605px;">//OK</span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>MPI_Intercomm_merge(server,11,&newcomm);//OK</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>MPI_Barrier(newcomm);//OK</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>MPI_Open_port(MPI_INFO_NULL, port_name2);//OK</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>MPI_Comm_accept(port_name2, MPI_INFO_NULL, 0, newcomm,&client2);<span style="line-height: 23.7999992370605px;">// BLOCK here, Wath's wrong?</span></div><div><span style="line-height: 23.7999992370605px;"><br></span></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>MPI_Intercomm_merge(client2,12,&newcomm2);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Barrier(newcomm2);</div><div><br></div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Close_port(port_name2);</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>MPI_Comm_disconnect(&client2);</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>MPI_Comm_disconnect( &server );</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>MPI_Finalize();</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>return 0;</div><div>}</div><div><br></div></div><div>//second client</div><div><div>#include "mpi.h"</div><div>int main( int argc, char **argv )</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>MPI_Comm server,newcomm;</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>char port_name[MPI_MAX_PORT_NAME];</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>int size,rank;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MPI_Init( &argc, &argv );</div><div><span class="Apple-tab-span" style="white-space:pre">    </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>strcpy( port_name, argv[1] );//OK</div><div><span class="Apple-tab-span" style="line-height: 1.7; white-space: pre;">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF,&server );<span style="line-height: 23.7999992370605px;">// BLOCK here, Wath's wrong?</span></div><div><span class="Apple-tab-span" style="white-space:pre">  </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>MPI_Comm_size(MPI_COMM_WORLD, &size);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>MPI_Intercomm_merge(server,11,&newcomm);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Barrier(newcomm);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>MPI_Comm_disconnect( &server );</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>MPI_Finalize();</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>return 0;</div><div>}</div><div><br></div></div><div><br></div><br><div></div><div id="divNeteaseMailCard"></div><br>At 2015-01-23 23:14:06, "Wesley Bland" <wbland@anl.gov> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:1.2em 0px!important">The size of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">MPI_COMM_WORLD</code> will never change. That communicator is set at initialization time and is not ever modified. However, when you finish connect/accept, you get a new communicator which you can merge into an intra-communicator which functions exactly like <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">MPI_COMM_WORLD</code>. Don¡¯t be attached to the variable name <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">MPI_COMM_WORLD</code>. It¡¯s just a variable and you can use a different one with very little extra work.</p>
<p style="margin:1.2em 0px!important">Thanks,<br>Wesley</p>
<div title="MDH:VGhlIHNpemUgb2YgYE1QSV9DT01NX1dPUkxEYCB3aWxsIG5ldmVyIGNoYW5nZS4gVGhhdCBjb21t
dW5pY2F0b3IgaXMgc2V0IGF0IGluaXRpYWxpemF0aW9uIHRpbWUgYW5kIGlzIG5vdCBldmVyIG1v
ZGlmaWVkLiBIb3dldmVyLCB3aGVuIHlvdSBmaW5pc2ggY29ubmVjdC9hY2NlcHQsIHlvdSBnZXQg
YSBuZXcgY29tbXVuaWNhdG9yIHdoaWNoIHlvdSBjYW4gbWVyZ2UgaW50byBhbiBpbnRyYS1jb21t
dW5pY2F0b3Igd2hpY2ggZnVuY3Rpb25zIGV4YWN0bHkgbGlrZSBgTVBJX0NPTU1fV09STERgLiBE
b24ndCBiZSBhdHRhY2hlZCB0byB0aGUgdmFyaWFibGUgbmFtZSBgTVBJX0NPTU1fV09STERgLiBJ
dCdzIGp1c3QgYSB2YXJpYWJsZSBhbmQgeW91IGNhbiB1c2UgYSBkaWZmZXJlbnQgb25lIHdpdGgg
dmVyeSBsaXR0bGUgZXh0cmEgd29yay48ZGl2Pjxicj48L2Rpdj48ZGl2PlRoYW5rcyw8L2Rpdj48
ZGl2Pldlc2xleTwvZGl2Pg==" style="height:0;font-size:0em;padding:0;margin:0"></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 22, 2015 at 6:14 PM, haozi <span dir="ltr"><<a href="mailto:yidanyiji@163.com" target="_blank">yidanyiji@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>
<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">
<div>Thanks, Lu.</div>
<div>My simple code is as following.</div>
<div>//server</div>
<div>
<div>#include "mpi.h"</div>
<div><br>
</div>
<div>int main(int argc, char *argv[])</div>
<div>{</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm client;</div>
<div><span style="white-space:pre-wrap"></span>MPI_Status status;</div>
<div><span style="white-space:pre-wrap"></span>char port_name[MPI_MAX_PORT_NAME];</div>
<div><span style="white-space:pre-wrap"></span>int size, again;</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>MPI_Init(&argc, &argv);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_size(MPI_COMM_WORLD, &size);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Open_port(MPI_INFO_NULL, port_name);</div>
<div><span style="white-space:pre-wrap"></span>printf("server port_name is %s\n\n", port_name);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&client);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_size(MPI_COMM_WORLD, &size);</div>
<div><span style="white-space:pre-wrap"></span>printf("At server, comm_size=%d @ MPI_COMM_WORLD=%x, Client_World=%x\n",size,MPI_COMM_WORLD, client);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_size(client, &size);</div>
<div><span style="white-space:pre-wrap"></span>printf("At server, client_size=%d @ MPI_COMM_WORLD=%x, Client_World=%x\n",size,MPI_COMM_WORLD, client);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_disconnect(&client);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Finalize();</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div>}</div>
</div>
<br>
<div>//client</div>
<div>
<div>#include "mpi.h"</div>
<div><br>
</div>
<div>int main( int argc, char **argv )</div>
<div>{</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm server;</div>
<div><span style="white-space:pre-wrap"></span>char port_name[MPI_MAX_PORT_NAME];</div>
<div><span style="white-space:pre-wrap"></span>int size;</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>MPI_Init( &argc, &argv );</div>
<div><span style="white-space:pre-wrap"></span>strcpy( port_name, argv[1] );</div>
<div><span style="white-space:pre-wrap"></span>printf("server port name:%s\n",port_name);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&server );</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_size(MPI_COMM_WORLD, &size);</div>
<div><span style="white-space:pre-wrap"></span>printf("At client, comm_size=%d @ MPI_COMM_WORLD=%x, Server_World=%x\n",size,MPI_COMM_WORLD,server);</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_size(server, &size);</div>
<div><span style="white-space:pre-wrap"></span>printf("At client, server_size=%d @ MPI_COMM_WORLD=%x, Server_World=%x\n",size,MPI_COMM_WORLD,server);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>MPI_Comm_disconnect( &server );</div>
<div><span style="white-space:pre-wrap"></span>MPI_Finalize();</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div>}</div>
</div>
<div><br>
</div>
<div>The run command is as following.</div>
<div>mpiexec -n 1 ./server</div>
<div>mpiexec -n 1 ./client</div>
<div><br>
</div>
<div>BUT, the SIZE is 1, NOT 2.</div>
<div><br>
</div>
<div>My question is as before: How does the size of MPI_COMM_WORLD change to 2 ?</div><div><div class="h5">
<br>
<div></div>
<div></div>
<br>
At 2015-01-23 00:30:43, "Huiwei Lu" <<a href="mailto:huiweilu@mcs.anl.gov" target="_blank">huiweilu@mcs.anl.gov</a>> wrote:<br>
<blockquote style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid">
<div dir="ltr">You may take a look at MPI_Comm_accept and MPI_Comm_connect, which will connect a new client process to a server process. See Chap. 10 of MPI 3.0 standard (<a href="http://www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf" target="_blank">www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf</a>)
 for a detail example.
<div class="gmail_extra"><br clear="all">
<div>
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">--</div>
<div dir="ltr">Huiwei Lu</div>
<div dir="ltr">Postdoc Appointee</div>
<div dir="ltr">Mathematics and Computer Science Division</div>
<div dir="ltr">Argonne National Laboratory</div>
<div dir="ltr"><a href="http://www.mcs.anl.gov/~huiweilu/" target="_blank">http://www.mcs.anl.gov/~huiweilu/</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">On Thu, Jan 22, 2015 at 9:41 AM, haozi <span dir="ltr"><<a href="mailto:yidanyiji@163.com" target="_blank">yidanyiji@163.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">
<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">
<div>Hi, guys.</div>
<div><br>
</div>
<div>This web page (<a href="http://wiki.mpich.org/mpich/index.php/PMI_v2_Design_Thoughts)" target="_blank">http://wiki.mpich.org/mpich/index.php/PMI_v2_Design_Thoughts)</a> says:</div>
<div>             <b> </b><span style="font-family:sans-serif;font-size:12.8000001907349px;line-height:19.2000007629395px"><b>Singleton init.</b> This is the process by which a program that was not started with mpiexec can
<b>become an MPI process </b>and make use of all MPI features, including MPI_Comm_spawn, needs to be designed and documented, with particular attention to the disposition of standard I/O. Not all process managers will want to or even be able to create a new
 mpiexec process, so this needs to be negotiated. Similarly, the dispostion of stdio needs to be negotiated between the singleton process and the process manager. To address these issues, a new singleton init protocol has been implemented and tested with the
 gforker process manager.</span></div>
<div><br>
</div>
<div>I am very interested in this <font color="#333333" face="arial"><span style="line-height:22px;background-color:rgb(254,254,254)">function</span></font>.</div>
<div>Can this function solve the following question:</div>
<div>              At beginning, the MPI job uses the mpiexec commond to start three MPI processes. That is to say, there are three MPI processes in MPI_COMM_WORLD. At some time, the job find itself to need another MPI process to cooperate the three MPI processes.
 So the question is: Could PMI help an non-MPI process to become a MPI process of the current MPI_COMM_WORLD? That is to say, Could the non-MPI process use the PMI function to become a member process of the current MPI job which would have FOUR MPI processes
 in MPI_COMM_WORLD?</div>
<div><br>
</div>
<div>Is there some method to solve question?</div>
<div>Is anybody have some example?</div>
<div><br>
</div>
<div>Thandks!!!</div>
</div>
</div>
<br>
<br>
<span title="neteasefooter"><span></span></span><br>
_______________________________________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div></div></div>
<br>
<br>
<span title="neteasefooter"><span></span></span>
</div>

</blockquote></div><br></div>
</blockquote></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>