Thanks! Gus and Rajeev for your feedback on my MPICH deadlock error post earlier in February.<br>Our model code now works successfully with the latest stable mpich2 (mpich2 1.4.1p1)  version after modifying the MPI calls as per your suggestions.<br>
<br>The code uses Master/Slave MPI implementation and was originally set up for a cluster of single core nodes controlled by a head node. <br><br>The code also works well with a single node multiple cores set up. <br><br>
Now I am testing this code on mutiple nodes each with multiple cores. The nodes are set up for password less login via ssh. The run hangs sometimes and takes longer to complete. (The run with single node 12 cores is faster than the corresponding run using  2 nodes each with 12 cores (total 24)).<br>
<br>I am trying to resolve this issue and wondering if you have any feedback on:<br>1. Does Master/Slave implementation need any specific settings to work across mutliple node/mutliple core machine set up?<br>2. Is there any way to explicitly specify a core as a master with mpich2 and exclude it from computations?<br>
<br>I would greatly appreciate any other pointers/suggestions about this issue.<br><br>Thanks,<br>Sarika<br><br><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Gustavo Correa</b> <span dir="ltr">&lt;<a href="mailto:gus@ldeo.columbia.edu">gus@ldeo.columbia.edu</a>&gt;</span><br>
Date: Tue, Feb 14, 2012 at 10:04 AM<br>Subject: Re: [mpich-discuss] MPICH deadlock error<br>To: <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br><br><br><div class="im"><br>
On Feb 13, 2012, at 8:05 PM, Sarika K wrote:<br>
<br>
&gt; Thanks! Gus. I appreciate your feedback.<br>
&gt;<br>
&gt; I looked through the MPI communication and driver code (written way back in 2001) , it does includes calls to MPI_Bcast (Attached below is a sample code). I am not sure why MPI_send /MPI_Recv is used in some places and MPI_Bcast in others.  I have started to learn more details about MPI calls only after encountering this deadlock error. Are there any particular cases/instances where MPI_send /MPI_Recv call set up is preferred over MPI_bcast or vice-versa?<br>

&gt;<br>
&gt; Best regards,<br>
&gt; Sarika<br>
<br>
</div>Hi Sarika<br>
<br>
When one process sends the *same* data to all other processes in a communicator,<br>
the situation begs for MPI_Bcast.<br>
Point to point communication (send/recv) is preferred when the data exchanged across<br>
different pairs of processes is different.<br>
MPI_Bcast is but one type of MPI collective procedures.<br>
There are several others with different goals [e.g. MPI_Scatter[v] and MPI_Gather[v], say,<br>
when parts of an array is distributed/collected by a master process].<br>
<br>
Check these MPI tutorials:<br>
<a href="http://www.citutor.org/browse.php" target="_blank">http://www.citutor.org/browse.php</a><br>
<a href="https://computing.llnl.gov/tutorials/mpi/" target="_blank">https://computing.llnl.gov/tutorials/mpi/</a><br>
<a href="http://www.mcs.anl.gov/research/projects/mpi/tutorial/" target="_blank">http://www.mcs.anl.gov/research/projects/mpi/tutorial/</a><br>
<a href="http://www.mcs.anl.gov/research/projects/mpi/tutorial/gropp/talk.html" target="_blank">http://www.mcs.anl.gov/research/projects/mpi/tutorial/gropp/talk.html</a><br>
<a href="http://www.cs.usfca.edu/%7Epeter/ppmpi/" target="_blank">http://www.cs.usfca.edu/~peter/ppmpi/</a><br>
<div class="HOEnZb"><div class="h5"><br>
I hope this helps,<br>
Gus Correa<br>
<br>
&gt;<br>
&gt; (MPI_Bcast sample code)<br>
&gt;       Nbuf = ix+iy+iz+is+4<br>
&gt;       if (Master) then<br>
&gt;         k=0<br>
&gt;     buf(k+1:k+ix)=dx(1:ix) ; k=k+ix<br>
&gt;     buf(k+1:k+iy)=dy(1:iy) ; k=k+iy<br>
&gt;     buf(k+1:k+iz)=sigmaz(1:iz) ; k=k+iz<br>
&gt;     buf(k+1)=dht ; k=k+1<br>
&gt;     buf(k+1)=baseh ; k=k+1<br>
&gt;     buf(k+1:k+is)=rmw(1:is) ; k=k+is<br>
&gt;     buf(k+1)=dt ; k=k+1<br>
&gt;     buf(k+1)=ut ; k=k+1<br>
&gt;     if (k.ne.Nbuf) then<br>
&gt;       print*, &#39;Error in real_distrib. Nbuf=&#39;,Nbuf,<br>
&gt;      &amp;             &#39;   needed=&#39;,k<br>
&gt;           stop<br>
&gt;     endif<br>
&gt;       endif<br>
&gt; c<br>
&gt;       call MPI_BCAST(buf(1),Nbuf,MPI_REAL,0,MPI_COMM_WORLD,Ierr)<br>
&gt; c<br>
&gt;       if (Worker) then<br>
&gt;         k=0<br>
&gt;     dx(1:ix)=buf(1:ix) ; k=ix<br>
&gt;     dy(1:iy)=buf(k+1:k+iy) ; k=k+iy<br>
&gt;     sigmaz(1:iz)=buf(k+1:k+iz) ; k=k+iz<br>
&gt;     dht=buf(k+1) ; k=k+1<br>
&gt;     baseh=buf(k+1) ; k=k+1<br>
&gt;     rmw(1:is)=buf(k+1:k+is); k=k+is<br>
&gt;     dt=buf(k+1); k=k+1<br>
&gt;     ut=buf(k+1); k=k+1<br>
&gt;       endif<br>
&gt;<br>
&gt; On Mon, Feb 13, 2012 at 4:05 PM, Gustavo Correa &lt;<a href="mailto:gus@ldeo.columbia.edu">gus@ldeo.columbia.edu</a>&gt; wrote:<br>
&gt; Hi Sarika<br>
&gt;<br>
&gt; I think you may also need an MPI_Wait or MPI_Waitall after the MPI_Recv.<br>
&gt;<br>
&gt; However, your code seems to broadcast  the same &#39;buf&#39; from Master to all Workers, right?<br>
&gt; Have you tried to use MPI_Bcast, instead of MPI_Send &amp; MPI_Recv?<br>
&gt; A collective call, and is likely to perform better.<br>
&gt; Something like this:<br>
&gt;<br>
&gt; if (Master) then<br>
&gt;  ...load buf with data<br>
&gt; endif<br>
&gt;<br>
&gt; call MPI_Bcast(buf, ...)  ! every process calls it<br>
&gt;<br>
&gt; if (Worker) then<br>
&gt;  ... unload data from buf<br>
&gt; endif<br>
&gt;<br>
&gt; I hope this helps,<br>
&gt; Gus Correa<br>
&gt;<br>
&gt; On Feb 13, 2012, at 5:03 PM, Sarika K wrote:<br>
&gt;<br>
&gt; &gt; Thanks! Rajeev for the quick feedback. I really appreciate it.  I have used but never never written/modified MPI code. I am assuming that I need to use the nonblocking routine MPI_Isend within the if (master) part of the sample code. Is that right?<br>

