Boost C++ Libraries: Ticket #2400: Messages corrupted if isend requests are not retained https://svn.boost.org/trac10/ticket/2400 <p> If I do a series of isends and discard the request objects (because I don't need to know when they complete), the messages can get corrupted. I realize this is the way the MPI library is designed, but I'm wondering if it possible to use some C++ goodness to make the request objects persist behind-the-scenes until the request is completed? The behavior is particularly unexpected in the Python layer. Thanks very much! </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2400 Trac 1.4.3 Marshall Clow Fri, 10 Oct 2008 15:51:27 GMT component changed; owner set https://svn.boost.org/trac10/ticket/2400#comment:1 https://svn.boost.org/trac10/ticket/2400#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Douglas Gregor</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">mpi</span> </li> </ul> Ticket Matthias Troyer Thu, 06 Aug 2009 18:56:43 GMT owner, status changed https://svn.boost.org/trac10/ticket/2400#comment:2 https://svn.boost.org/trac10/ticket/2400#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Douglas Gregor</span> to <span class="trac-author">Matthias Troyer</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Matthias Troyer Thu, 06 Aug 2009 20:39:18 GMT <link>https://svn.boost.org/trac10/ticket/2400#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2400#comment:3</guid> <description> <p> The reason is that when sending anything other than MPI datatypes, the object is serialized by Boost.Serialization into a temporary buffer, which is then associated with the request object. Using isend with Boost.MPI one always has to wait for completion of the request and cannot discard it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Thu, 06 Aug 2009 20:42:13 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2400#comment:4 https://svn.boost.org/trac10/ticket/2400#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket Matthias Troyer Thu, 06 Aug 2009 20:44:50 GMT <link>https://svn.boost.org/trac10/ticket/2400#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2400#comment:5</guid> <description> <p> This is not a bug but intended behavior. A note has been added to the documentation. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 07 Aug 2009 16:42:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2400#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2400#comment:6</guid> <description> <p> OK, I understand, but in Python one normally does not have to worry about when it is safe to deallocate an object, as the GC is supposed to take care of this for you. Is there no way to increment the Python reference count of the request object or its buffer until it is completed? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Fri, 07 Aug 2009 17:01:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2400#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2400#comment:7</guid> <description> <p> No, the basic issue is that: you *have to* call wait on the request to finish the irecv or isend operation and cannot just discard the object. If you do not call wait, the code never checks for completion. There are a few solutions, that are sub-optimal: </p> <p> 1.) keep the buffer alive as you propose, but that will lead to a memory leak since the request obejct is the only one who knows about the buffer. If you discard the request there will be a leak since nobody ever checks for completion. </p> <p> 2.) have the destructor call wait - but then the code might just hang or deadlock in the destructor, which would be very hard to debug. </p> <p> 3.) have the destructor cancel the request, but then again this leads to unexpected behavior, if one discards the request: this automatically cancels the send! </p> <p> The best option as I can see is to: </p> <p> 4.) assert on the precondition to the destructor, namely that the request has to be finished. Note that we cannot throw an exception in a destructor have to abort. </p> <p> I don't like option 4 either but it seems the safest and will at least tell you that you forgot to wait for completion. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Tue, 01 Jan 2013 10:59:07 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/2400#comment:8 https://svn.boost.org/trac10/ticket/2400#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> We should revisit this ticket since MPI 3 now explicitly allows requests to be discarded and we should try to mimic this. This will require us to keep buffers alive and perform garbage collection from time to time when requests are done. </p> Ticket