Boost C++ Libraries: Ticket #6704: Boost version of mpi_in_place https://svn.boost.org/trac10/ticket/6704 <p> In some mpi collective operations, like <a class="ext-link" href="http://www.open-mpi.org/doc/v1.4/man3/MPI_Allreduce.3.php"><span class="icon">​</span>all_reduce</a>, that have an input and output bufer of the same size, it is possible to specify the same buffer for both input and output by using the MPI_IN_PLACE constant as a sendbuffer (see above link). </p> <p> That feature does not seems to be supported through boost::mpi. </p> <p> This can be illustrated through the attached program: </p> <pre class="wiki">alainm@vai:~/code/boost/mpibug$ mpiexec -np 2 ./a.out This is P0 good This is P1 good alainm@vai:~/code/boost/mpibug$ </pre><pre class="wiki">alainm@vai:~/code/boost/mpibug$ mpiexec -np 2 ./a.out bug terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::mpi::exception&gt; &gt;' what(): MPI_Allreduce: MPI_ERR_BUFFER: invalid buffer pointer [vai:03464] *** Process received signal *** terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::mpi::exception&gt; &gt;' what(): MPI_Allreduce: MPI_ERR_BUFFER: invalid buffer pointer [vai:03465] *** Process received signal *** [vai:03465] Signal: Aborted (6) [vai:03465] Signal code: (-6) [vai:03464] Signal: Aborted (6) [vai:03464] Signal code: (-6) [vai:03465] [ 0] [0x4002040c] [vai:03465] *** End of error message *** [vai:03464] [ 0] [0x4002040c] [vai:03464] *** End of error message *** -------------------------------------------------------------------------- mpiexec noticed that process rank 1 with PID 3465 on node vai exited on signal 6 (Aborted). -------------------------------------------------------------------------- 2 total processes killed (some possibly by mpiexec during cleanup) alainm@vai:~/code/boost/mpibug$ </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6704 Trac 1.4.3 Alain Miniussi <alain.miniussi@…> Mon, 19 Mar 2012 10:33:52 GMT attachment set https://svn.boost.org/trac10/ticket/6704 https://svn.boost.org/trac10/ticket/6704 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">allreduce.cpp</span> </li> </ul> <p> c++ source code </p> Ticket Alain Miniussi <alain.miniussi@…> Mon, 19 Mar 2012 10:39:59 GMT <link>https://svn.boost.org/trac10/ticket/6704#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:1</guid> <description> <p> One solution could be to transparently test for equality of the two buffers and silently pass MPI_IN_PLACE to MPI_Allreduce, another could to provide a boost mpi_in_place object with automatic conversion to T*. The first one is probably a no-brainner for user, but then, something explicit in MPI is made implicit in boost mpi. I can provide the patch, other operation could be concerned. </p> <p> Regards, </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Mon, 19 Mar 2012 11:00:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:2</guid> <description> <p> Another issue with th e implicit solution is that the input buffer is not left unchanged, while it is documented as such. So I guess a acceptable solution would be to simply provide a global: </p> <pre class="wiki">namespace boost{ namespace mpi { template&lt;typename T&gt; T const* mpi_in_place(T const* p = 0) { return static_cast&lt;T const*&gt;(MPI_IN_PLACE); } } } </pre><p> function ? </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Tue, 20 Mar 2012 10:20:33 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6704 https://svn.boost.org/trac10/ticket/6704 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mpi_in_place_tck6704_rev77427.patch</span> </li> </ul> <p> A proposed patch for the missing (?) feature) </p> Ticket Alain Miniussi <alain.miniussi@…> Tue, 20 Mar 2012 10:24:46 GMT <link>https://svn.boost.org/trac10/ticket/6704#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:3</guid> <description> <p> The attached path propose a fix for this issue. It add the 'missing' all_reduce prototypes with only one input/output buffer. When appropriate, it is implemented by passing <strong>MPI_IN_PLACE</strong> to the existing boost implementations as a sendbuffer. When it is not possible (user types and user op), it re-introduces the missing buffer and uses a reduce/broadcast combination. The all_reduce test have been updated to check for in place and out of place array all_reduce operations. </p> <p> Please let me know if there is a problem wit this patch. </p> <p> Regards </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Tue, 20 Mar 2012 10:28:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:4</guid> <description> <p> Note that since the new prototype are just an override of existing prototype with only one parameter, the existing documentation probably still holds. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Thu, 11 Oct 2012 09:27:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:5</guid> <description> <p> I think the nicest would be a version that just takes a single inout value. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 11 Oct 2012 10:00:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6704#comment:5" title="Comment 5">troyer</a>: </p> <blockquote class="citation"> <p> I think the nicest would be a version that just takes a single inout value. </p> </blockquote> <p> Agreed, but should we do something about the situation where the user explicitly provides the <strong>MPI_IN_PLACE</strong> argument ? Provided we let the code fail at runtime, should we throw an exception ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Thu, 11 Oct 2012 10:09:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:7</guid> <description> <p> Why would the user want to provide it explicitly if we give a nicer interface to all_reduce that takes just a single inout parameter? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 11 Oct 2012 12:10:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:8</guid> <description> <p> Maybe someone coming from the C api.... but agreed, it's (probably too) far fetched. </p> <p> I will go for the one inout param along with a clarification in the documentation then. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 11 Oct 2012 13:51:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:9</guid> <description> <p> One more question: </p> <p> Right now, in the attached patch, we have </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, const T &amp; in_value, T &amp; out_value, Op op); template&lt;typename T, typename Op&gt; T all_reduce(const communicator &amp; comm, const T &amp; in_value, Op op); template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, const T * in_values, int n, T * out_values, Op op); </pre><p> plus </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, T * inout_values, int n, Op op); </pre><p> but we do not have: </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, T &amp; in_value, Op op); </pre><p> that's based on the assumption that there isn't much usage for it and that it would cause confusing overload issues. </p> <p> I am still trying to find out how to modify the documentation :-) </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Thu, 11 Oct 2012 15:41:17 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6704 https://svn.boost.org/trac10/ticket/6704 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mpi_all_reduce_in_place.patch</span> </li> </ul> <p> updated patch for revision 80953 </p> Ticket Alain Miniussi <alain.miniussi@…> Thu, 11 Oct 2012 15:48:04 GMT <link>https://svn.boost.org/trac10/ticket/6704#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:10</guid> <description> <p> So, the attachment <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6704/mpi_all_reduce_in_place.patch" title="Attachment 'mpi_all_reduce_in_place.patch' in Ticket #6704">mpi_all_reduce_in_place.patch</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6704/mpi_all_reduce_in_place.patch" title="Download">​</a> should implement the proposed modification. It include a inout version of the function for arrays, a modification of the doxygen documentation (what I was unable to test because I have issues with the doc generation) and updated test suite to exercise the feature. </p> <p> Here is a summary of the context in which the patch was produced: </p> <pre class="wiki">[alainm@login02 trunk]$ svn up At revision 80953. [alainm@login02 trunk]$ svn diff &gt; mpi_all_reduce_in_place.patch [alainm@login02 trunk]$ svn status -q M boost/mpi/collectives.hpp M boost/mpi/collectives/all_reduce.hpp M libs/mpi/test/all_reduce_test.cpp M libs/mpi/doc/mpi.qbk [alainm@login02 trunk]$ svn info . Path: . URL: http://svn.boost.org/svn/boost/trunk Repository Root: http://svn.boost.org/svn/boost Repository UUID: b8fc166d-592f-0410-95f2-cb63ce0dd405 Revision: 80953 Node Kind: directory Schedule: normal Last Changed Author: viboes Last Changed Rev: 80950 Last Changed Date: 2012-10-11 01:24:24 +0200 (Thu, 11 Oct 2012) [alainm@login02 trunk]$ </pre><p> Pleae let me know if it's ok. </p> <p> Thanks! </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Thu, 11 Oct 2012 15:48:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:11</guid> <description> <p> I forgot: it was tested with openmpi 1.6.1 </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Thu, 18 Oct 2012 08:39:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:12</guid> <description> <p> Hi, </p> <p> If something more need to be done before it can be commited, please let me know. </p> <p> Regards </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 31 Dec 2012 11:39:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:13</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6704#comment:9" title="Comment 9">anonymous</a>: </p> <blockquote class="citation"> <p> One more question: </p> <p> Right now, in the attached patch, we have </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, const T &amp; in_value, T &amp; out_value, Op op); template&lt;typename T, typename Op&gt; T all_reduce(const communicator &amp; comm, const T &amp; in_value, Op op); template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, const T * in_values, int n, T * out_values, Op op); </pre><p> plus </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, T * inout_values, int n, Op op); </pre><p> but we do not have: </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, T &amp; in_value, Op op); </pre><p> that's based on the assumption that there isn't much usage for it and that it would cause confusing overload issues. </p> </blockquote> <p> After discussing this I find that actually an in-place version that does not return a copy makes more sense for in-place semantics, and the call might be as </p> <pre class="wiki">template&lt;typename T, typename Op&gt; void all_reduce(const communicator &amp; comm, mpi::inplace_t&lt;T&gt; in_value, Op op); </pre><p> where mpi::inplace_t&lt;T&gt; wrapper might be created by an mpi::inplace function. Thus by using mpi::inplace around the one argument we don't return anything. I would not use a two-parameter version where one parameter is replaced by an mpi::inplace placeholder like the C API does. We should go for a nicer C++ API and not try to just copy the C API as the deprecated official MPI C++ API did. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Mon, 31 Dec 2012 11:41:37 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/6704#comment:14 https://svn.boost.org/trac10/ticket/6704#comment:14 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Douglas Gregor</span> to <span class="trac-author">Matthias Troyer</span> </li> </ul> Ticket Alain Miniussi <alain.miniussi@…> Wed, 16 Jan 2013 11:59:59 GMT attachment set https://svn.boost.org/trac10/ticket/6704 https://svn.boost.org/trac10/ticket/6704 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">inplace6704-r82503.patch</span> </li> </ul> <p> patch with explicit inplace version of all reduce </p> Ticket Alain Miniussi <alain.miniussi@…> Wed, 16 Jan 2013 12:04:35 GMT <link>https://svn.boost.org/trac10/ticket/6704#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:15</guid> <description> <p> in <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6704/inplace6704-r82503.patch" title="Attachment 'inplace6704-r82503.patch' in Ticket #6704">inplace6704-r82503.patch</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6704/inplace6704-r82503.patch" title="Download">​</a>, you will find a patch with an explicit in place version of <strong>all_reduce</strong>. Both pointer and non pointer version requires the <strong>inplace</strong> wrapper. </p> <p> A new file has been added, I did put my name in the copyright (I do not know the usage, feel free to modify). </p> </description> <category>Ticket</category> </item> <item> <author>alain.miniussi@…</author> <pubDate>Wed, 24 Jul 2013 09:57:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:16</guid> <description> <p> Hi Matthias, </p> <p> Is it ok for this one to go into trunk ? </p> <p> Thanks, </p> <p> Alain </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Wed, 24 Jul 2013 22:50:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:17</guid> <description> <p> Can you please add documentation for this and a regression test? I will then commit it. </p> </description> <category>Ticket</category> </item> <item> <author>alain.miniussi@…</author> <pubDate>Thu, 25 Jul 2013 13:18:22 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6704 https://svn.boost.org/trac10/ticket/6704 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mpi_all_red-r85156-6704.patch</span> </li> </ul> <p> patch with tests and documentation </p> Ticket anonymous Thu, 25 Jul 2013 13:25:51 GMT <link>https://svn.boost.org/trac10/ticket/6704#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:18</guid> <description> <p> In the last attachment <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6704/mpi_all_red-r85156-6704.patch" title="Attachment 'mpi_all_red-r85156-6704.patch' in Ticket #6704">mpi_all_red-r85156-6704.patch</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6704/mpi_all_red-r85156-6704.patch" title="Download">​</a>, the doc has been updated (mostly the doxigen documentation) the regression test was already in [source:/trunk/libs/mpi/test/all_reduce_test.cpp] (I followed existing practice, that file now also test the new overload). </p> <p> A typo has been fixed in the docbook, but it's been otherwise left untouched (since it's more an optimization than a functionnality, I did not think where was anything to add in there (?)) </p> <p> Let me know if it's ok. </p> <p> Thanks! </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Wed, 28 Aug 2013 13:30:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:19 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:19</guid> <description> <p> It seems that the patch has not been applied, is there a pending issue with the fix ? </p> <p> Best regards </p> <p> Alain </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Wed, 28 Aug 2013 13:55:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6704#comment:20 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:20</guid> <description> <p> It would be good to explain it in the documentation, so that people know about it. Sorry for not being clear but I've been waiting for that. </p> </description> <category>Ticket</category> </item> <item> <author>Alain Miniussi <alain.miniussi@…></author> <pubDate>Thu, 29 Aug 2013 14:35:09 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6704 https://svn.boost.org/trac10/ticket/6704 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket6704-svn85498.patch.gz</span> </li> </ul> <p> patch with tests and documentation </p> Ticket Alain Miniussi <alain.miniussi@…> Thu, 29 Aug 2013 14:40:15 GMT <link>https://svn.boost.org/trac10/ticket/6704#comment:21 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6704#comment:21</guid> <description> <p> <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6704/ticket6704-svn85498.patch.gz" title="Attachment 'ticket6704-svn85498.patch.gz' in Ticket #6704">ticket6704-svn85498.patch.gz</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6704/ticket6704-svn85498.patch.gz" title="Download">​</a> contains the same path augmented with new documentation: </p> <ul><li>in mpi.qbk, an example has been added to illustrate the usage of all_reduce using the in place and out of place version and the possibility of optimization associated with <strong>MPI_IN_PLACE</strong>. </li><li>an entry as been added in the C-mapping section. </li></ul><p> Let me know if this is what is expected. </p> <p> As a side note, we might want to add a similar functionality to reduce at some point (?) </p> <p> Regards </p> </description> <category>Ticket</category> </item> </channel> </rss>