<div dir="ltr"><div><div>Hi, Pavan,<br><br>Thanks a lot, that is most confusing part for me in MPI. I would like to clear this type of problems.<br><br></div>So the blocking begins to send message to itself, but there is no receive posted. Thus, the MPI block it. Am I right here?<br>
<br></div><div>Thus, I need a nonblocking receive to wait the message here. Can I use blocking receive?<br></div><div><br></div><div>Hi Jeff,<br><br></div><div>The weblink is <a href="https://computing.llnl.gov/tutorials/mpi/#Derived_Data_Types">https://computing.llnl.gov/tutorials/mpi/#Derived_Data_Types</a><br>
</div><div>the code is second example. Thank you<br></div><div><br></div><div>Thanks a lot!<br></div><div>Sufeng<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 2, 2013 at 4:48 PM, Pavan Balaji <span dir="ltr"><<a href="mailto:balaji@mcs.anl.gov" target="_blank">balaji@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
This is an incorrect program.  You need to post an Irecv before sending to yourself.<br>
<br>
 -- Pavan<div><div class="h5"><br>
<br>
On 07/02/2013 04:39 PM, Sufeng Niu wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi,<br>
<br>
I try to familiar with mpi self defined type api, and I directly run a<br>
very simple code from LLNL webpage:<br>
<br>
//----------------------------<u></u>------------------------------<u></u>------------------------------<u></u>-------<br>
<br>
#include"mpi.h"<br>
#include <stdio.h><br>
#define SIZE 4<br>
<br>
int main(argc,argv)<br>
int argc;<br>
char *argv[];  {<br>
int numtasks, rank, source=0, dest, tag=1, i;<br>
float a[SIZE][SIZE] =<br>
   {1.0, 2.0, 3.0, 4.0,<br>
    5.0, 6.0, 7.0, 8.0,<br>
    9.0, 10.0, 11.0, 12.0,<br>
   13.0, 14.0, 15.0, 16.0};<br>
float b[SIZE];<br>
<br>
MPI_Status stat;<br>
MPI_Datatype columntype;<br>
<br>
MPI_Init(&argc,&argv);<br>
MPI_Comm_rank(MPI_COMM_WORLD, &rank);<br>
MPI_Comm_size(MPI_COMM_WORLD, &numtasks);<br>
<br>
MPI_Type_vector(SIZE, 1, SIZE, MPI_FLOAT, &columntype);<br>
MPI_Type_commit(&columntype);<br>
<br>
if (numtasks == SIZE) {<br>
   if (rank == 0) {<br>
      for (i=0; i<numtasks; i++)<br>
        MPI_Send(&a[0][i], 1, columntype, i, tag, MPI_COMM_WORLD);<br>
         }<br>
<br>
   MPI_Recv(b, SIZE, MPI_FLOAT, source, tag, MPI_COMM_WORLD, &stat);<br>
   printf("rank= %d  b= %3.1f %3.1f %3.1f %3.1f\n",<br>
         rank,b[0],b[1],b[2],b[3]);<br>
   }<br>
else<br>
   printf("Must specify %d processors. Terminating.\n",SIZE);<br>
<br>
MPI_Type_free(&columntype);<br>
MPI_Finalize();<br>
}<br>
<br>
//----------------------------<u></u>------------------------------<u></u>------------------------------<u></u>-------<br>
<br>
However, it doesn't work. the program just suspend there. I figure out<br>
the problem is at line MPI_Send, and MPI_Recv. the MPI_Send just send it<br>
to itself. but I don't know why it doesn't work. Is it caused by dead<br>
lock? why?<br>
<br>
Thank you very much!<br>
<br>
--<br>
Best Regards,<br>
Sufeng Niu<br>
ECASP lab, ECE department, Illinois Institute of Technology<br>
Tel: <a href="tel:312-731-7219" value="+13127317219" target="_blank">312-731-7219</a><br>
<br>
<br></div></div>
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/discuss</a><br>
<br><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Pavan Balaji<br>
<a href="http://www.mcs.anl.gov/~balaji" target="_blank">http://www.mcs.anl.gov/~balaji</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Best Regards,<div>Sufeng Niu</div><div>ECASP lab, ECE department, Illinois Institute of Technology</div><div>Tel: 312-731-7219</div>
</div>