diff --git a/thrust/testing/type_traits.cu b/thrust/testing/type_traits.cu index bab73c76c4c..e213cd4cfac 100644 --- a/thrust/testing/type_traits.cu +++ b/thrust/testing/type_traits.cu @@ -5,8 +5,14 @@ #include #include #include +#include +#include #include +#include +#include +#include + #include void TestIsContiguousIterator() @@ -146,3 +152,34 @@ void TestIsCommutative() } } DECLARE_UNITTEST(TestIsCommutative); + +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 + 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>::value, ""); + static_assert(thrust::is_trivially_relocatable<::cuda::std::tuple>::value, ""); + 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, ""); +}; +DECLARE_UNITTEST(TestTriviallyRelocatable); diff --git a/thrust/thrust/pair.h b/thrust/thrust/pair.h index 0e567a35b66..def1aeaf170 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 1ff1031804e..3e7cd87daeb 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 7732d7c6ab1..8566a510578 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 */