Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] MPI_Recv hangs
From: Eduardo Morras (nec556_at_[hidden])
Date: 2012-05-04 10:44:16

At 15:20 04/05/2012, you wrote:
>Ups, I edited the code to make it easier to understand but I forgot
>to change two p2, sorry ^^' .
>I hope this one is completely right:
>1: for(int p1=0; p1<np; ++p1) {
>2: for(int p2=0; p2<np; ++p2) {
>3: if(me==p1) {
>4: if(sendSize(p2))
>//processor p1 sends data to processor p2
>5: if(recvSize(p2))
>//processor p1 receives data to processor p2
>6: } else if(me==p2) {
>7: if(recvSize(p1))
>//processor p2 receives data to processor p1
>8: if(sendSize(p1))
>//processor p2 sends data to processor p1
>9: }
>10: MPI_Barrier(myw);
>11: }
>12: }

Now p1 will send messages to p2 and receive messages from p2

Now p2 will send messages to p1 and receive messages from p1

The logic of send/recv looks ok. Now, in 5 and 7, recvSize(p2) and
recvSize(p1) function what value returns? The size of the buffer
received from the MPI_Recv done in previous for loop?

>This is the real code:
>for(int p1=0; p1<mpiS; ++p1) {
>for(int p2=0; p2<mpiS; ++p2) {
>if(mpiR==p1) {
>if(ite>25) cout<<"p1("<<p1<<") enviar "<<sento<<"
>"<<s.getMem(sento)<<" FLOATS "<<endl;

Don't know what are you doing here, second parameter, s.getMem(sento)
should be the size of the buffer.

MPI_Ssend is defined for c++ :

   void Comm::Ssend(const void* buf, int count, const Datatype&
datatype, int dest, int tag) const

and you are using the C call. Are you mixing c and c++ code? Be
careful with that.

The rest of your code has the same problems, check them. Perhaps you
need a tutorial, check , it's for mpich
but is mpi-flavourless, so it works with openmpi too.

>Thanks Eduardo

HTH and happy coding