&gt; &gt;<br>
&gt; &gt; Best regards,<br>
&gt; &gt; Sarika<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Mon, Feb 13, 2012 at 1:45 PM, Rajeev Thakur &lt;<a href="mailto:thakur@mcs.anl.gov">thakur@mcs.anl.gov</a>&gt; wrote:<br>
&gt; &gt; This will happen if the master is also sending to itself, and calls MPI_Send(to itself) before MPI_Recv(from itself). You need to either use a nonblocking send or post a nonblocking receive before the blocking send.<br>

&gt; &gt;<br>
&gt; &gt; Rajeev<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Feb 13, 2012, at 3:28 PM, Sarika K wrote:<br>
&gt; &gt;<br>
&gt; &gt; &gt; Dear MPICH-discuss group:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; My work involves working with Fortran Code using MPICH for parallelization. But I have a very limited experience with the details of MPICH implementation. (I have always treated the MPICh part of the code as a black box).<br>

&gt; &gt; &gt;<br>
&gt; &gt; &gt; I am now working on porting the code across different machine configurations. My modeling code works fine on some machines/servers. But it also generates random MPI deadlock errors when running the simulations across other machines/servers.<br>

&gt; &gt; &gt;<br>
&gt; &gt; &gt; The error message is below.<br>
&gt; &gt; &gt; &quot;Fatal error in MPI_Send: Other MPI error, error stack:<br>
&gt; &gt; &gt; MPI_Send(174): MPI_Send(buf=0x7f4d9b375010, count=1, dtype=USER&lt;vector&gt;, dest=1, tag=10001, MPI_COMM_WORLD) failed<br>
&gt; &gt; &gt; MPID_Send(53): DEADLOCK: attempting to send a message to the local process without a prior matching receive&quot;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I searched this list/other resources for this error code and strongly believe that there is a bug in the model MPI implementation code which remains dormant in some environments and works fine due to the internal buffering threshold dependance.<br>

