Boost C++ Libraries: Ticket #2220: Stack overflow in get_mpi_datatype() for struct declared as primitive_type https://svn.boost.org/trac10/ticket/2220 <p> struct <a class="missing wiki">MyStruct</a> { int dummy; }; </p> <p> BOOST_IS_MPI_DATATYPE(<a class="missing wiki">MyStruct</a>); BOOST_CLASS_IMPLEMENTATION(<a class="missing wiki">MyStruct</a>,primitive_type); ... get_mpi_datatype&lt;<a class="missing wiki">MyStruct</a>&gt;() <em> produces stack overflow </em></p> <p> ## Call stack: get_mpi_datatype&lt;<a class="missing wiki">MyStruct</a>&gt;(); mpi_datatype_map.datatype&lt;<a class="missing wiki">MyStruct</a>&gt;(...); mpi_datatype_oarchive::mpi_datatype_oarchive(const T&amp; x); *this &lt;&lt; x; <em>this serialization in turn calls get_mpi_datatype() </em></p> <p> Possible solution: use another mpi_datatype_oarchive constructor with no serialization (only for MPI_Type_struct() to be called) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2220 Trac 1.4.3 Douglas Gregor Tue, 19 Aug 2008 11:55:48 GMT owner changed https://svn.boost.org/trac10/ticket/2220#comment:1 https://svn.boost.org/trac10/ticket/2220#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Douglas Gregor</span> to <span class="trac-author">Matthias Troyer</span> </li> </ul> <p> Matthias, could you take a look at this? </p> Ticket Matthias Troyer Tue, 19 Aug 2008 13:54:49 GMT <link>https://svn.boost.org/trac10/ticket/2220#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2220#comment:2</guid> <description> <p> The problem is that the serialization mechanism is not used for primitive types. This struct will actually not serialize with a text or XML-based archive either. Why is it declared primitive? </p> <p> To make it work you have to overload get_mpi_datatype for this "primitive" type. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 30 Aug 2008 00:35:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2220#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2220#comment:3</guid> <description> <p> If this behavior is by design, then sorry for this bug ticket. </p> <p> My intention is to transport binary structures on a platform-dependent binary basis, without any member-wise serialization. This must lower CPU utilization and thus increase transfer rates. As far as I know this feature exists in MPI, so I expected to obtain this behavior in the boost wrapper. </p> <p> Exactly, by declaring structures as primitive_type I expected to avoid serialization procedure at all (and actually after such declaration, serialize() becomes unneeded in compile time). But - implementation fails with stack overflow. </p> <p> Can you advise? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Sat, 30 Aug 2008 01:11:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2220#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2220#comment:4</guid> <description> <p> This is not supported since it might fail on heterogeneous machines. We actually have an undocumented feature doing just what you want. You need to declare your type as bitwise serializable and specify at build time that you build for a homogeneous machine. Then at least arrays of this type are transmitted without serialization. We could add further optimizations for single instances. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Evgeny</dc:creator> <pubDate>Sun, 31 Aug 2008 06:16:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2220#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2220#comment:5</guid> <description> <p> Thank you. I think that an option to transfer without serialization might be extremely valuable in homogeneous environments. So this may be a good idea to add corresponding level of serialization (since primitive_type has some other semantics). </p> <p> Will try to build in a way you advised. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Sun, 21 Sep 2008 06:28:10 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2220#comment:6 https://svn.boost.org/trac10/ticket/2220#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket