<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">One problem is that the spawned child is not calling MPI_INTERCOMM_MERGE. The child needs to call the merge function in the 'else' part of your 'if (parentcomm == MPI_COMM_NULL)'.<br>
<br>
-Nick<br>
<div style="font-family: Times New Roman; color: rgb(0, 0, 0); font-size: 16px;">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF597404"><font color="#000000" face="Tahoma" size="2"><b>From:</b> mpich-discuss-bounces@mcs.anl.gov [mpich-discuss-bounces@mcs.anl.gov] on behalf of Umit [umitcanyilmaz@gmail.com]<br>
<b>Sent:</b> Thursday, February 16, 2012 7:06 AM<br>
<b>To:</b> mpich-discuss@mcs.anl.gov<br>
<b>Subject:</b> [mpich-discuss] Howto use MPI_Comm_merge together with MPI_Comm_spawn<br>
</font><br>
</div>
<div></div>
<div>Hello All, <br>
<br>
Can anyone tell me what is wrong with this simple code:<br>
<br>
#define NUM_SPAWNS 4<br>
double timer;<br>
int i; <br>
char str[100]; <br>
int main( int argc, char *argv[] )<br>
{<br>
&nbsp;&nbsp;&nbsp; MPI_Comm parentcomm, intercomm;<br>
&nbsp;&nbsp;&nbsp; MPI_Comm comm, scomm;<br>
&nbsp;&nbsp;&nbsp; MPI_Init( &amp;argc, &amp;argv );<br>
&nbsp;&nbsp;&nbsp; MPI_Comm_get_parent( &amp;parentcomm );<br>
&nbsp;&nbsp;&nbsp; int np = NUM_SPAWNS; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; int size; <br>
&nbsp;&nbsp;&nbsp; MPI_Comm_size( MPI_COMM_WORLD , &amp;size );<br>
&nbsp;&nbsp;&nbsp; if (parentcomm == MPI_COMM_NULL)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scomm = MPI_COMM_WORLD; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; int errcodes[np];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MPI_Comm_spawn( &quot;/home/test/Desktop/merge/./a.out&quot;, MPI_ARGV_NULL, np, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &amp;intercomm, errcodes );<br>
&nbsp; &nbsp; &nbsp;&nbsp; MPI_Intercomm_merge( intercomm, 1, &amp;comm );<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;I'm the spawned.\n&quot;);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; MPI_Finalize();<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
I called MPI_Intercomm_merge outside of if statement but I got the same error. <br>
Spawn is successfull. I have especially tested it. If I try to merge, i got the following error:<br>
<br>
test@ubuntu:~/Desktop/merge$ mpirun -np 1 ./a.out<br>
I'm the spawned.<br>
I'm the spawned.<br>
I'm the spawned.<br>
I'm the spawned.<br>
Fatal error in MPI_Intercomm_merge: Other MPI error, error stack:<br>
MPI_Intercomm_merge(288)..........: MPI_Intercomm_merge(comm=0x84000000, high=1, newintracomm=0xbf97ff40) failed<br>
MPI_Intercomm_merge(263)..........: <br>
MPIR_Get_contextid(639)...........: <br>
MPI_Allreduce(773)................: MPI_Allreduce(sbuf=MPI_IN_PLACE, rbuf=0xbf97fd18, count=64, MPI_INT, MPI_BAND, comm=0x84000002) failed<br>
MPIR_Allreduce(289)...............: <br>
MPIC_Sendrecv(161)................: <br>
MPIC_Wait(513)....................: <br>
MPIDI_CH3I_Progress(150)..........: <br>
MPID_nem_mpich2_blocking_recv(948): <br>
MPID_nem_tcp_connpoll(1720).......: <br>
state_commrdy_handler(1556).......: <br>
MPID_nem_tcp_recv_handler(1446)...: socket closed<br>
rank 0 in job 21&nbsp; ubuntu_38267&nbsp;&nbsp; caused collective abort of all ranks<br>
&nbsp; exit status of rank 0: killed by signal 9 <br>
<br>
<br>
Thanks In Advance, <br>
<br>
<br>
</div>
</div>
</div>
</body>
</html>