&gt; &gt; &gt;<br>
&gt; &gt; &gt; I am not sure if this is sufficient information, but attached below sample subroutine (there are many inside the code) which generates the deadlock error.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I would really appreciate any help/pointers from the group to fix this error in our code.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks in advance for your time and assistance,<br>
&gt; &gt; &gt; Sarika<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; c-----------------------------------------------------------------------------------------------------------------------------<br>
&gt; &gt; &gt;       subroutine int_distrib1(iend)<br>
&gt; &gt; &gt; c-----------------------<br>
&gt; &gt; &gt; c  Master distributes another bunch of integers to Workers<br>
&gt; &gt; &gt; c-----------------------------------------------------------------------------------------------------------------------------<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt;       use ParallelDataMap<br>
&gt; &gt; &gt;       use CommDataTypes<br>
&gt; &gt; &gt;       implicit none<br>
&gt; &gt; &gt;       include &#39;mpif.h&#39;<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt;       include &#39;aqmax.param&#39;<br>
&gt; &gt; &gt;       include &#39;aqindx.cmm&#39;<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt;       integer :: iend<br>
&gt; &gt; &gt;       integer, parameter ::  Nbuf=35<br>
&gt; &gt; &gt;       integer ::  i, j, k, buf(Nbuf), Ierr, status(MPI_STATUS_SIZE)<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt;       if (Master) then<br>
&gt; &gt; &gt; ! arguments<br>
&gt; &gt; &gt;     buf(1) = iend<br>
&gt; &gt; &gt; !  /aqspid/ in aqindx.cmm stuff<br>
&gt; &gt; &gt;     buf(2) = iair<br>
&gt; &gt; &gt;     buf(3) = ih2o<br>
&gt; &gt; &gt;     buf(4) = io2<br>
&gt; &gt; &gt;     buf(5) = ico<br>
&gt; &gt; &gt;     buf(6) = ino2<br>
&gt; &gt; &gt;     buf(7) = iho2<br>
&gt; &gt; &gt;     buf(8) = iso2<br>
&gt; &gt; &gt;     buf(9) = io3<br>
&gt; &gt; &gt;     buf(10)= ich4<br>
&gt; &gt; &gt;     buf(11)= ico2<br>
&gt; &gt; &gt;     buf(12)= ih2<br>
&gt; &gt; &gt;     buf(13)= in2<br>
&gt; &gt; &gt;     buf(14)= itrace<br>
&gt; &gt; &gt;     k=15<br>
&gt; &gt; &gt;     buf(k:k+9) = ispg_idx(1:10); k=k+10<br>
&gt; &gt; &gt;     buf(k:k+9) = ispl_idx(1:10); k=k+10<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     do i=1,Nworkers<br>
&gt; &gt; &gt;       call MPI_SEND(buf, Nbuf, MPI_INTEGER,<br>
&gt; &gt; &gt;      &amp;         i, i,  MPI_COMM_WORLD, Ierr)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     enddo<br>
&gt; &gt; &gt;     print*, &#39;&#39;<br>
&gt; &gt; &gt;     print*, &#39;done sending int_distrib1&#39;<br>
&gt; &gt; &gt;     print*, &#39;&#39;<br>
&gt; &gt; &gt;       endif   !   (Master)<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt;       if (Worker) then<br>
&gt; &gt; &gt;         call MPI_RECV(buf, Nbuf, MPI_INTEGER, 0, MyId,<br>
&gt; &gt; &gt;      &amp;                 MPI_COMM_WORLD, status, ierr)<br>
&gt; &gt; &gt;     iend  = buf(1)<br>
&gt; &gt; &gt; ! /aqspid/ in aqindx.cmm stuff<br>
&gt; &gt; &gt;     iair  = buf(2)<br>
&gt; &gt; &gt;     ih2o  = buf(3)<br>
&gt; &gt; &gt;     io2   = buf(4)<br>
&gt; &gt; &gt;     ico   = buf(5)<br>
&gt; &gt; &gt;     ino2  = buf(6)<br>
&gt; &gt; &gt;     iho2  = buf(7)<br>
&gt; &gt; &gt;     iso2  = buf(8)<br>
&gt; &gt; &gt;     io3   = buf(9)<br>
&gt; &gt; &gt;     ich4  = buf(10)<br>
&gt; &gt; &gt;     ico2  = buf(11)<br>
&gt; &gt; &gt;     ih2   = buf(12)<br>
&gt; &gt; &gt;     in2   = buf(13)<br>
&gt; &gt; &gt;     itrace= buf(14)<br>
&gt; &gt; &gt;     k=15<br>
&gt; &gt; &gt;     ispg_idx(1:10) = buf(k:k+9); k=k+10<br>
&gt; &gt; &gt;     ispl_idx(1:10) = buf(k:k+9); k=k+10<br>
&gt; &gt; &gt;     print*, &#39;&#39;<br>
&gt; &gt; &gt;     print*, &#39;done receiving int_distrib1&#39;<br>
&gt; &gt; &gt;     print*, &#39;&#39;<br>
&gt; &gt; &gt;       endif  !    (Worker)<br>
&gt; &gt; &gt; c<br>
&gt; &gt; &gt;       end  subroutine int_distrib1<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; mpich-discuss mailing list     <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
&gt; &gt; &gt; To manage subscription options or unsubscribe:<br>
&gt; &gt; &gt; <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; mpich-discuss mailing list     <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
&gt; &gt; To manage subscription options or unsubscribe:<br>
&gt; &gt; <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; mpich-discuss mailing list     <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
&gt; &gt; To manage subscription options or unsubscribe:<br>
&gt; &gt; <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; mpich-discuss mailing list     <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
&gt; To manage subscription options or unsubscribe:<br>
&gt; <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; mpich-discuss mailing list     <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
&gt; To manage subscription options or unsubscribe:<br>
&gt; <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
<br>
_______________________________________________<br>
mpich-discuss mailing list     <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
</div></div></div><br>