From 2458880e772db9a6446a15c335d9987f8fc20131 Mon Sep 17 00:00:00 2001 From: Alexander Matthes Date: Fri, 6 Apr 2018 10:21:52 +0200 Subject: [PATCH] Added work around for Nvidia nvcc cuda compiler >= 9.0 * https://svn.boost.org/trac10/ticket/13513 * https://github.com/ComputationalRadiationPhysics/alpaka/issues/459#issuecomment-377678240 --- include/boost/mp11/algorithm.hpp | 56 +++++++++++++++++++++++++ include/boost/mp11/detail/mp_append.hpp | 16 +++++++ include/boost/mp11/utility.hpp | 17 ++++++++ 3 files changed, 89 insertions(+) diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 23758f7..93fb213 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -95,6 +95,15 @@ struct list_size_mismatch { }; +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template class F, class... L> struct mp_transform_cuda_workaround +{ + using type = mp_if...>, detail::mp_transform_impl, detail::list_size_mismatch>; +}; + +#endif + } // namespace detail #if BOOST_WORKAROUND( BOOST_MSVC, == 1900 ) || BOOST_WORKAROUND( BOOST_GCC, < 40800 ) @@ -103,10 +112,18 @@ template class F, class... L> using mp_transform = typename m #else +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template class F, class... L> using mp_transform = typename detail::mp_transform_cuda_workaround< F, L...>::type::type; + +#else + template class F, class... L> using mp_transform = typename mp_if...>, detail::mp_transform_impl, detail::list_size_mismatch>::type; #endif +#endif + template using mp_transform_q = mp_transform; namespace detail @@ -303,9 +320,27 @@ template struct mp_at_c_impl #endif +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template struct mp_at_c_cuda_workaround +{ + using type = mp_if_c<(I < mp_size::value), detail::mp_at_c_impl, void>; +}; + +#endif + } // namespace detail +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template using mp_at_c = typename detail::mp_at_c_cuda_workaround< L, I >::type::type; + +#else + template using mp_at_c = typename mp_if_c<(I < mp_size::value), detail::mp_at_c_impl, void>::type; + +#endif + template using mp_at = mp_at_c; // mp_take(_c) @@ -543,6 +578,25 @@ template class L, class T1, class... T, std::size_t I, templa using L2 = mp_second; + #if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + + struct detail + { + struct mp_nth_element_impl_cuda_workaround + { + using type = mp_cond< + + mp_bool<(I < N1)>, mp_nth_element_impl, + mp_bool<(I == N1)>, mp_identity, + mp_true, mp_nth_element_impl + + >; + }; + }; + using type = typename detail::mp_nth_element_impl_cuda_workaround::type::type; + + #else + using type = typename mp_cond< mp_bool<(I < N1)>, mp_nth_element_impl, @@ -550,6 +604,8 @@ template class L, class T1, class... T, std::size_t I, templa mp_true, mp_nth_element_impl >::type; + + #endif }; } // namespace detail diff --git a/include/boost/mp11/detail/mp_append.hpp b/include/boost/mp11/detail/mp_append.hpp index e58c8a7..f149066 100644 --- a/include/boost/mp11/detail/mp_append.hpp +++ b/include/boost/mp11/detail/mp_append.hpp @@ -133,12 +133,28 @@ template< using type = typename mp_append_impl::type; }; +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template +struct mp_append_impl_cuda_workaround +{ + using type = mp_if_c<(sizeof...(L) > 111), mp_quote, mp_if_c<(sizeof...(L) > 11), mp_quote, mp_quote>>; +}; + +template struct mp_append_impl: mp_append_impl_cuda_workaround::type::template fn +{ +}; + +#else + template struct mp_append_impl: mp_if_c<(sizeof...(L) > 111), mp_quote, mp_if_c<(sizeof...(L) > 11), mp_quote, mp_quote>>::template fn { }; #endif +#endif + } // namespace detail template using mp_append = typename detail::mp_append_impl::type; diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index 4fd98e1..8c71711 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -106,10 +106,27 @@ struct mp_no_type { }; +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template class F, class... T> struct mp_defer_cuda_workaround +{ + using type = mp_if, detail::mp_defer_impl, detail::mp_no_type>; +}; + +#endif + } // namespace detail +#if BOOST_WORKAROUND( BOOST_CUDA_VERSION, / 1000000 == 9 ) + +template class F, class... T> using mp_defer = typename detail::mp_defer_cuda_workaround< F, T...>::type; + +#else + template class F, class... T> using mp_defer = mp_if, detail::mp_defer_impl, detail::mp_no_type>; +#endif + // mp_eval_if, mp_eval_if_c namespace detail {