Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: [OMPI users] Trouble with MPI_Recv not filling buffer
From: Patrick Brückner (patrick.brueckner_at_[hidden])
Date: 2013-07-06 14:33:59


Hello,

I am currently learning MPI and there's this problem that I have been
dealing with very long now. I am trying to receive a struct, and in some
very specific cases (when I run with 2/3/4 instances and only
calculating exactly the same number of data). For some weird reason it
seems to work as soon as I have a lot of data to calculate (starting
with N=5, I cannot reproduce the problem).

--- snip ---
data p;
p.collection = malloc(sizeof(int)*N);

printf("[%d] before receiving, data id %d at %d with direction
%d\n",me,p.id,p.position,p.direction);

MPI_Status data_status;
MPI_Recv(&p,1,MPI_data,MPI_ANY_SOURCE,99,MPI_COMM_WORLD,&data_status);
if(data_status.MPI_ERROR != MPI_SUCCESS) {
     printf("[%d] ERROR %d",me,data_status.MPI_ERROR);
     return -1;
}
printf("[%d] received status %d\n",data_status.MPI_ERROR);
received++;
printf("[%0d] received data %d (%d/%d) at position %d with direction
%d\n",me,p.id,received,expected,p.position,p.direction);
--- snip ---

I get this output:

[1] before receiving, data id -1665002272 at 0 with direction 0
[0] received status 0
[1] received data -1665002272 (1/2) at position 0 with direction 0

I am wondering if you had any hint for me, why data is still not having
the correct data but just the old, uninitialized values, and why I don't
get any error. Also I really have no idea, why instance 0 is printing
this status information, as it does not enter this section at all. Is
this some kind of optimazation that I have to turn off?

Thanks for all hints,
Patrick