<div style="font-family: Helvetica; font-size: 13px;">The way you’re doing things is theoretically fine, but unnecessary. In MPI, it’s fine to not know the size of the message before you receive it (as long as you know the type). Instead of sending around “pre-messages” with all of the meta-data, you can use MPI_Probe (<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Probe.html">http://www.mpich.org/static/docs/latest/www3/MPI_Probe.html</a>) which will give you information about the next message that you’ll receive (there are other variants that you might prefer to use like MPI_Iprobe, MPI_Mprobe, etc.).</div><div style="font-family: Helvetica; font-size: 13px;"><br></div><div style="font-family: Helvetica; font-size: 13px;">Have a look at the documentation at the link above, but generally, you’ll probe MPI to find out information about the next message such as the source and the size. Then you can create your buffers appropriately and avoid lots of extra buffer creation / destruction calls.</div><div style="font-family: Helvetica; font-size: 13px;"><br></div><div style="font-family: Helvetica; font-size: 13px;">Thanks,</div><div style="font-family: Helvetica; font-size: 13px;">Wesley</div>
                <div></div>
                 
                <p style="color: #A0A0A8;">On Tuesday, May 27, 2014 at 11:15 AM, Grindeanu, Iulian R. wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hello,<br>
We are trying to track down a memory leak, and we are not sure if we are using correctly MPI_ISend and MPI_Irecv<br>
<br>
We would like to use non-blocking communication, between pairs of processes.<br>
<br>
(it happens during a computation, at every time step; every processor has a list of processors it needs to communicate with; what we do not know, is the size of the messages, in advance)<br>
<br>
Let's assume A needs to send to B<br>
Because we do not know the size in advance, we send first a fixed size message from A to B; this first message has info about how big the total message needs to be; A knows it has to send more. When B receives the first part, it sends an ack (small size, int
 4) to A, acknowledging, and also resizing the local buffer, to fill more data; then A sends the rest.<br>
<br>
All these sends / receives use Isend and Irecv, and we try to match the messages, using proper tags. We use different tags for fixed size, ack, and rest of the message.<br>
<br>
Before sending the code, I would like to know is what we try is feasible and doable?<br>
<br>
We notice that the memory use on processor A keeps increasing, when we do this in a loop, on the order of about 1000-2000 bytes per iteration.
<br>
<br>
I think we are matching correctly isends and ireceives, and that our buffers are not leaking (we may be wrong)<br>
<br>
So again, an iteration is like this:<br>
A sends a fixed size message to B; B sends back an ack, and when A receives it, sends the rest, because B has now the proper buffer to receive.<br>
<br>
Next iteration, the size of the message is again unknown, so we do again the dance.<br>
<br>
Do you have an example like that we can use? Should we use other types of sends/receives?<br>
<br>
Thanks,<br>
Iulian<br>
</div>


</div></div></span>
                 
                 
                <div style="border-bottom: 1px solid #f0f0f0; height: 10px;">
                </div>
                <br>
                 
                <div style="font-weight: bold; font-size: 14px; margin-bottom: 5px;">Attachments:</div>
                 
                 
                 
                 
                 
                 
                 
                <div>
                     
                    <div style="">- ATT00001.txt</div>
                     
                </div>
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>