On Nov 1, 2005, at 2:34 PM, dennis lastor wrote:
> I am trying to pass a 1D array using MPI_Send / MPI_Recv. The array
> gets passed properly, but then it appears as if I hang on the receive.
> Here is a snippet of the code I am using:
>
> float node0[400];
> ....
> float data_buf[400];
>
> if (node == 0) {
> .....
> .....
> node1[0] = 0.1;
> node1[1] = 0.4;
> node1_cnt = 2;
> MPI_Send( &node1 , node1_cnt, MPI_FLOAT, 1, 1, comm_2d);
>
> }//while still master
>
> MPI_Recv( data_buf , 2, MPI_FLOAT, 0, 1, comm_2d, NULL);
> printf("BUFFER %f %f \n",data_buf[0],data_buf[1]);
>
> MPI_Finalize();
> }
>
> I get the following output:
>
> BUFFER 0.100000 0.400000
>
> Which implies that the receive completed, but then it hangs.
You don't really give enough of the program to know what is really
going on. But it looks like rank 0 sends a message to rank 1, and
then both ranks sit in a receive. The rank 1 receive will complete,
but the rank 0 receive will never complete because no one sends to
it. Hence, the hang.
But I could be wrong - it's hard to tell from your code. You might
want debugging section of the LAM/MPI FAQ, at:
http://www.lam-mpi.org/faq/category6.php3
In particular, you should look at where each program is waiting and
make sure that each receive has a matching send.
Hope this helps,
Brian
--
Brian Barrett
LAM/MPI developer and all around nice guy
Have a LAM/MPI day: http://www.lam-mpi.org/
|