Boost C++ Libraries: Ticket #13513: Nvidia cuda compiler 9 does not work with boost::mp11 https://svn.boost.org/trac10/ticket/13513 <p> I am working with cuda and I choose to use boost::mp11 for my projects. However cuda 9 does not work with boost::mp11, even this simple application fails: </p> <pre class="wiki">#include &lt;boost/mp11.hpp&gt; int main() {} </pre><p> To be fair, this seems to be a bug in the nvidia compiler not boost, but this is a showstopper for using boost::mp11 together with a recent cuda version. Everything works fine with cuda 8. </p> <p> I already figured out, what fails in the background in the nvcc (details are <a class="ext-link" href="https://github.com/ComputationalRadiationPhysics/alpaka/issues/459#issuecomment-377678240"><span class="icon">​</span>here</a>), but now also found a work around for boost::mp11: </p> <p> The problem occurs on code like this: </p> <pre class="wiki">template&lt;template&lt;class...&gt; class F, class... T&gt; using mp_defer = mp_if&lt;mp_valid&lt;F, T...&gt;, detail::mp_defer_impl&lt;F, T...&gt;, detail::mp_no_type&gt;; </pre><p> Everytime mp_if is used, the nvcc preprocessor tries to be "smart" and starts recursively replacing stuff so that in the end detail::mp_no_type... is given to the compiler. </p> <p> I figured out I can prevent nvcc from doing this with invoking another struct inbetween like this: </p> <pre class="wiki">template&lt;template&lt;class...&gt; class F, class... T&gt; struct cuda_workaround { using type = mp_if&lt;mp_valid&lt;F, T...&gt;, detail::mp_defer_impl&lt;F, T...&gt;, detail::mp_no_type&gt;; }; template&lt;template&lt;class...&gt; class F, class... T&gt; using mp_defer = typename cuda_workaround&lt; F, T... &gt;::type; </pre><p> This work around is needed on 5 places in the boost mp11: </p> <ul><li>mp_append.hpp <pre class="wiki">template&lt;class... L&gt; struct mp_append_impl: mp_if_c&lt;(sizeof...(L) &gt; 111), mp_quote&lt;append_inf_impl&gt;, mp_if_c&lt;(sizeof...(L) &gt; 11), mp_quote&lt;append_111_impl&gt;, mp_quote&lt;append_11_impl&gt; &gt; &gt;::template fn&lt;L...&gt; </pre></li><li>algorithm.hpp <pre class="wiki">template&lt;template&lt;class...&gt; class F, class... L&gt; using mp_transform = typename mp_if&lt;mp_same&lt;mp_size&lt;L&gt;...&gt;, detail::mp_transform_impl&lt;F, L...&gt;, detail::list_size_mismatch&gt;::type; </pre><pre class="wiki">template&lt;class L, std::size_t I&gt; using mp_at_c = typename mp_if_c&lt;(I &lt; mp_size&lt;L&gt;::value), detail::mp_at_c_impl&lt;L, I&gt;, void&gt;::type; </pre><pre class="wiki"> using type = typename mp_cond&lt; mp_bool&lt;(I &lt; N1)&gt;, mp_nth_element_impl&lt;L1, I, P&gt;, mp_bool&lt;(I == N1)&gt;, mp_identity&lt;T1&gt;, mp_true, mp_nth_element_impl&lt;L2, I - N1 - 1, P&gt; &gt;::type; </pre></li><li>utility.hpp <pre class="wiki">template&lt;template&lt;class...&gt; class F, class... T&gt; using mp_defer = mp_if&lt;mp_valid&lt;F, T...&gt;, detail::mp_defer_impl&lt;F, T...&gt;, detail::mp_no_type&gt;; </pre></li></ul><p> I added an intermediate struct as seen above for every case if cuda 9 is used and now my code compiles with nvcc 9. </p> <p> So I suggest to add such a work around for cuda 9 and above. I can also do this myself, what would be the best way? Providing a patch for the most recent version on github or directly opening a pull request? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13513 Trac 1.4.3 Alexander Matthes <a.matthes@…> Fri, 06 Apr 2018 08:34:25 GMT <link>https://svn.boost.org/trac10/ticket/13513#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13513#comment:1</guid> <description> <p> I opened a PR in the mp11 github: <a class="ext-link" href="https://github.com/boostorg/mp11/pull/21"><span class="icon">​</span>https://github.com/boostorg/mp11/pull/21</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 10 May 2018 16:40:31 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/13513#comment:2 https://svn.boost.org/trac10/ticket/13513#comment:2 <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">obsolete</span> </li> </ul> <p> Moved to <a class="ext-link" href="https://github.com/boostorg/mp11/issues/22"><span class="icon">​</span>https://github.com/boostorg/mp11/issues/22</a> </p> Ticket