<div dir="ltr"><div><div>Hi, <br><br></div>I try to familiar with mpi self defined type api, and I directly run a very simple code from LLNL webpage:<br><br>//-----------------------------------------------------------------------------------------------<br clear="all">
</div><div><div><div><pre>#include <font color="#FF0000">"mpi.h"</font>
#include <stdio.h>
#define SIZE 4
int main(argc,argv)
int argc;
char *argv[]; {
int numtasks, rank, source=0, dest, tag=1, i;
float a[SIZE][SIZE] =
{1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0,
13.0, 14.0, 15.0, 16.0};
float b[SIZE];
<font color="#FF0000">MPI_Status stat</font>;
<font color="#FF0000">MPI_Datatype columntype</font>;
<font color="#FF0000">MPI_Init</font>(&argc,&argv);
<font color="#FF0000">MPI_Comm_rank</font>(MPI_COMM_WORLD, &rank);
<font color="#FF0000">MPI_Comm_size</font>(MPI_COMM_WORLD, &numtasks);
<font color="#FF0000">MPI_Type_vector</font>(SIZE, 1, SIZE, MPI_FLOAT, &columntype);
<font color="#FF0000">MPI_Type_commit</font>(&columntype);
if (numtasks == SIZE) {
if (rank == 0) {
for (i=0; i<numtasks; i++)
<font color="#FF0000">MPI_Send</font>(&a[0][i], 1, columntype, i, tag, MPI_COMM_WORLD);
}
<font color="#FF0000">MPI_Recv</font>(b, SIZE, MPI_FLOAT, source, tag, MPI_COMM_WORLD, &stat);
printf("rank= %d b= %3.1f %3.1f %3.1f %3.1f\n",
rank,b[0],b[1],b[2],b[3]);
}
else
printf("Must specify %d processors. Terminating.\n",SIZE);
<font color="#FF0000">MPI_Type_free</font>(&columntype);
<font color="#FF0000">MPI_Finalize</font>();
}</pre>//-----------------------------------------------------------------------------------------------<br><br></div><div>However, it doesn't work. the program just suspend there. I figure out the problem is at line MPI_Send, and MPI_Recv. the MPI_Send just send it to itself. but I don't know why it doesn't work. Is it caused by dead lock? why?<br>
<br></div><div>Thank you very much!<br></div><div><br></div><div>-- <br>Best Regards,<div>Sufeng Niu</div><div>ECASP lab, ECE department, Illinois Institute of Technology</div><div>Tel: 312-731-7219</div>
</div></div></div></div>