Search code examples
c++cipcmpiopenmpi

best way to send data(given in Bytes) to a process in openMPI?


I am doing like this , Suppose i need to send temp amount of bytes to root process :

var char*;
var=new char[temp];
MPI_Isend(&temp,1,MPI_INT,0,tag,MPI_COMM_WORLD,&request[0]);
MPI_Isend(var,temp,MPI_BYTE,0,tag,MPI_COMM_WORLD,&request[1]);

and on the root process ,i am writing this code ,

MPI_Recv(&temp,1,MPI_INT,i,tag,MPI_COMM_WORLD,&status[0]);
var=new char[temp];
MPI_Recv(var,temp,MPI_BYTE,0,tag,MPI_COMM_WORLD,&status[1]);

I am able to receive temp(amount of data bytes to be transfered) at root process and seeing error of truncated message for the next part ?


Solution

  • You are receiving from the wrong location:

    MPI_Recv(var,temp,MPI_BYTE,0,tag,MPI_COMM_WORLD,&status[1]);
                               ^
    

    You should be receiving from (presumably), the i process.