diff --git a/libcudacxx/include/cuda/std/detail/libcxx/include/complex b/libcudacxx/include/cuda/std/detail/libcxx/include/complex index dc596bd65b..b03b7d9ee6 100644 --- a/libcudacxx/include/cuda/std/detail/libcxx/include/complex +++ b/libcudacxx/include/cuda/std/detail/libcxx/include/complex @@ -1467,6 +1467,9 @@ inline namespace literals inline namespace complex_literals { # ifdef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE +// NOTE: if you get a warning from GCC <7 here that "literal operator suffixes not preceded by ‘_’ are reserved for +// future standardization" then we are sorry. The warning was implemented before GCC 7, but can only be disabled since +// GCC 7. See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69523 _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr complex operator""il(long double __im) { return {0.0l, __im}; diff --git a/thrust/testing/type_traits.cu b/thrust/testing/type_traits.cu index bab73c76c4..f4ba3d0896 100644 --- a/thrust/testing/type_traits.cu +++ b/thrust/testing/type_traits.cu @@ -5,8 +5,17 @@ #include #include #include +#include +#include #include +#if defined(THRUST_GCC_VERSION) && THRUST_GCC_VERSION >= 70000 +// This header pulls in an unsuppressable warning on GCC 6 +# include +#endif // defined(THRUST_GCC_VERSION) && THRUST_GCC_VERSION >= 70000 +#include +#include + #include void TestIsContiguousIterator() @@ -146,3 +155,53 @@ void TestIsCommutative() } } DECLARE_UNITTEST(TestIsCommutative); + +struct NonTriviallyCopyable +{ + NonTriviallyCopyable(const NonTriviallyCopyable&) {} +}; +THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(NonTriviallyCopyable); + +static_assert(!::cuda::std::is_trivially_copyable::value, ""); +static_assert(thrust::is_trivially_relocatable::value, ""); + +void TestTriviallyRelocatable() +{ + static_assert(thrust::is_trivially_relocatable::value, ""); +#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA + static_assert(thrust::is_trivially_relocatable<__half>::value, ""); + static_assert(thrust::is_trivially_relocatable::value, ""); + static_assert(thrust::is_trivially_relocatable::value, ""); + static_assert(thrust::is_trivially_relocatable::value, ""); + static_assert(thrust::is_trivially_relocatable::value, ""); +# ifndef _LIBCUDACXX_HAS_NO_INT128 + static_assert(thrust::is_trivially_relocatable<__int128>::value, ""); +# endif // _LIBCUDACXX_HAS_NO_INT128 +#endif // THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA +#if defined(THRUST_GCC_VERSION) && THRUST_GCC_VERSION >= 70000 + static_assert(thrust::is_trivially_relocatable>::value, ""); + static_assert(thrust::is_trivially_relocatable<::cuda::std::complex>::value, ""); + static_assert(thrust::is_trivially_relocatable>>::value, ""); + static_assert(thrust::is_trivially_relocatable<::cuda::std::pair>>::value, ""); + static_assert(thrust::is_trivially_relocatable, char>>::value, ""); + static_assert(thrust::is_trivially_relocatable<::cuda::std::tuple, char>>::value, + ""); +#endif // defined(THRUST_GCC_VERSION) && THRUST_GCC_VERSION >= 70000 + static_assert(thrust::is_trivially_relocatable< + ::cuda::std::tuple>>, + thrust::tuple<::cuda::std::pair>, int>>>::value, + ""); + + static_assert(!thrust::is_trivially_relocatable>::value, ""); + static_assert(!thrust::is_trivially_relocatable<::cuda::std::pair>::value, ""); + static_assert(!thrust::is_trivially_relocatable>::value, ""); + static_assert(!thrust::is_trivially_relocatable<::cuda::std::tuple>::value, ""); + + // test propagation of relocatability through pair and tuple + static_assert(thrust::is_trivially_relocatable::value, ""); + static_assert(thrust::is_trivially_relocatable>::value, ""); + static_assert(thrust::is_trivially_relocatable<::cuda::std::pair>::value, ""); + static_assert(thrust::is_trivially_relocatable>::value, ""); + static_assert(thrust::is_trivially_relocatable<::cuda::std::tuple>::value, ""); +}; +DECLARE_UNITTEST(TestTriviallyRelocatable); diff --git a/thrust/thrust/pair.h b/thrust/thrust/pair.h index 0e567a35b6..def1aeaf17 100644 --- a/thrust/thrust/pair.h +++ b/thrust/thrust/pair.h @@ -30,6 +30,9 @@ # pragma system_header #endif // no system header +#include + +#include #include THRUST_NAMESPACE_BEGIN @@ -117,6 +120,11 @@ make_pair(T1&& t1, T2&& t2) using _CUDA_VSTD::get; +template +struct proclaim_trivially_relocatable> + : ::cuda::std::conjunction, is_trivially_relocatable> +{}; + /*! \endcond */ diff --git a/thrust/thrust/tuple.h b/thrust/thrust/tuple.h index 1ff1031804..3e7cd87dae 100644 --- a/thrust/thrust/tuple.h +++ b/thrust/thrust/tuple.h @@ -39,6 +39,8 @@ # pragma system_header #endif // no system header +#include + #include #include #include @@ -232,6 +234,10 @@ inline _CCCL_HOST_DEVICE tuple tie(Ts&... ts) noexcept using _CUDA_VSTD::get; +template +struct proclaim_trivially_relocatable> : ::cuda::std::conjunction...> +{}; + /*! \endcond */ diff --git a/thrust/thrust/type_traits/is_trivially_relocatable.h b/thrust/thrust/type_traits/is_trivially_relocatable.h index 7732d7c6ab..8566a51057 100644 --- a/thrust/thrust/type_traits/is_trivially_relocatable.h +++ b/thrust/thrust/type_traits/is_trivially_relocatable.h @@ -36,6 +36,10 @@ #include #include +#include +#include +#include + #include THRUST_NAMESPACE_BEGIN @@ -285,6 +289,18 @@ THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(double3) THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(double4) #endif +THRUST_NAMESPACE_BEGIN +template +struct proclaim_trivially_relocatable<::cuda::std::pair> + : ::cuda::std::conjunction, is_trivially_relocatable> +{}; + +template +struct proclaim_trivially_relocatable<::cuda::std::tuple> + : ::cuda::std::conjunction...> +{}; +THRUST_NAMESPACE_END + /*! \endcond */