diff --git a/src/vt/messaging/message/message_serialize.h b/src/vt/messaging/message/message_serialize.h index 1032839e43..ad111948ea 100644 --- a/src/vt/messaging/message/message_serialize.h +++ b/src/vt/messaging/message/message_serialize.h @@ -53,11 +53,38 @@ namespace vt { namespace messaging { +// C++17 port. ref. https://en.cppreference.com/w/cpp/types/conjunction +template struct cxx14_conjunction : std::true_type { }; +template struct cxx14_conjunction : B1 { }; +template +struct cxx14_conjunction + : std::conditional_t, B1> {}; + +// C++17 port. ref. https://en.cppreference.com/w/cpp/types/void_t +template +struct cxx14_make_void { typedef void type;}; +template +using cxx14_void_t = typename cxx14_make_void::type; + // Only some compilers can directly check for a serialization method // because to do so requires declval on a templated member WITHOUT // causing templated instantiation (which will fail). #ifndef vt_quirked_serialize_method_detection +using SerializeSizerType = ::checkpoint::Sizer; + +// Covering case work-about for NVCC (CUDA 10.1). See usage site. +template +struct has_any_serialize_member_t +{ + template + static auto test(U* u) -> decltype( + u->template serialize(std::declval()) + , char(0)) { return char(0); } + static double test(...) { return 0; } + static const bool value = (sizeof(test((T*)0)) == 1); +}; + template struct has_own_serialize_member_t : std::false_type {}; @@ -66,7 +93,7 @@ struct has_own_serialize_member_t) + decltype(&U::template serialize) >::value >> : std::true_type @@ -77,7 +104,14 @@ struct has_own_serialize_member_t static constexpr auto const has_own_serialize = ::checkpoint::SerializableTraits::has_serialize_noninstrusive - or has_own_serialize_member_t::value; + // NVCC (CUDA 10.1 and 11) has SFINAE issues with decltype above, + // and possible fallout with lazy evaluation of 'and'. + // While this compiles, NVCC incorrectly detects some types + // as requiring serialization. See #949. + or cxx14_conjunction< + has_any_serialize_member_t, + has_own_serialize_member_t + >::value; #endif @@ -223,19 +257,6 @@ struct is_byte_copyable_t { }; #endif -// C++17 port. ref. https://en.cppreference.com/w/cpp/types/conjunction -template struct cxx14_conjunction : std::true_type { }; -template struct cxx14_conjunction : B1 { }; -template -struct cxx14_conjunction - : std::conditional_t, B1> {}; - -// C++17 port. ref. https://en.cppreference.com/w/cpp/types/void_t -template -struct cxx14_make_void { typedef void type;}; -template -using cxx14_void_t = typename cxx14_make_void::type; - // Foward-declare struct BaseMsg;