Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
8 Views

how to add data already present in the recieve buffer using MPI

Hi I am trying to send a data(forces) across 2 Process, using MPI commands(send and recieve) Usually the data will be over written in the received buffer, i do not want to overwrite the data in the received buffer instead i want to add the data it received. i can do following. Store the data in previous time step to a different array and then add it after receiving, but then i have huge number of nodes and i do not want to have a memory allotted for its storage every time step.(or overwrite the same) My question is there a way to add the received data directly to the buffer and store it in the received memory using MPI? any help in this direction , would be really thankful. i am sure collective communication calls (MPI Reduce)cannot be worked out here.. are they any other commands that can do this?
0 Kudos
1 Reply
Highlighted
Black Belt
8 Views

I'm troubled by your statement that "Usually the data will be over written in the received buffer".If you're using the simple blockingMPI_Send and MPI_Recv, the data should never be overwritten, even if the same process sends additional messages with the same tag. Messages from different processes, even with the same tag, will have a different source process and should not be overwriting anything already stored in the receive buffer. (The above assumes you are talking about the internal MPI receive buffer.)

If the buffer you are referring to is the user-created bufer to hold the contents of a received message, then the fix is simple: don't read a new message into the same memory location. If you receive 10 integers into the array A (that has been declared to hold 10 integers), you will overwrite those ten integers if you receive a new message of 10 integersinto the same array. On the other hand, if you declared A to hold 20 integers, you can avoid this overwriting by giving the first memory location of the second receive buffer as being A[10]. Then, the first ten integers will be in [0]-[9] and the second ten integers will be safely located in [10]-[19].

MPI_Recv(A, 10, MPI_INT, 0, 23, &status_0);
MPI_Recv(&A[10], 10, MPI_INT, 1, 23, &status_1);


If all of the message coming into the process are from all other processes in the computation, you could use the collective communication ofMPI_Gather to collect each message from all the processes and store it into a buffer without overlap. The catch is that the buffer needs to have enough allocated memory space to hold the entire collection of data being received.

Is any of this helpful or close to what you are asking about?

--clay
0 Kudos