From 29b3311fdca9335f3ff89a658ea24a4a9eae6508 Mon Sep 17 00:00:00 2001 From: Yung-sheng Tu Date: Thu, 2 Oct 2025 08:20:08 +0000 Subject: [PATCH 001/153] =?UTF-8?q?Partially=20revert=20"[rocThrust]=20fix?= =?UTF-8?q?:=20HIP=20compiler=20rejects=20THRUST=5FNODISCARD=20after=20THR?= =?UTF-8?q?UST=5FD=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0098e5e109f3d2ad00f5d26a8bda552ceb11dab5. --- projects/rocthrust/thrust/async/copy.h | 2 +- projects/rocthrust/thrust/async/for_each.h | 2 +- projects/rocthrust/thrust/async/reduce.h | 4 ++-- projects/rocthrust/thrust/async/sort.h | 6 ++---- projects/rocthrust/thrust/async/transform.h | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/projects/rocthrust/thrust/async/copy.h b/projects/rocthrust/thrust/async/copy.h index dfde676ca8e3..b64a0c565756 100644 --- a/projects/rocthrust/thrust/async/copy.h +++ b/projects/rocthrust/thrust/async/copy.h @@ -115,7 +115,7 @@ struct copy_fn final THRUST_FWD(output))) template - THRUST_DEPRECATED THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const + THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; diff --git a/projects/rocthrust/thrust/async/for_each.h b/projects/rocthrust/thrust/async/for_each.h index 559482994ba5..d7a9f05da1c5 100644 --- a/projects/rocthrust/thrust/async/for_each.h +++ b/projects/rocthrust/thrust/async/for_each.h @@ -92,7 +92,7 @@ struct for_each_fn final THRUST_FWD(f))) template - THRUST_DEPRECATED THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const + THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; diff --git a/projects/rocthrust/thrust/async/reduce.h b/projects/rocthrust/thrust/async/reduce.h index dd81505ea3a6..2293ed02135f 100644 --- a/projects/rocthrust/thrust/async/reduce.h +++ b/projects/rocthrust/thrust/async/reduce.h @@ -162,7 +162,7 @@ struct reduce_fn final ::internal::remove_cvref_t>::value_type>>{})) template - THRUST_DEPRECATED THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const + THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; @@ -310,7 +310,7 @@ struct reduce_into_fn final thrust::is_execution_policy<::internal::remove_cvref_t>{})) template - THRUST_DEPRECATED THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const + THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; diff --git a/projects/rocthrust/thrust/async/sort.h b/projects/rocthrust/thrust/async/sort.h index 8a155069c03d..62cf8fa06409 100644 --- a/projects/rocthrust/thrust/async/sort.h +++ b/projects/rocthrust/thrust/async/sort.h @@ -144,12 +144,11 @@ THRUST_SUPPRESS_DEPRECATED_PUSH ) template - THRUST_DEPRECATED #if !(defined(__CUDA__) && THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG) // clang in CUDA mode can only handle one attribute THRUST_NODISCARD THRUST_HOST #endif - auto operator()(Args&&... args) const + THRUST_DEPRECATED auto operator()(Args&&... args) const THRUST_RETURNS( call(THRUST_FWD(args)...) ) @@ -268,12 +267,11 @@ struct sort_fn final ) template - THRUST_DEPRECATED #if !(defined(__CUDA__) && THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG) // clang in CUDA mode can only handle one attribute THRUST_NODISCARD THRUST_HOST #endif - auto operator()(Args&&... args) const + THRUST_DEPRECATED auto operator()(Args&&... args) const THRUST_RETURNS( call(THRUST_FWD(args)...) ) diff --git a/projects/rocthrust/thrust/async/transform.h b/projects/rocthrust/thrust/async/transform.h index e75013a2d0a1..bd5c5c86dd0c 100644 --- a/projects/rocthrust/thrust/async/transform.h +++ b/projects/rocthrust/thrust/async/transform.h @@ -123,7 +123,7 @@ struct transform_fn final ) template - THRUST_DEPRECATED THRUST_NODISCARD THRUST_HOST + THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS( call(THRUST_FWD(args)...) From a86449c83dd424785fdf596315473efe6b856f58 Mon Sep 17 00:00:00 2001 From: Yung-sheng Tu Date: Thu, 2 Oct 2025 08:24:39 +0000 Subject: [PATCH 002/153] Revert "Fix rocThrust 2.8.5 NVCC job failures (#1770)" This reverts commit ecd2400b82997e07577e104862626f380f3bc1ad. --- projects/rocthrust/thrust/system/hip/detail/future.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/rocthrust/thrust/system/hip/detail/future.inl b/projects/rocthrust/thrust/system/hip/detail/future.inl index 010e4da97819..c58a89ca017a 100644 --- a/projects/rocthrust/thrust/system/hip/detail/future.inl +++ b/projects/rocthrust/thrust/system/hip/detail/future.inl @@ -43,7 +43,7 @@ # include _THRUST_STD_INCLUDE(__memory/unique_ptr.h) // clang-format on #else -# include +# include #endif # include From cbf9ad0f282644e31ea9e3b943b897170d2c5d6e Mon Sep 17 00:00:00 2001 From: Yung-sheng Tu Date: Thu, 2 Oct 2025 08:30:44 +0000 Subject: [PATCH 003/153] Revert "rocThrust CCCL 2.8.5 changes (#1394)" This reverts commits from 63f701c7fce9e295101ca93b91657216e9628296 to f43f8debebbaefb0d26e27ee2491bb2aa4ef3849. --- .../rocthrust/examples/counting_iterator.cu | 4 +- .../examples/minimal_custom_backend.cu | 9 +- projects/rocthrust/test/CMakeLists.txt | 1 + .../test/test_allocator_aware_policies.cpp | 7 - projects/rocthrust/test/test_async_copy.cpp | 32 +- .../rocthrust/test/test_async_for_each.cpp | 3 +- projects/rocthrust/test/test_async_reduce.cpp | 973 +++++++++--------- .../rocthrust/test/test_async_reduce_into.cpp | 2 - projects/rocthrust/test/test_async_scan.cpp | 2 - projects/rocthrust/test/test_async_sort.cpp | 8 - .../rocthrust/test/test_async_transform.cpp | 453 +++----- .../test/test_dependencies_aware_policies.cpp | 5 - projects/rocthrust/test/test_dereference.cpp | 12 +- projects/rocthrust/test/test_event.cpp | 4 - projects/rocthrust/test/test_find.cpp | 164 ++- projects/rocthrust/test/test_functional.cpp | 9 +- projects/rocthrust/test/test_future.cpp | 4 - .../rocthrust/test/test_is_partitioned.cpp | 30 +- projects/rocthrust/test/test_logical.cpp | 36 +- projects/rocthrust/test/test_optional.cpp | 69 ++ projects/rocthrust/test/test_partition.cpp | 8 +- .../rocthrust/test/test_partition_point.cpp | 48 +- .../test/test_permutation_iterator.cpp | 194 ++-- projects/rocthrust/test/test_remove.cpp | 162 ++- projects/rocthrust/test/test_scan.cpp | 10 - projects/rocthrust/test/test_tabulate.cpp | 74 +- projects/rocthrust/test/test_transform.cpp | 19 +- .../test_transform_input_output_iterator.cpp | 4 +- .../test/test_transform_iterator.cpp | 253 +---- .../rocthrust/test/test_transform_scan.cpp | 6 +- projects/rocthrust/test/test_tuple.cpp | 11 - projects/rocthrust/test/test_type_traits.cpp | 22 +- projects/rocthrust/test/test_utils.hpp | 16 +- .../testing/allocator_aware_policies.cu | 7 - .../async/exclusive_scan/counting_iterator.cu | 9 +- .../async/exclusive_scan/discard_output.cu | 9 +- .../async/exclusive_scan/large_indices.cu | 17 +- .../async/exclusive_scan/large_types.cu | 9 +- .../async/exclusive_scan/mixed_types.cu | 9 +- .../testing/async/exclusive_scan/mixin.h | 2 - .../testing/async/exclusive_scan/simple.cu | 9 +- .../async/exclusive_scan/stateful_operator.cu | 11 +- .../async/exclusive_scan/using_vs_adl.cu | 17 +- .../async/inclusive_scan/counting_iterator.cu | 9 +- .../async/inclusive_scan/discard_output.cu | 9 +- .../async/inclusive_scan/large_indices.cu | 17 +- .../async/inclusive_scan/large_types.cu | 9 +- .../async/inclusive_scan/mixed_types.cu | 9 +- .../testing/async/inclusive_scan/mixin.h | 2 - .../testing/async/inclusive_scan/simple.cu | 9 +- .../async/inclusive_scan/stateful_operator.cu | 11 +- .../async/inclusive_scan/using_vs_adl.cu | 17 +- .../testing/async/test_policy_overloads.h | 26 +- projects/rocthrust/testing/async_copy.cu | 8 - projects/rocthrust/testing/async_for_each.cu | 3 +- projects/rocthrust/testing/async_reduce.cu | 8 - .../rocthrust/testing/async_reduce_into.cu | 2 - projects/rocthrust/testing/async_sort.cu | 8 - projects/rocthrust/testing/async_transform.cu | 6 - .../testing/cuda/adjacent_difference.cu | 2 +- projects/rocthrust/testing/cuda/copy_if.cu | 45 +- .../rocthrust/testing/cuda/is_partitioned.cu | 14 +- projects/rocthrust/testing/cuda/logical.cu | 72 +- projects/rocthrust/testing/cuda/mismatch.cu | 57 +- .../rocthrust/testing/cuda/partition_point.cu | 6 +- projects/rocthrust/testing/cuda/remove.cu | 100 +- projects/rocthrust/testing/cuda/tabulate.cu | 46 +- projects/rocthrust/testing/cuda/transform.cu | 6 +- .../rocthrust/testing/cuda/transform_scan.cu | 3 +- .../testing/dependencies_aware_policies.cu | 5 - projects/rocthrust/testing/dereference.cu | 12 +- projects/rocthrust/testing/event.cu | 4 - projects/rocthrust/testing/find.cu | 36 +- projects/rocthrust/testing/functional.cu | 9 +- projects/rocthrust/testing/future.cu | 4 - projects/rocthrust/testing/is_partitioned.cu | 33 +- projects/rocthrust/testing/logical.cu | 36 +- projects/rocthrust/testing/partition.cu | 9 +- projects/rocthrust/testing/partition_point.cu | 19 +- .../rocthrust/testing/permutation_iterator.cu | 154 ++- projects/rocthrust/testing/remove.cu | 142 ++- projects/rocthrust/testing/scan.cu | 10 - projects/rocthrust/testing/tabulate.cu | 32 +- projects/rocthrust/testing/transform.cu | 11 +- .../transform_input_output_iterator.cu | 4 +- .../rocthrust/testing/transform_iterator.cu | 143 +-- projects/rocthrust/testing/transform_scan.cu | 6 +- projects/rocthrust/testing/tuple.cu | 11 - projects/rocthrust/testing/type_traits.cu | 22 +- .../testing/unittest/testframework.h | 19 +- projects/rocthrust/testing/unittest/util.h | 8 +- projects/rocthrust/thrust/async/copy.h | 71 +- projects/rocthrust/thrust/async/for_each.h | 42 +- projects/rocthrust/thrust/async/reduce.h | 239 ++--- projects/rocthrust/thrust/async/scan.h | 251 ++--- projects/rocthrust/thrust/async/sort.h | 57 +- projects/rocthrust/thrust/async/transform.h | 32 +- projects/rocthrust/thrust/detail/alignment.h | 7 +- .../detail/allocator_aware_execution_policy.h | 27 +- .../thrust/detail/config/cpp_compatibility.h | 97 +- .../thrust/detail/config/cpp_dialect.h | 2 +- .../dependencies_aware_execution_policy.h | 11 +- .../thrust/detail/execute_with_allocator.h | 4 +- .../detail/execute_with_allocator_fwd.h | 25 +- .../thrust/detail/execute_with_dependencies.h | 45 +- .../thrust/detail/functional/actor.h | 7 + .../thrust/detail/functional/operators.h | 1 + .../rocthrust/thrust/detail/numeric_traits.h | 35 +- projects/rocthrust/thrust/detail/pointer.h | 14 +- projects/rocthrust/thrust/detail/reference.h | 5 +- .../rocthrust/thrust/detail/select_system.h | 12 +- .../rocthrust/thrust/detail/static_assert.h | 9 +- projects/rocthrust/thrust/detail/tuple.inl | 5 - .../rocthrust/thrust/detail/tuple_transform.h | 22 +- .../rocthrust/thrust/detail/type_deduction.h | 32 +- .../rocthrust/thrust/detail/type_traits.h | 8 - .../detail/type_traits/has_nested_type.h | 14 +- .../thrust/detail/type_traits/minimum_type.h | 2 +- .../detail/type_traits/pointer_traits.h | 25 +- .../result_of_adaptable_function.h | 71 ++ projects/rocthrust/thrust/execution_policy.h | 19 +- projects/rocthrust/thrust/functional.h | 6 +- projects/rocthrust/thrust/future.h | 45 +- .../thrust/iterator/constant_iterator.h | 9 +- .../thrust/iterator/counting_iterator.h | 5 +- .../thrust/iterator/detail/any_system_tag.h | 9 +- .../iterator/detail/counting_iterator.inl | 5 +- .../iterator/detail/discard_iterator_base.h | 11 +- .../detail/iterator_facade_category.h | 10 +- .../iterator/detail/transform_iterator.inl | 55 +- .../detail/tuple_of_iterator_references.h | 8 +- .../iterator/detail/universal_categories.h | 28 +- .../thrust/iterator/discard_iterator.h | 2 +- .../thrust/iterator/iterator_adaptor.h | 2 +- .../thrust/iterator/iterator_categories.h | 50 +- .../thrust/iterator/iterator_facade.h | 3 +- .../thrust/iterator/iterator_traits.h | 21 +- .../thrust/iterator/permutation_iterator.h | 2 +- .../thrust/iterator/reverse_iterator.h | 9 +- .../iterator/tabulate_output_iterator.h | 10 +- .../transform_input_output_iterator.h | 9 +- .../thrust/iterator/transform_iterator.h | 2 +- .../iterator/transform_output_iterator.h | 11 +- .../rocthrust/thrust/iterator/zip_iterator.h | 2 +- projects/rocthrust/thrust/limits.h | 12 +- projects/rocthrust/thrust/logical.h | 44 +- projects/rocthrust/thrust/optional.h | 32 +- projects/rocthrust/thrust/partition.h | 8 +- projects/rocthrust/thrust/remove.h | 23 +- .../system/cpp/detail/execution_policy.h | 9 +- .../system/cuda/detail/adjacent_difference.h | 3 +- .../thrust/system/cuda/detail/async/copy.h | 6 +- .../system/cuda/detail/async/customization.h | 10 +- .../system/cuda/detail/async/exclusive_scan.h | 5 +- .../system/cuda/detail/async/for_each.h | 2 - .../system/cuda/detail/async/inclusive_scan.h | 43 +- .../thrust/system/cuda/detail/async/reduce.h | 11 +- .../thrust/system/cuda/detail/async/sort.h | 6 +- .../system/cuda/detail/async/transform.h | 2 - .../thrust/system/cuda/detail/copy_if.h | 2 +- .../system/cuda/detail/core/agent_launcher.h | 5 +- .../cuda/detail/core/triple_chevron_launch.h | 6 +- .../thrust/system/cuda/detail/core/util.h | 14 +- .../thrust/system/cuda/detail/count.h | 3 +- .../system/cuda/detail/execution_policy.h | 20 +- .../thrust/system/cuda/detail/extrema.h | 14 +- .../thrust/system/cuda/detail/find.h | 108 +- .../thrust/system/cuda/detail/future.inl | 81 +- .../thrust/system/cuda/detail/inner_product.h | 15 +- .../detail/internal/copy_device_to_device.h | 3 +- .../thrust/system/cuda/detail/mismatch.h | 142 +-- .../rocthrust/thrust/system/cuda/detail/par.h | 8 +- .../thrust/system/cuda/detail/partition.h | 4 +- .../thrust/system/cuda/detail/reduce.h | 2 +- .../thrust/system/cuda/detail/reduce_by_key.h | 2 +- .../thrust/system/cuda/detail/scan.h | 10 +- .../thrust/system/cuda/detail/scatter.h | 2 +- .../thrust/system/cuda/detail/terminate.h | 19 +- .../system/cuda/detail/transform_scan.h | 15 +- .../thrust/system/cuda/detail/unique.h | 2 +- .../thrust/system/cuda/detail/unique_by_key.h | 2 +- .../thrust/system/cuda/detail/util.h | 38 +- .../rocthrust/thrust/system/cuda/future.h | 13 +- .../thrust/system/detail/generic/copy.inl | 59 +- .../thrust/system/detail/generic/copy_if.inl | 3 +- .../thrust/system/detail/generic/gather.inl | 124 +-- .../thrust/system/detail/generic/scatter.inl | 102 +- .../system/detail/generic/transform_scan.inl | 7 +- .../detail/sequential/execution_policy.h | 9 +- .../system/hip/detail/adjacent_difference.h | 5 +- .../thrust/system/hip/detail/async/copy.h | 7 +- .../system/hip/detail/async/customization.h | 9 +- .../system/hip/detail/async/exclusive_scan.h | 3 +- .../thrust/system/hip/detail/async/for_each.h | 2 - .../system/hip/detail/async/inclusive_scan.h | 3 +- .../thrust/system/hip/detail/async/reduce.h | 10 +- .../thrust/system/hip/detail/async/sort.h | 7 +- .../system/hip/detail/async/transform.h | 2 - .../thrust/system/hip/detail/count.h | 3 +- .../system/hip/detail/execution_policy.h | 17 +- .../thrust/system/hip/detail/extrema.h | 12 +- .../rocthrust/thrust/system/hip/detail/find.h | 112 +- .../thrust/system/hip/detail/future.inl | 129 +-- .../thrust/system/hip/detail/inner_product.h | 15 +- .../detail/internal/copy_device_to_device.h | 3 +- .../thrust/system/hip/detail/mismatch.h | 140 +-- .../rocthrust/thrust/system/hip/detail/par.h | 111 +- .../thrust/system/hip/detail/terminate.h | 27 +- .../system/hip/detail/transform_reduce.h | 3 +- .../thrust/system/hip/detail/transform_scan.h | 29 +- .../rocthrust/thrust/system/hip/detail/util.h | 51 +- projects/rocthrust/thrust/system/hip/future.h | 21 +- projects/rocthrust/thrust/transform.h | 10 +- projects/rocthrust/thrust/tuple.h | 16 +- .../type_traits/logical_metafunctions.h | 63 +- .../thrust/type_traits/remove_cvref.h | 65 +- projects/rocthrust/thrust/version.h | 2 +- 217 files changed, 3065 insertions(+), 4353 deletions(-) create mode 100644 projects/rocthrust/test/test_optional.cpp create mode 100644 projects/rocthrust/thrust/detail/type_traits/result_of_adaptable_function.h diff --git a/projects/rocthrust/examples/counting_iterator.cu b/projects/rocthrust/examples/counting_iterator.cu index a04685c2f15d..54cbfec7050e 100644 --- a/projects/rocthrust/examples/counting_iterator.cu +++ b/projects/rocthrust/examples/counting_iterator.cu @@ -26,7 +26,7 @@ #include #include -int main() +int main(void) { // this example computes indices for all the nonzero values in a sequence @@ -51,7 +51,7 @@ int main() // compute indices of nonzero elements using IndexIterator = thrust::device_vector::iterator; - IndexIterator indices_end = thrust::copy_if(first, last, stencil.begin(), indices.begin(), ::internal::identity{}); + IndexIterator indices_end = thrust::copy_if(first, last, stencil.begin(), indices.begin(), thrust::identity()); // indices now contains [1,2,5,7] // print result diff --git a/projects/rocthrust/examples/minimal_custom_backend.cu b/projects/rocthrust/examples/minimal_custom_backend.cu index 50b2ca18bfc7..e22c923d8804 100644 --- a/projects/rocthrust/examples/minimal_custom_backend.cu +++ b/projects/rocthrust/examples/minimal_custom_backend.cu @@ -25,9 +25,6 @@ #include #include -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -# include -#endif // This example demonstrates how to build a minimal custom // Thrust backend by intercepting for_each's dispatch. @@ -67,16 +64,16 @@ int main() my_system sys; // To invoke our version of for_each, pass sys as the first parameter - thrust::for_each(sys, vec.begin(), vec.end(), _THRUST_STD::negate<>{}); + thrust::for_each(sys, vec.begin(), vec.end(), thrust::identity()); // Other algorithms that Thrust implements with thrust::for_each will also // cause our version of for_each to be invoked when we pass an instance of my_system as the first parameter. // Even though we did not define a special version of transform, Thrust dispatches the version it knows // for thrust::device_execution_policy, which my_system inherits. - thrust::transform(sys, vec.begin(), vec.end(), vec.begin(), ::internal::identity{}); + thrust::transform(sys, vec.begin(), vec.end(), vec.begin(), thrust::identity()); // Invocations without my_system are handled normally. - thrust::for_each(vec.begin(), vec.end(), _THRUST_STD::negate<>{}); + thrust::for_each(vec.begin(), vec.end(), thrust::identity()); return 0; } diff --git a/projects/rocthrust/test/CMakeLists.txt b/projects/rocthrust/test/CMakeLists.txt index 031be6512739..3f5ec182b666 100644 --- a/projects/rocthrust/test/CMakeLists.txt +++ b/projects/rocthrust/test/CMakeLists.txt @@ -229,6 +229,7 @@ if(BUILD_TEST) add_rocthrust_test("mr_new") add_rocthrust_test("mr_pool") add_rocthrust_test("mr_pool_options") + add_rocthrust_test("optional") add_rocthrust_test("out_of_memory_recovery") add_rocthrust_test("pair") add_rocthrust_test("pair_reduce") diff --git a/projects/rocthrust/test/test_allocator_aware_policies.cpp b/projects/rocthrust/test/test_allocator_aware_policies.cpp index e4c9a46677f0..680484d22149 100644 --- a/projects/rocthrust/test/test_allocator_aware_policies.cpp +++ b/projects/rocthrust/test/test_allocator_aware_policies.cpp @@ -15,11 +15,6 @@ * limitations under the License. */ -#include - -// need to suppress deprecation warnings for execute_with_allocator_and_dependencies here and inside type traits -THRUST_SUPPRESS_DEPRECATED_PUSH - #include #include #include @@ -145,5 +140,3 @@ TYPED_TEST(AllocatorAwarePoliciesTests, TestAllocatorAttachment) TestAllocatorAttachment test; test(); } - -THRUST_SUPPRESS_DEPRECATED_POP diff --git a/projects/rocthrust/test/test_async_copy.cpp b/projects/rocthrust/test/test_async_copy.cpp index 9c1446dfc0e2..34cb5f5b634f 100644 --- a/projects/rocthrust/test/test_async_copy.cpp +++ b/projects/rocthrust/test/test_async_copy.cpp @@ -17,9 +17,6 @@ #include -// need to suppress deprecation warnings inside a lot of thrust headers -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2014 # include @@ -336,6 +333,30 @@ TYPED_TEST(AsyncCopyTests, test_async_copy_trivially_relocatable_elements_roundt /////////////////////////////////////////////////////////////////////////////// +# define ASSERT_THROWS_EQ_WITH_FILE_AND_LINE(EXPR, EXCEPTION_TYPE, VALUE, FILE_, LINE_) \ + { \ + threw_status THRUST_PP_CAT2(__s, LINE_) = did_not_throw; \ + try \ + { \ + EXPR; \ + } \ + catch (EXCEPTION_TYPE const& THRUST_PP_CAT2(__e, LINE_)) \ + { \ + if (VALUE == THRUST_PP_CAT2(__e, LINE_)) \ + THRUST_PP_CAT2(__s, LINE_) = threw_right_type; \ + else \ + THRUST_PP_CAT2(__s, LINE_) = threw_right_type_but_wrong_value; \ + } \ + catch (...) \ + { \ + THRUST_PP_CAT2(__s, LINE_) = threw_wrong_type; \ + } \ + check_assert_throws(THRUST_PP_CAT2(__s, LINE_), THRUST_PP_STRINGIZE(EXCEPTION_TYPE), FILE_, LINE_); \ + } + +# define ASSERT_THROWS_EQ(EXPR, EXCEPTION_TYPE, VALUE) \ + ASSERT_THROWS_EQ_WITH_FILE_AND_LINE(EXPR, EXCEPTION_TYPE, VALUE, __FILE__, __LINE__) + template THRUST_HOST void test_async_copy_after() { @@ -415,8 +436,3 @@ TYPED_TEST(AsyncCopyTests, test_async_copy_after_test) // Can't do this today because we can't do cross-system with explicit policies. #endif - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC diff --git a/projects/rocthrust/test/test_async_for_each.cpp b/projects/rocthrust/test/test_async_for_each.cpp index 2354a5c66081..8dd9df7b5ac7 100644 --- a/projects/rocthrust/test/test_async_for_each.cpp +++ b/projects/rocthrust/test/test_async_for_each.cpp @@ -26,8 +26,6 @@ # include "test_param_fixtures.hpp" # include "test_utils.hpp" -THRUST_SUPPRESS_DEPRECATED_PUSH - # define DEFINE_ASYNC_FOR_EACH_CALLABLE(name, ...) \ struct THRUST_PP_CAT2(name, _fn) \ { \ @@ -41,6 +39,7 @@ THRUST_SUPPRESS_DEPRECATED_PUSH /**/ DEFINE_ASYNC_FOR_EACH_CALLABLE(invoke_async_for_each); + DEFINE_ASYNC_FOR_EACH_CALLABLE(invoke_async_for_each_device, thrust::device); # undef DEFINE_ASYNC_FOR_EACH_CALLABLE diff --git a/projects/rocthrust/test/test_async_reduce.cpp b/projects/rocthrust/test/test_async_reduce.cpp index f085709bd647..8676a3ba13e8 100644 --- a/projects/rocthrust/test/test_async_reduce.cpp +++ b/projects/rocthrust/test/test_async_reduce.cpp @@ -15,77 +15,71 @@ * limitations under the License. */ -#define THRUST_ENABLE_FUTURE_RAW_DATA_MEMBER - #include -// need to suppress deprecation warnings inside several thrust headers -THRUST_SUPPRESS_DEPRECATED_PUSH - -#if THRUST_CPP_DIALECT >= 2017 +#include +#include +#include +#include -# include -# include -# include -# include - -# include "test_param_fixtures.hpp" -# include "test_real_assertions.hpp" -# include "test_utils.hpp" +#include "test_param_fixtures.hpp" +#include "test_real_assertions.hpp" +#include "test_utils.hpp" TESTS_DEFINE(AsyncReduceTests, NumericalTestsParams); template struct custom_plus { - THRUST_HOST_DEVICE T operator()(T lhs, T rhs) const + __host__ __device__ T operator()(T lhs, T rhs) const { return lhs + rhs; } }; -# define DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER(NAME, MEMBERS, CTOR, DTOR, VALIDATE, ...) \ - template \ - struct NAME \ - { \ - MEMBERS \ - \ - NAME() \ - { \ - CTOR \ - } \ - \ - ~NAME() \ - { \ - DTOR \ - } \ - \ - template \ - void validate_event(Event& e) \ - { \ - THRUST_UNUSED_VAR(e); \ - VALIDATE \ - } \ - \ - template \ - THRUST_HOST auto operator()(ForwardIt&& first, Sentinel&& last) \ - THRUST_DECLTYPE_RETURNS(::thrust::async::reduce(__VA_ARGS__)) \ - }; \ - /**/ - -# define DEFINE_ASYNC_REDUCE_INVOKER(NAME, ...) \ - DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( \ - NAME, THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), __VA_ARGS__) \ - /**/ - -# define DEFINE_SYNC_REDUCE_INVOKER(NAME, ...) \ - template \ - struct NAME \ - { \ - template \ - THRUST_HOST auto operator()(ForwardIt&& first, Sentinel&& last) THRUST_RETURNS(::thrust::reduce(__VA_ARGS__)) \ - }; \ - /**/ +#define DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER(NAME, MEMBERS, CTOR, DTOR, VALIDATE, ...) \ + template \ + struct NAME \ + { \ + MEMBERS \ + \ + NAME() \ + { \ + CTOR \ + } \ + \ + ~NAME() \ + { \ + DTOR \ + } \ + \ + template \ + void validate_event(Event& e) \ + { \ + THRUST_UNUSED_VAR(e); \ + VALIDATE \ + } \ + \ + template \ + __host__ auto operator()(ForwardIt&& first, Sentinel&& last) \ + THRUST_DECLTYPE_RETURNS(::thrust::async::reduce(__VA_ARGS__)) \ + }; \ + /**/ + +#define DEFINE_ASYNC_REDUCE_INVOKER(NAME, ...) \ + DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( \ + NAME, THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), __VA_ARGS__) \ + /**/ + +#define DEFINE_SYNC_REDUCE_INVOKER(NAME, ...) \ + template \ + struct NAME \ + { \ + template \ + __host__ auto operator()(ForwardIt&& first, Sentinel&& last) \ + THRUST_DECLTYPE_RETURNS(::thrust::reduce(__VA_ARGS__)) \ + }; \ + /**/ DEFINE_ASYNC_REDUCE_INVOKER(reduce_async_invoker, THRUST_FWD(first), THRUST_FWD(last)); DEFINE_ASYNC_REDUCE_INVOKER(reduce_async_invoker_device, thrust::device, THRUST_FWD(first), THRUST_FWD(last)); @@ -97,14 +91,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_on // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -117,14 +110,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_allocator_on // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -149,14 +141,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_on_init // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -170,14 +161,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_allocator_on_init // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -210,14 +200,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_on_init_plus // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -232,14 +221,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_allocator_on_init_plus // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -274,14 +262,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_on_init_custom_plus // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -296,14 +283,13 @@ DEFINE_STATEFUL_ASYNC_REDUCE_INVOKER( reduce_async_invoker_device_allocator_on_init_custom_plus // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -321,200 +307,207 @@ DEFINE_SYNC_REDUCE_INVOKER( /////////////////////////////////////////////////////////////////////////////// template class AsyncReduceInvoker, template class SyncReduceInvoker> -THRUST_HOST void test_async_reduce() +void testAsyncReduce() { for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); + + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); + + thrust::device_vector d0a(h0); + thrust::device_vector d0b(h0); + thrust::device_vector d0c(h0); + thrust::device_vector d0d(h0); + + AsyncReduceInvoker invoke_async; + SyncReduceInvoker invoke_sync; + + ASSERT_EQ(h0, d0a); + ASSERT_EQ(h0, d0b); + ASSERT_EQ(h0, d0c); + ASSERT_EQ(h0, d0d); + + auto f0a = invoke_async(d0a.begin(), d0a.end()); + auto f0b = invoke_async(d0b.begin(), d0b.end()); + auto f0c = invoke_async(d0c.begin(), d0c.end()); + auto f0d = invoke_async(d0d.begin(), d0d.end()); + + invoke_async.validate_event(f0a); + invoke_async.validate_event(f0b); + invoke_async.validate_event(f0c); + invoke_async.validate_event(f0d); + + // This potentially runs concurrently with the copies. + auto const r0 = invoke_sync(h0.begin(), h0.end()); + + T r1a; + T r1b; + T r1c; + T r1d; + + test_future_value_retrieval(f0a, r1a); + test_future_value_retrieval(f0b, r1b); + test_future_value_retrieval(f0c, r1c); + test_future_value_retrieval(f0d, r1d); + + auto tolerance = std::max(std::abs(0.1f * r0), T(precision)); - thrust::host_vector h0(random_integers(size)); - thrust::device_vector d0a(h0); - thrust::device_vector d0b(h0); - thrust::device_vector d0c(h0); - thrust::device_vector d0d(h0); - - AsyncReduceInvoker invoke_async; - SyncReduceInvoker invoke_sync; - - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - ASSERT_EQ(h0, d0c); - ASSERT_EQ(h0, d0d); - - auto f0a = invoke_async(d0a.begin(), d0a.end()); - auto f0b = invoke_async(d0b.begin(), d0b.end()); - auto f0c = invoke_async(d0c.begin(), d0c.end()); - auto f0d = invoke_async(d0d.begin(), d0d.end()); - - invoke_async.validate_event(f0a); - invoke_async.validate_event(f0b); - invoke_async.validate_event(f0c); - invoke_async.validate_event(f0d); - - // This potentially runs concurrently with the copies. - auto const r0 = invoke_sync(h0.begin(), h0.end()); - - decltype(f0a.extract()) r1a; - decltype(f0b.extract()) r1b; - decltype(f0c.extract()) r1c; - decltype(f0d.extract()) r1d; - - test_future_value_retrieval(f0a, r1a); - test_future_value_retrieval(f0b, r1b); - test_future_value_retrieval(f0c, r1c); - test_future_value_retrieval(f0d, r1d); - - ASSERT_EQ(r0, r1a); - ASSERT_EQ(r0, r1b); - ASSERT_EQ(r0, r1c); - ASSERT_EQ(r0, r1d); + ASSERT_NEAR(r0, r1a, tolerance); + ASSERT_NEAR(r0, r1b, tolerance); + ASSERT_NEAR(r0, r1c, tolerance); + ASSERT_NEAR(r0, r1d, tolerance); + } } -} +}; -TYPED_TEST(AsyncReduceTests, test_async_reduce) +TYPED_TEST(AsyncReduceTests, TestAsyncReduce) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicy) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocator) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_on) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyOn) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_on) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorOn) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_on_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyOnInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_on_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorOnInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_on_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyOnInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_on_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorOnInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_on_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyOnInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_allocator_on_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyAllocatorOnInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce(); + testAsyncReduce(); } /////////////////////////////////////////////////////////////////////////////// template class AsyncReduceInvoker, template class SyncReduceInvoker> -THRUST_HOST void test_async_reduce_counting_iterator() +void testAsyncReduceCountingIterator() { constexpr std::size_t n = 15 * sizeof(T); @@ -539,481 +532,477 @@ THRUST_HOST void test_async_reduce_counting_iterator() // This potentially runs concurrently with the copies. auto const r0 = invoke_sync(first, last); - decltype(f0a.extract()) r1a; - decltype(f0b.extract()) r1b; - decltype(f0c.extract()) r1c; - decltype(f0d.extract()) r1d; + T r1a; + T r1b; + T r1c; + T r1d; test_future_value_retrieval(f0a, r1a); test_future_value_retrieval(f0b, r1b); test_future_value_retrieval(f0c, r1c); test_future_value_retrieval(f0d, r1d); - ASSERT_EQ(r0, r1a); - ASSERT_EQ(r0, r1b); - ASSERT_EQ(r0, r1c); - ASSERT_EQ(r0, r1d); -} + auto tolerance = std::max(std::abs(0.1f * r0), T(precision)); -TYPED_TEST(AsyncReduceTests, test_async_reduce_counting_iterator) + ASSERT_NEAR(r0, r1a, tolerance); + ASSERT_NEAR(r0, r1b, tolerance); + ASSERT_NEAR(r0, r1c, tolerance); + ASSERT_NEAR(r0, r1d, tolerance); +}; + +TYPED_TEST(AsyncReduceTests, TestAsyncReduceCountingIterator) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_counting_iterator) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyCountingIterator) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_counting_iterator_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceCountingIteratorInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_counting_iterator_init) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyCountingIteratorInit) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_counting_iterator_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceCountingIteratorInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_counting_iterator_init_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyCountingIteratorInitPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_counting_iterator_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceCountingIteratorInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } -TYPED_TEST(AsyncReduceTests, test_async_reduce_policy_counting_iterator_init_custom_plus) +TYPED_TEST(AsyncReduceTests, TestAsyncReducePolicyCountingIteratorInitCustomPlus) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; - test_async_reduce_counting_iterator(); + testAsyncReduceCountingIterator(); } /////////////////////////////////////////////////////////////////////////////// -TYPED_TEST(AsyncReduceTests, test_async_reduce_using) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceUsing) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); - thrust::host_vector h0(random_integers(size)); - thrust::device_vector d0a(h0); - thrust::device_vector d0b(h0); + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); + thrust::device_vector d0a(h0); + thrust::device_vector d0b(h0); - thrust::device_future f0a; - thrust::device_future f0b; + ASSERT_EQ(h0, d0a); + ASSERT_EQ(h0, d0b); - // When you import the customization points into the global namespace, - // they should be selected instead of the synchronous algorithms. - { - using namespace thrust::async; - f0a = reduce(d0a.begin(), d0a.end()); - } - { - using thrust::async::reduce; - f0b = reduce(d0b.begin(), d0b.end()); - } + thrust::device_future f0a; + thrust::device_future f0b; + + // When you import the customization points into the global namespace, + // they should be selected instead of the synchronous algorithms. + { + using namespace thrust::async; + f0a = reduce(d0a.begin(), d0a.end()); + } + { + using thrust::async::reduce; + f0b = reduce(d0b.begin(), d0b.end()); + } + + // ADL should find the synchronous algorithms. + // This potentially runs concurrently with the copies. + T const r0 = reduce(h0.begin(), h0.end()); - // ADL should find the synchronous algorithms. - // This potentially runs concurrently with the copies. - T const r0 = reduce(h0.begin(), h0.end()); + T r1a; + T r1b; - T r1a; - T r1b; + test_future_value_retrieval(f0a, r1a); + test_future_value_retrieval(f0b, r1b); - test_future_value_retrieval(f0a, r1a); - test_future_value_retrieval(f0b, r1b); + auto tolerance = std::max(std::abs(0.1f * r0), T(precision)); - ASSERT_EQ(r0, r1a); - ASSERT_EQ(r0, r1b); + ASSERT_NEAR(r0, r1a, tolerance); + ASSERT_NEAR(r0, r1b, tolerance); + } } -} +}; /////////////////////////////////////////////////////////////////////////////// -TYPED_TEST(AsyncReduceTests, test_async_reduce_after) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceAfter) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); - thrust::host_vector h0(random_integers(size)); - thrust::device_vector d0(h0); + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); - ASSERT_EQ(h0, d0); + thrust::device_vector d0(h0); - auto f0 = thrust::async::reduce(d0.begin(), d0.end()); + ASSERT_EQ(h0, d0); - ASSERT_EQ(true, f0.valid_stream()); + auto f0 = thrust::async::reduce(d0.begin(), d0.end()); - auto const f0_stream = f0.stream().native_handle(); + ASSERT_EQ(true, f0.valid_stream()); - auto f1 = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); + auto const f0_stream = f0.stream().native_handle(); - // Verify that double consumption of a future produces an exception. - ASSERT_THROW(auto x = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); - THRUST_UNUSED_VAR(x), thrust::event_error); + auto f1 = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); - ASSERT_EQ_QUIET(f0_stream, f1.stream().native_handle()); + // Verify that double consumption of a future produces an exception. + ASSERT_THROW(auto x = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); + THRUST_UNUSED_VAR(x), thrust::event_error); - auto after_policy2 = thrust::device.after(f1); + ASSERT_EQ_QUIET(f0_stream, f1.stream().native_handle()); - auto f2 = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); + auto after_policy2 = thrust::device.after(f1); - // Verify that double consumption of a policy produces an exception. - ASSERT_THROW(auto x = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); - THRUST_UNUSED_VAR(x), thrust::event_error); + auto f2 = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); - ASSERT_EQ_QUIET(f0_stream, f2.stream().native_handle()); + // Verify that double consumption of a policy produces an exception. + ASSERT_THROW(auto x = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); + THRUST_UNUSED_VAR(x), thrust::event_error); - // This potentially runs concurrently with the copies. - T const r0 = thrust::reduce(h0.begin(), h0.end()); + ASSERT_EQ_QUIET(f0_stream, f2.stream().native_handle()); - T r1; + // This potentially runs concurrently with the copies. + T const r0 = thrust::reduce(h0.begin(), h0.end()); - test_future_value_retrieval(f2, r1); + T r1; - ASSERT_EQ(r0, r1); + test_future_value_retrieval(f2, r1); + + auto tolerance = std::max(std::abs(0.1f * r0), T(precision)); + + ASSERT_NEAR(r0, r1, tolerance); + } } -} +}; /////////////////////////////////////////////////////////////////////////////// -TYPED_TEST(AsyncReduceTests, test_async_reduce_on_then_after) +TYPED_TEST(AsyncReduceTests, TestAsyncReduceOnThenAfter) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); - thrust::host_vector h0(random_integers(size)); - thrust::device_vector d0(h0); + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); - ASSERT_EQ(h0, d0); + thrust::device_vector d0(h0); - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream; - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME( - StreamCreateWithFlags)(&stream, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + ASSERT_EQ(h0, d0); - auto f0 = thrust::async::reduce(thrust::device.on(stream), d0.begin(), d0.end()); + hipStream_t stream; + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream, hipStreamNonBlocking)); - ASSERT_EQ_QUIET(stream, f0.stream().native_handle()); + auto f0 = thrust::async::reduce(thrust::device.on(stream), d0.begin(), d0.end()); - auto f1 = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); + ASSERT_EQ_QUIET(stream, f0.stream().native_handle()); - // Verify that double consumption of a future produces an exception. - ASSERT_THROW(auto x = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); - THRUST_UNUSED_VAR(x), thrust::event_error); + auto f1 = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); - ASSERT_EQ_QUIET(stream, f1.stream().native_handle()); + // Verify that double consumption of a future produces an exception. + ASSERT_THROW(auto x = thrust::async::reduce(thrust::device.after(f0), d0.begin(), d0.end()); + THRUST_UNUSED_VAR(x), thrust::event_error); - auto after_policy2 = thrust::device.after(f1); + ASSERT_EQ_QUIET(stream, f1.stream().native_handle()); - auto f2 = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); + auto after_policy2 = thrust::device.after(f1); - // Verify that double consumption of a policy produces an exception. - ASSERT_THROW(auto x = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); - THRUST_UNUSED_VAR(x), thrust::event_error); + auto f2 = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); - ASSERT_EQ_QUIET(stream, f2.stream().native_handle()); + // Verify that double consumption of a policy produces an exception. + ASSERT_THROW(auto x = thrust::async::reduce(after_policy2, d0.begin(), d0.end()); + THRUST_UNUSED_VAR(x), thrust::event_error); - // This potentially runs concurrently with the copies. - T const r0 = thrust::reduce(h0.begin(), h0.end()); + ASSERT_EQ_QUIET(stream, f2.stream().native_handle()); - T r1; + // This potentially runs concurrently with the copies. + T const r0 = thrust::reduce(h0.begin(), h0.end()); + + T r1; + + test_future_value_retrieval(f2, r1); - test_future_value_retrieval(f2, r1); + auto tolerance = std::max(std::abs(0.1f * r0), T(precision)); - ASSERT_EQ(r0, r1); + ASSERT_NEAR(r0, r1, tolerance); - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream)); + } } -} +}; /////////////////////////////////////////////////////////////////////////////// -TYPED_TEST(AsyncReduceTests, test_async_reduce_allocator_on_then_after) +/* +TYPED_TEST(AsyncReduceTests, TestAsyncReduceAllocatorOnThenAfter) { - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - using T = typename TestFixture::input_type; - for (auto size : get_sizes()) - { - SCOPED_TRACE(testing::Message() << "with size = " << size); - - thrust::host_vector h0(random_integers(size)); - thrust::device_vector d0(h0); - - ASSERT_EQ(h0, d0); + SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); + using T = typename TestFixture::input_type; + for(auto size : get_sizes()) + { + SCOPED_TRACE(testing::Message() << "with size = " << size); + for(size_t seed_index = 0; seed_index < random_seeds_count + seed_size; seed_index++) + { + unsigned int seed + = seed_index < random_seeds_count ? rand() : seeds[seed_index - random_seeds_count]; + SCOPED_TRACE(testing::Message() << "with seed= " << seed); + + thrust::host_vector h0 = get_random_data( + size, saturate_cast(-1000), saturate_cast(1000), seed); + + thrust::device_vector d0(h0); + + ASSERT_EQ(h0, d0); + + hipStream_t stream0; + thrust::hip_rocprim::throw_on_error( + hipStreamCreateWithFlags(&stream0, hipStreamNonBlocking) + ); + + hipStream_t stream1; + thrust::hip_rocprim::throw_on_error( + hipStreamCreateWithFlags(&stream1, hipStreamNonBlocking) + ); + + auto f0 = thrust::async::reduce( + thrust::device(thrust::device_allocator{}).on(stream0) + , d0.begin(), d0.end() + ); + + ASSERT_EQ_QUIET(stream0, f0.stream().native_handle()); + + auto f1 = thrust::async::reduce( + thrust::device(thrust::device_allocator{}).after(f0) + , d0.begin(), d0.end() + ); + + ASSERT_THROW( + auto x = thrust::async::reduce( + thrust::device(thrust::device_allocator{}).after(f0) + , d0.begin(), d0.end() + ); + THRUST_UNUSED_VAR(x) + , thrust::event_error + ); + + ASSERT_EQ_QUIET(stream0, f1.stream().native_handle()); + + auto f2 = thrust::async::reduce( + thrust::device(thrust::device_allocator{}).on(stream1).after(f1) + , d0.begin(), d0.end() + ); + + ASSERT_THROW( + auto x = thrust::async::reduce( + thrust::device(thrust::device_allocator{}).on(stream1).after(f1) + , d0.begin(), d0.end() + ); + THRUST_UNUSED_VAR(x) + , thrust::event_error + ); + + KNOWN_FAILURE; + // FIXME: The below fails because you can't combine allocator attachment, + // `.on`, and `.after`. + ASSERT_EQ_QUIET(stream1, f2.stream().native_handle()); + + // This potentially runs concurrently with the copies. + T const r0 = thrust::reduce(h0.begin(), h0.end()); + + T const r1 = TEST_FUTURE_VALUE_RETRIEVAL(f2); + + ASSERT_EQ(r0, r1); + + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream0)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream1)); + } + } +} - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream0; - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME( - StreamCreateWithFlags)(&stream0, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); +/////////////////////////////////////////////////////////////////////////////// - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream1; - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME( - StreamCreateWithFlags)(&stream1, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); +TYPED_TEST(AsyncReduceTests, TestAsyncReduceCaching) +{ + SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); + using T = typename TestFixture::input_type; + for(auto size : get_sizes()) + { + SCOPED_TRACE(testing::Message() << "with size = " << size); + for(size_t seed_index = 0; seed_index < random_seeds_count + seed_size; seed_index++) + { + unsigned int seed + = seed_index < random_seeds_count ? rand() : seeds[seed_index - random_seeds_count]; + SCOPED_TRACE(testing::Message() << "with seed= " << seed); - auto f0 = thrust::async::reduce(thrust::device(thrust::device_allocator{}).on(stream0), d0.begin(), d0.end()); + thrust::host_vector h0 = get_random_data( + size, saturate_cast(-1000), saturate_cast(1000), seed); - ASSERT_EQ_QUIET(stream0, f0.stream().native_handle()); + constexpr std::int64_t m = 32; + thrust::device_vector d0(h0); - auto f1 = thrust::async::reduce(thrust::device(thrust::device_allocator{}).after(f0), d0.begin(), d0.end()); + ASSERT_EQ(h0, d0); - ASSERT_THROW( - auto x = thrust::async::reduce(thrust::device(thrust::device_allocator{}).after(f0), d0.begin(), d0.end()); - THRUST_UNUSED_VAR(x), thrust::event_error); + T const* f0_raw_data; - ASSERT_EQ_QUIET(stream0, f1.stream().native_handle()); + { + // Perform one reduction to ensure there's an entry in the caching + // allocator. + auto f0 = thrust::async::reduce(d0.begin(), d0.end()); - auto f2 = thrust::async::reduce( - thrust::device(thrust::device_allocator{}).on(stream1).after(f1), d0.begin(), d0.end()); + TEST_EVENT_WAIT(f0); - ASSERT_THROW(auto x = thrust::async::reduce( - thrust::device(thrust::device_allocator{}).on(stream1).after(f1), d0.begin(), d0.end()); - THRUST_UNUSED_VAR(x), thrust::event_error); + f0_raw_data = f0.raw_data(); + } - // KNOWN_FAILURE; - // FIXME: The below fails because you can't combine allocator attachment, - // `.on`, and `.after`. - // The `#if 0` can be removed once the KNOWN_FAILURE is resolved. -# if 0 - ASSERT_EQ_QUIET(stream1, f2.stream().native_handle()); + for (std::int64_t i = 0; i < m; ++i) + { + auto f1 = thrust::async::reduce(d0.begin(), d0.end()); - // This potentially runs concurrently with the copies. - T const r0 = thrust::reduce(h0.begin(), h0.end()); + ASSERT_EQ(true, f1.valid_stream()); + ASSERT_EQ(true, f1.valid_content()); - T r1; + ASSERT_EQ_QUIET(f0_raw_data, f1.raw_data()); - test_future_value_retrieval(f2, r1); + // This potentially runs concurrently with the copies. + T const r0 = thrust::reduce(h0.begin(), h0.end()); - ASSERT_EQ(r0, r1); + T const r1 = TEST_FUTURE_VALUE_RETRIEVAL(f1); - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream0)); - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream1)); -# endif - } -} + ASSERT_EQ(r0, r1); + } + } + } +}; +*/ /////////////////////////////////////////////////////////////////////////////// -TYPED_TEST(AsyncReduceTests, test_async_reduce_caching) +TYPED_TEST(AsyncReduceTests, TestAsyncCopyThenReduce) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); - constexpr std::int64_t m = 32; - - thrust::host_vector h0(random_integers(size)); - thrust::device_vector d0(h0); - - ASSERT_EQ(h0, d0); - - T const* f0_raw_data; - + for (auto seed : get_seeds()) { - // Perform one reduction to ensure there's an entry in the caching - // allocator. - auto f0 = thrust::async::reduce(d0.begin(), d0.end()); - - TEST_EVENT_WAIT(f0); - - f0_raw_data = f0.raw_data(); - } - - for (std::int64_t i = 0; i < m; ++i) - { - auto f1 = thrust::async::reduce(d0.begin(), d0.end()); - - ASSERT_EQ(true, f1.valid_stream()); - ASSERT_EQ(true, f1.valid_content()); - - ASSERT_EQ_QUIET(f0_raw_data, f1.raw_data()); + SCOPED_TRACE(testing::Message() << "with seed= " << seed); + + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); + + thrust::device_vector d0a(h0); + thrust::device_vector d0b(h0); + thrust::device_vector d0c(h0); + thrust::device_vector d0d(h0); + + auto f0a = thrust::async::copy(h0.begin(), h0.end(), d0a.begin()); + auto f0b = thrust::async::copy(h0.begin(), h0.end(), d0b.begin()); + auto f0c = thrust::async::copy(h0.begin(), h0.end(), d0c.begin()); + auto f0d = thrust::async::copy(h0.begin(), h0.end(), d0d.begin()); + + ASSERT_EQ(true, f0a.valid_stream()); + ASSERT_EQ(true, f0b.valid_stream()); + ASSERT_EQ(true, f0c.valid_stream()); + ASSERT_EQ(true, f0d.valid_stream()); + + auto const f0a_stream = f0a.stream().native_handle(); + auto const f0b_stream = f0b.stream().native_handle(); + auto const f0c_stream = f0c.stream().native_handle(); + auto const f0d_stream = f0d.stream().native_handle(); + + auto f1a = thrust::async::reduce(thrust::device.after(f0a), d0a.begin(), d0a.end()); + auto f1b = thrust::async::reduce(thrust::device.after(f0b), d0b.begin(), d0b.end()); + auto f1c = thrust::async::reduce(thrust::device.after(f0c), d0c.begin(), d0c.end()); + auto f1d = thrust::async::reduce(thrust::device.after(f0d), d0d.begin(), d0d.end()); + + ASSERT_EQ(false, f0a.valid_stream()); + ASSERT_EQ(false, f0b.valid_stream()); + ASSERT_EQ(false, f0c.valid_stream()); + ASSERT_EQ(false, f0d.valid_stream()); + + ASSERT_EQ(true, f1a.valid_stream()); + ASSERT_EQ(true, f1a.valid_content()); + ASSERT_EQ(true, f1b.valid_stream()); + ASSERT_EQ(true, f1b.valid_content()); + ASSERT_EQ(true, f1c.valid_stream()); + ASSERT_EQ(true, f1c.valid_content()); + ASSERT_EQ(true, f1d.valid_stream()); + ASSERT_EQ(true, f1d.valid_content()); + + // Verify that streams were stolen. + ASSERT_EQ_QUIET(f0a_stream, f1a.stream().native_handle()); + ASSERT_EQ_QUIET(f0b_stream, f1b.stream().native_handle()); + ASSERT_EQ_QUIET(f0c_stream, f1c.stream().native_handle()); + ASSERT_EQ_QUIET(f0d_stream, f1d.stream().native_handle()); // This potentially runs concurrently with the copies. T const r0 = thrust::reduce(h0.begin(), h0.end()); - T r1; - test_future_value_retrieval(f1, r1); + T r1a; + T r1b; + T r1c; + T r1d; - ASSERT_EQ(r0, r1); - } - } -} - -/////////////////////////////////////////////////////////////////////////////// + test_future_value_retrieval(f1a, r1a); + test_future_value_retrieval(f1b, r1b); + test_future_value_retrieval(f1c, r1c); + test_future_value_retrieval(f1d, r1d); -TYPED_TEST(AsyncReduceTests, test_async_copy_then_reduce) -{ - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - using T = typename TestFixture::input_type; - for (auto size : get_sizes()) - { - SCOPED_TRACE(testing::Message() << "with size = " << size); + auto tolerance = std::max(std::abs(0.1f * r0), T(precision)); - thrust::host_vector h0a(random_integers(size)); - thrust::host_vector h0b(random_integers(size)); - thrust::host_vector h0c(random_integers(size)); - thrust::host_vector h0d(random_integers(size)); - - thrust::device_vector d0a(size); - thrust::device_vector d0b(size); - thrust::device_vector d0c(size); - thrust::device_vector d0d(size); - - auto f0a = thrust::async::copy(h0a.begin(), h0a.end(), d0a.begin()); - auto f0b = thrust::async::copy(h0b.begin(), h0b.end(), d0b.begin()); - auto f0c = thrust::async::copy(h0c.begin(), h0c.end(), d0c.begin()); - auto f0d = thrust::async::copy(h0d.begin(), h0d.end(), d0d.begin()); - - ASSERT_EQ(true, f0a.valid_stream()); - ASSERT_EQ(true, f0b.valid_stream()); - ASSERT_EQ(true, f0c.valid_stream()); - ASSERT_EQ(true, f0d.valid_stream()); - - auto const f0a_stream = f0a.stream().native_handle(); - auto const f0b_stream = f0b.stream().native_handle(); - auto const f0c_stream = f0c.stream().native_handle(); - auto const f0d_stream = f0d.stream().native_handle(); - - auto f1a = thrust::async::reduce(thrust::device.after(f0a), d0a.begin(), d0a.end()); - auto f1b = thrust::async::reduce(thrust::device.after(f0b), d0b.begin(), d0b.end()); - auto f1c = thrust::async::reduce(thrust::device.after(f0c), d0c.begin(), d0c.end()); - auto f1d = thrust::async::reduce(thrust::device.after(f0d), d0d.begin(), d0d.end()); - - ASSERT_EQ(false, f0a.valid_stream()); - ASSERT_EQ(false, f0b.valid_stream()); - ASSERT_EQ(false, f0c.valid_stream()); - ASSERT_EQ(false, f0d.valid_stream()); - - ASSERT_EQ(true, f1a.valid_stream()); - ASSERT_EQ(true, f1a.valid_content()); - ASSERT_EQ(true, f1b.valid_stream()); - ASSERT_EQ(true, f1b.valid_content()); - ASSERT_EQ(true, f1c.valid_stream()); - ASSERT_EQ(true, f1c.valid_content()); - ASSERT_EQ(true, f1d.valid_stream()); - ASSERT_EQ(true, f1d.valid_content()); - - // Verify that streams were stolen. - ASSERT_EQ_QUIET(f0a_stream, f1a.stream().native_handle()); - ASSERT_EQ_QUIET(f0b_stream, f1b.stream().native_handle()); - ASSERT_EQ_QUIET(f0c_stream, f1c.stream().native_handle()); - ASSERT_EQ_QUIET(f0d_stream, f1d.stream().native_handle()); - - // This potentially runs concurrently with the copies. - T const r0 = thrust::reduce(h0a.begin(), h0a.end()); - - T r1a; - T r1b; - T r1c; - T r1d; - - test_future_value_retrieval(f1a, r1a); - test_future_value_retrieval(f1b, r1b); - test_future_value_retrieval(f1c, r1c); - test_future_value_retrieval(f1d, r1d); - - ASSERT_EQ(r0, r1a); - ASSERT_EQ(r0, r1b); - ASSERT_EQ(r0, r1c); - ASSERT_EQ(r0, r1d); + ASSERT_NEAR(r0, r1a, tolerance); + ASSERT_NEAR(r0, r1b, tolerance); + ASSERT_NEAR(r0, r1c, tolerance); + ASSERT_NEAR(r0, r1d, tolerance); + } } } /////////////////////////////////////////////////////////////////////////////// // TODO: when_all from reductions. - -// See also issue: https://github.com/NVIDIA/cccl/issues/1886 -struct tuple_sum -{ - __device__ thrust::tuple - operator()(const thrust::tuple& t1, const thrust::tuple& t2) const - { - return thrust::make_tuple(thrust::get<0>(t1) + thrust::get<0>(t2), thrust::get<1>(t1) + thrust::get<1>(t2)); - } -}; - -TEST(AsyncReduceTests, test_async_reduce_bug1886) -{ -#ifdef ADDRESS_SANITIZER_BUILD - GTEST_SKIP() << "This test is disabled in ASAN builds due to its memory usage."; -#endif - - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - - // Initialize input data - thrust::device_vector d_data1{1, 2, 3, 4, 5}; - thrust::device_vector d_data2{10, 20, 30, 40, 50}; - - using TupleType = thrust::tuple; - using IteratorType = - thrust::zip_iterator::iterator, thrust::device_vector::iterator>>; - - TupleType result; - try - { - // Create zip_begin and zip_end iterators - IteratorType zip_begin = thrust::make_zip_iterator(thrust::make_tuple(d_data1.begin(), d_data2.begin())); - IteratorType zip_end = thrust::make_zip_iterator(thrust::make_tuple(d_data2.end(), d_data2.end())); - - // Initialize the starting tuple - TupleType init = thrust::make_tuple(0, 0); - - // Perform async reduce using zip_begin and zip_end - auto future = thrust::async::reduce(thrust::device, zip_begin, zip_end, init, tuple_sum()); - - // Get the result - result = future.get(); - } - catch (const ::std::bad_alloc& e) - { - (void) hipGetLastError(); - GTEST_SKIP() << "std::bad_alloc: " << e.what(); - } - - // Print the result - std::cout << "Sum: (" << thrust::get<0>(result) << ", " << thrust::get<1>(result) << ")" << std::endl; -} - -#endif - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC diff --git a/projects/rocthrust/test/test_async_reduce_into.cpp b/projects/rocthrust/test/test_async_reduce_into.cpp index 44d73c1c767c..14fc6e8fa193 100644 --- a/projects/rocthrust/test/test_async_reduce_into.cpp +++ b/projects/rocthrust/test/test_async_reduce_into.cpp @@ -33,8 +33,6 @@ TESTS_DEFINE(AsyncReduceIntoTests, NumericalTestsParams); -THRUST_SUPPRESS_DEPRECATED_PUSH - template struct custom_plus { diff --git a/projects/rocthrust/test/test_async_scan.cpp b/projects/rocthrust/test/test_async_scan.cpp index 38a6f5a096de..e01dee7a879d 100644 --- a/projects/rocthrust/test/test_async_scan.cpp +++ b/projects/rocthrust/test/test_async_scan.cpp @@ -25,8 +25,6 @@ TESTS_DEFINE(AsyncScanTests, NumericalTestsParams) -THRUST_SUPPRESS_DEPRECATED_PUSH - enum wait_policy { wait_for_futures, diff --git a/projects/rocthrust/test/test_async_sort.cpp b/projects/rocthrust/test/test_async_sort.cpp index 902352c648f5..8dab1a820a44 100644 --- a/projects/rocthrust/test/test_async_sort.cpp +++ b/projects/rocthrust/test/test_async_sort.cpp @@ -17,9 +17,6 @@ #include -// need to suppress deprecation warnings inside a lot of thrust headers -THRUST_SUPPRESS_DEPRECATED_PUSH - // Disabled on MSVC && NVCC < 11.1 for GH issue #1098. #if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && defined(__CUDACC__) # if (__CUDACC_VER_MAJOR__ < 11) || (__CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ < 1) @@ -307,8 +304,3 @@ TYPED_TEST(AsyncSortTests, test_async_sort_policy_custom_greater_no_wait) // TODO: Test future return type. #endif - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC diff --git a/projects/rocthrust/test/test_async_transform.cpp b/projects/rocthrust/test/test_async_transform.cpp index 970d1bb099d4..8072a413bf47 100644 --- a/projects/rocthrust/test/test_async_transform.cpp +++ b/projects/rocthrust/test/test_async_transform.cpp @@ -17,89 +17,67 @@ #include -#if THRUST_CPP_DIALECT >= 2017 - -# include -# include -# include -# include - -# include "test_param_fixtures.hpp" -# include "test_real_assertions.hpp" -# include "test_utils.hpp" - -using BuiltinNumericTypes = ::testing::Types< - Params, - Params, - Params, - Params, - Params, - Params, - Params, - Params, - Params, - Params, - Params, - Params, - Params>; +#include +#include +#include +#include -TESTS_DEFINE(AsyncTransformTests, NumericalTestsParams); -TESTS_DEFINE(AsyncTransformBuiltinTests, BuiltinNumericTypes); - -THRUST_SUPPRESS_DEPRECATED_PUSH +#include "test_param_fixtures.hpp" +#include "test_real_assertions.hpp" +#include "test_utils.hpp" template struct divide_by_2 { - THRUST_HOST_DEVICE T operator()(T x) const + __host__ __device__ T operator()(T x) const { return x / 2; } }; -# define DEFINE_STATEFUL_ASYNC_TRANSFORM_UNARY_INVOKER(NAME, MEMBERS, CTOR, DTOR, VALIDATE, ...) \ - template \ - struct NAME \ - { \ - MEMBERS \ - \ - NAME() \ - { \ - CTOR \ - } \ - \ - ~NAME() \ - { \ - DTOR \ - } \ - \ - template \ - void validate_event(Event& e) \ - { \ - THRUST_UNUSED_VAR(e); \ - VALIDATE \ - } \ - \ - template \ - THRUST_HOST auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& output, UnaryOperation&& op) \ - THRUST_DECLTYPE_RETURNS(::thrust::async::transform(__VA_ARGS__)) \ - }; \ - /**/ - -# define DEFINE_ASYNC_TRANSFORM_UNARY_INVOKER(NAME, ...) \ - DEFINE_STATEFUL_ASYNC_TRANSFORM_UNARY_INVOKER( \ - NAME, THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), __VA_ARGS__) \ - /**/ - -# define DEFINE_SYNC_TRANSFORM_UNARY_INVOKER(NAME, ...) \ - template \ - struct NAME \ - { \ - template \ - THRUST_HOST auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& output, UnaryOperation&& op) \ - THRUST_RETURNS(::thrust::transform(__VA_ARGS__)) \ - }; \ - /**/ +#define DEFINE_STATEFUL_ASYNC_TRANSFORM_UNARY_INVOKER(NAME, MEMBERS, CTOR, DTOR, VALIDATE, ...) \ + template \ + struct NAME \ + { \ + MEMBERS \ + \ + NAME() \ + { \ + CTOR \ + } \ + \ + ~NAME() \ + { \ + DTOR \ + } \ + \ + template \ + void validate_event(Event& e) \ + { \ + THRUST_UNUSED_VAR(e); \ + VALIDATE \ + } \ + \ + template \ + __host__ auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& output, UnaryOperation&& op) \ + THRUST_DECLTYPE_RETURNS(::thrust::async::transform(__VA_ARGS__)) \ + }; \ + /**/ + +#define DEFINE_ASYNC_TRANSFORM_UNARY_INVOKER(NAME, ...) \ + DEFINE_STATEFUL_ASYNC_TRANSFORM_UNARY_INVOKER( \ + NAME, THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), THRUST_PP_EMPTY(), __VA_ARGS__) \ + /**/ + +#define DEFINE_SYNC_TRANSFORM_UNARY_INVOKER(NAME, ...) \ + template \ + struct NAME \ + { \ + template \ + __host__ auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& output, UnaryOperation&& op) \ + THRUST_DECLTYPE_RETURNS(::thrust::transform(__VA_ARGS__)) \ + }; \ + /**/ DEFINE_ASYNC_TRANSFORM_UNARY_INVOKER( transform_unary_async_invoker, THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(output), THRUST_FWD(op)); @@ -121,14 +99,13 @@ DEFINE_STATEFUL_ASYNC_TRANSFORM_UNARY_INVOKER( transform_unary_async_invoker_device_on // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -143,14 +120,13 @@ DEFINE_STATEFUL_ASYNC_TRANSFORM_UNARY_INVOKER( transform_unary_async_invoker_device_allocator_on // Members. , - SPECIALIZE_DEVICE_RESOURCE_NAME(Stream_t) stream_; + hipStream_t stream_; // Constructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamCreateWithFlags)( - &stream_, SPECIALIZE_DEVICE_RESOURCE_NAME(StreamNonBlocking))); + thrust::hip_rocprim::throw_on_error(hipStreamCreateWithFlags(&stream_, hipStreamNonBlocking)); // Destructor. , - thrust::THRUST_DEVICE_BACKEND_DETAIL::throw_on_error(SPECIALIZE_DEVICE_RESOURCE_NAME(StreamDestroy)(stream_)); + thrust::hip_rocprim::throw_on_error(hipStreamDestroy(stream_)); // `validate_event` member. , ASSERT_EQ_QUIET(stream_, e.stream().native_handle()); @@ -167,6 +143,8 @@ DEFINE_SYNC_TRANSFORM_UNARY_INVOKER( /////////////////////////////////////////////////////////////////////////////// +TESTS_DEFINE(AsyncTransformTests, NumericalTestsParams); + template class AsyncTransformUnaryInvoker, @@ -174,64 +152,73 @@ template class UnaryOperation> -THRUST_HOST void test_async_transform_unary() +void test_async_transform_unary() { for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); - thrust::host_vector h0(random_integers(size)); + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); - thrust::device_vector d0a(h0); - thrust::device_vector d0b(h0); - thrust::device_vector d0c(h0); - thrust::device_vector d0d(h0); + thrust::device_vector d0a(h0); + thrust::device_vector d0b(h0); + thrust::device_vector d0c(h0); + thrust::device_vector d0d(h0); - thrust::host_vector h1(size); + thrust::host_vector h1(size); - thrust::device_vector d1a(size); - thrust::device_vector d1b(size); - thrust::device_vector d1c(size); - thrust::device_vector d1d(size); + thrust::device_vector d1a(size); + thrust::device_vector d1b(size); + thrust::device_vector d1c(size); + thrust::device_vector d1d(size); - AsyncTransformUnaryInvoker invoke_async; - SyncTransformUnaryInvoker invoke_sync; + AsyncTransformUnaryInvoker invoke_async; + SyncTransformUnaryInvoker invoke_sync; - UnaryOperation op; + UnaryOperation op; - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - ASSERT_EQ(h0, d0c); - ASSERT_EQ(h0, d0d); + ASSERT_EQ(h0, d0a); + ASSERT_EQ(h0, d0b); + ASSERT_EQ(h0, d0c); + ASSERT_EQ(h0, d0d); - auto f0a = invoke_async(d0a.begin(), d0a.end(), d1a.begin(), op); - auto f0b = invoke_async(d0b.begin(), d0b.end(), d1b.begin(), op); - auto f0c = invoke_async(d0c.begin(), d0c.end(), d1c.begin(), op); - auto f0d = invoke_async(d0d.begin(), d0d.end(), d1d.begin(), op); + auto f0a = invoke_async(d0a.begin(), d0a.end(), d1a.begin(), op); + auto f0b = invoke_async(d0b.begin(), d0b.end(), d1b.begin(), op); + auto f0c = invoke_async(d0c.begin(), d0c.end(), d1c.begin(), op); + auto f0d = invoke_async(d0d.begin(), d0d.end(), d1d.begin(), op); - invoke_async.validate_event(f0a); - invoke_async.validate_event(f0b); - invoke_async.validate_event(f0c); - invoke_async.validate_event(f0d); + invoke_async.validate_event(f0a); + invoke_async.validate_event(f0b); + invoke_async.validate_event(f0c); + invoke_async.validate_event(f0d); - // This potentially runs concurrently with the copies. - invoke_sync(h0.begin(), h0.end(), h1.begin(), op); + // This potentially runs concurrently with the copies. + invoke_sync(h0.begin(), h0.end(), h1.begin(), op); - TEST_EVENT_WAIT(thrust::when_all(f0a, f0b, f0c, f0d)); + TEST_EVENT_WAIT(thrust::when_all(f0a, f0b, f0c, f0d)); - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - ASSERT_EQ(h0, d0c); - ASSERT_EQ(h0, d0d); + auto tolerance = T(precision); - ASSERT_EQ(h1, d1a); - ASSERT_EQ(h1, d1b); - ASSERT_EQ(h1, d1c); - ASSERT_EQ(h1, d1d); + thrust::host_vector r1a = d1a; + thrust::host_vector r1b = d1b; + thrust::host_vector r1c = d1c; + thrust::host_vector r1d = d1d; + + for (uint32_t i = 0; i < h0.size(); i++) + { + ASSERT_NEAR(h1[i], r1a[i], tolerance); + ASSERT_NEAR(h1[i], r1b[i], tolerance); + ASSERT_NEAR(h1[i], r1c[i], tolerance); + ASSERT_NEAR(h1[i], r1d[i], tolerance); + } + } } -} +}; -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnary) { #ifdef ADDRESS_SANITIZER_BUILD GTEST_SKIP() << "Skipping test due to memory constraints in address sanitizer build."; @@ -242,14 +229,14 @@ TYPED_TEST(AsyncTransformTests, test_async_transform_unary_divide_by_2) test_async_transform_unary(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_policy_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryDevice) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; test_async_transform_unary(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_policy_allocator_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryDeviceAllocator) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; @@ -259,14 +246,14 @@ TYPED_TEST(AsyncTransformTests, test_async_transform_unary_policy_allocator_divi divide_by_2>(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_policy_on_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryDeviceOn) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; test_async_transform_unary(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_policy_allocator_on_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryDeviceAllocatorOn) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; @@ -285,66 +272,80 @@ template class UnaryOperation> -THRUST_HOST void test_async_transform_unary_inplace() +void test_async_transform_unary_inplace() { for (auto size : get_sizes()) { SCOPED_TRACE(testing::Message() << "with size = " << size); + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); - thrust::host_vector h0(random_integers(size)); + thrust::host_vector h0 = get_random_data(size, saturate_cast(-1000), saturate_cast(1000), seed); - thrust::device_vector d0a(h0); - thrust::device_vector d0b(h0); - thrust::device_vector d0c(h0); - thrust::device_vector d0d(h0); + thrust::device_vector d0a(h0); + thrust::device_vector d0b(h0); + thrust::device_vector d0c(h0); + thrust::device_vector d0d(h0); - AsyncTransformUnaryInvoker invoke_async; - SyncTransformUnaryInvoker invoke_sync; + AsyncTransformUnaryInvoker invoke_async; + SyncTransformUnaryInvoker invoke_sync; - UnaryOperation op; + UnaryOperation op; - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - ASSERT_EQ(h0, d0c); - ASSERT_EQ(h0, d0d); + ASSERT_EQ(h0, d0a); + ASSERT_EQ(h0, d0b); + ASSERT_EQ(h0, d0c); + ASSERT_EQ(h0, d0d); - auto f0a = invoke_async(d0a.begin(), d0a.end(), d0a.begin(), op); - auto f0b = invoke_async(d0b.begin(), d0b.end(), d0b.begin(), op); - auto f0c = invoke_async(d0c.begin(), d0c.end(), d0c.begin(), op); - auto f0d = invoke_async(d0d.begin(), d0d.end(), d0d.begin(), op); + auto f0a = invoke_async(d0a.begin(), d0a.end(), d0a.begin(), op); + auto f0b = invoke_async(d0b.begin(), d0b.end(), d0b.begin(), op); + auto f0c = invoke_async(d0c.begin(), d0c.end(), d0c.begin(), op); + auto f0d = invoke_async(d0d.begin(), d0d.end(), d0d.begin(), op); - invoke_async.validate_event(f0a); - invoke_async.validate_event(f0b); - invoke_async.validate_event(f0c); - invoke_async.validate_event(f0d); + invoke_async.validate_event(f0a); + invoke_async.validate_event(f0b); + invoke_async.validate_event(f0c); + invoke_async.validate_event(f0d); - // This potentially runs concurrently with the copies. - invoke_sync(h0.begin(), h0.end(), h0.begin(), op); + // This potentially runs concurrently with the copies. + invoke_sync(h0.begin(), h0.end(), h0.begin(), op); - TEST_EVENT_WAIT(thrust::when_all(f0a, f0b, f0c, f0d)); + TEST_EVENT_WAIT(thrust::when_all(f0a, f0b, f0c, f0d)); - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - ASSERT_EQ(h0, d0c); - ASSERT_EQ(h0, d0d); + auto tolerance = T(precision); + + thrust::host_vector ra = d0a; + thrust::host_vector rb = d0b; + thrust::host_vector rc = d0c; + thrust::host_vector rd = d0d; + + for (uint32_t i = 0; i < h0.size(); i++) + { + ASSERT_NEAR(h0[i], ra[i], tolerance); + ASSERT_NEAR(h0[i], rb[i], tolerance); + ASSERT_NEAR(h0[i], rc[i], tolerance); + ASSERT_NEAR(h0[i], rd[i], tolerance); + } + } } -} +}; -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryInplace) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; test_async_transform_unary_inplace(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryInplaceDevice) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; test_async_transform_unary_inplace(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_allocator_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryInplaceDeviceAllocator) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; @@ -354,7 +355,7 @@ TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_alloca divide_by_2>(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_on_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryInplaceDeviceOn) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; @@ -364,7 +365,7 @@ TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_on_div divide_by_2>(); } -TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_allocator_on_divide_by_2) +TYPED_TEST(AsyncTransformTests, TestAsyncTransformUnaryInplaceDeviceAllocatorOn) { SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using T = typename TestFixture::input_type; @@ -375,139 +376,3 @@ TYPED_TEST(AsyncTransformTests, test_async_transform_unary_inplace_policy_alloca } /////////////////////////////////////////////////////////////////////////////// - -template - class AsyncTransformUnaryInvoker, - template - class SyncTransformUnaryInvoker, - template - class UnaryOperation> -THRUST_HOST void test_async_transform_unary_counting_iterator() -{ - constexpr std::size_t n = 15 * sizeof(T); - - ASSERT_LE(T(n), truncate_to_max_representable(n)); - - thrust::counting_iterator first(0); - thrust::counting_iterator last(n); - - thrust::host_vector h0(n); - - thrust::device_vector d0a(n); - thrust::device_vector d0b(n); - thrust::device_vector d0c(n); - thrust::device_vector d0d(n); - - AsyncTransformUnaryInvoker invoke_async; - SyncTransformUnaryInvoker invoke_sync; - - UnaryOperation op; - - auto f0a = invoke_async(first, last, d0a.begin(), op); - auto f0b = invoke_async(first, last, d0b.begin(), op); - auto f0c = invoke_async(first, last, d0c.begin(), op); - auto f0d = invoke_async(first, last, d0d.begin(), op); - - invoke_async.validate_event(f0a); - invoke_async.validate_event(f0b); - invoke_async.validate_event(f0c); - invoke_async.validate_event(f0d); - - // This potentially runs concurrently with the copies. - invoke_sync(first, last, h0.begin(), op); - - TEST_EVENT_WAIT(thrust::when_all(f0a, f0b, f0c, f0d)); - - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - ASSERT_EQ(h0, d0c); - ASSERT_EQ(h0, d0d); -} - -TYPED_TEST(AsyncTransformBuiltinTests, test_async_transform_unary_counting_iterator_divide_by_2) -{ - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - using T = typename TestFixture::input_type; - test_async_transform_unary_counting_iterator(); -} - -TYPED_TEST(AsyncTransformBuiltinTests, test_async_transform_unary_counting_iterator_policy_divide_by_2) -{ - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - using T = typename TestFixture::input_type; - test_async_transform_unary_counting_iterator(); -} - -/////////////////////////////////////////////////////////////////////////////// - -template class UnaryOperation> -THRUST_HOST void test_async_transform_using() -{ - for (auto size : get_sizes()) - { - SCOPED_TRACE(testing::Message() << "with size = " << size); - - thrust::host_vector h0(random_integers(size)); - - thrust::device_vector d0a(h0); - thrust::device_vector d0b(h0); - - thrust::host_vector h1(size); - - thrust::device_vector d1a(size); - thrust::device_vector d1b(size); - - UnaryOperation op; - - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - - thrust::device_event f0a; - thrust::device_event f0b; - - // When you import the customization points into the global namespace, - // they should be selected instead of the synchronous algorithms. - { - THRUST_SUPPRESS_DEPRECATED_PUSH - using namespace thrust::async; - f0a = transform(d0a.begin(), d0a.end(), d1a.begin(), op); - THRUST_SUPPRESS_DEPRECATED_POP - } - { - THRUST_SUPPRESS_DEPRECATED_PUSH - using thrust::async::transform; - f0b = transform(d0b.begin(), d0b.end(), d1b.begin(), op); - THRUST_SUPPRESS_DEPRECATED_POP - } - - // ADL should find the synchronous algorithms. - // This potentially runs concurrently with the copies. - transform(h0.begin(), h0.end(), h1.begin(), op); - - TEST_EVENT_WAIT(thrust::when_all(f0a, f0b)); - - ASSERT_EQ(h0, d0a); - ASSERT_EQ(h0, d0b); - - ASSERT_EQ(h1, d1a); - ASSERT_EQ(h1, d1b); - } -} - -TYPED_TEST(AsyncTransformTests, test_async_transform_using_divide_by_2) -{ - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - using T = typename TestFixture::input_type; - test_async_transform_using(); -} - -/////////////////////////////////////////////////////////////////////////////// - -#endif diff --git a/projects/rocthrust/test/test_dependencies_aware_policies.cpp b/projects/rocthrust/test/test_dependencies_aware_policies.cpp index 561e7ede6423..55d553f2eb94 100644 --- a/projects/rocthrust/test/test_dependencies_aware_policies.cpp +++ b/projects/rocthrust/test/test_dependencies_aware_policies.cpp @@ -17,9 +17,6 @@ #include -// need to suppress deprecation warnings for execute_with_allocator_and_dependencies inside type traits -THRUST_SUPPRESS_DEPRECATED_PUSH - #include #include #include @@ -139,5 +136,3 @@ TYPED_TEST(DependenciesAwarePoliciesTests, TestDependencyAttachmentInstance) TestDependencyAttachment test; test(); } - -THRUST_SUPPRESS_DEPRECATED_POP diff --git a/projects/rocthrust/test/test_dereference.cpp b/projects/rocthrust/test/test_dereference.cpp index c7874027cb83..f27863757f39 100644 --- a/projects/rocthrust/test/test_dereference.cpp +++ b/projects/rocthrust/test/test_dereference.cpp @@ -96,8 +96,8 @@ TEST(DereferenceTests, TestDeviceDereferenceTransformIterator) get_random_data(100, get_default_limits::min(), get_default_limits::max(), seed); thrust::device_vector output(input.size(), 0); - simple_copy(thrust::make_transform_iterator(input.begin(), ::internal::identity{}), - thrust::make_transform_iterator(input.end(), ::internal::identity{}), + simple_copy(thrust::make_transform_iterator(input.begin(), thrust::identity()), + thrust::make_transform_iterator(input.end(), thrust::identity()), output.begin()); ASSERT_EQ(input, output); @@ -111,8 +111,8 @@ TEST(DereferenceTests, TestDeviceDereferenceTransformIteratorInputConversion) thrust::device_vector input = unittest::random_integers(100); thrust::device_vector output(input.size(), 0); - simple_copy(thrust::make_transform_iterator(input.begin(), ::internal::identity{}), - thrust::make_transform_iterator(input.end(), ::internal::identity{}), + simple_copy(thrust::make_transform_iterator(input.begin(), thrust::identity()), + thrust::make_transform_iterator(input.end(), thrust::identity()), output.begin()); ASSERT_EQ(input == output, true); @@ -125,8 +125,8 @@ TEST(DereferenceTests, TestDeviceDereferenceTransformIteratorOutputConversion) thrust::device_vector input = unittest::random_integers(100); thrust::device_vector output(input.size(), 0); - simple_copy(thrust::make_transform_iterator(input.begin(), ::internal::identity{}), - thrust::make_transform_iterator(input.end(), ::internal::identity{}), + simple_copy(thrust::make_transform_iterator(input.begin(), thrust::identity()), + thrust::make_transform_iterator(input.end(), thrust::identity()), output.begin()); ASSERT_EQ(input == output, true); diff --git a/projects/rocthrust/test/test_event.cpp b/projects/rocthrust/test/test_event.cpp index 900ce72a4a2d..0fcec3eebcb3 100644 --- a/projects/rocthrust/test/test_event.cpp +++ b/projects/rocthrust/test/test_event.cpp @@ -27,10 +27,6 @@ TESTS_DEFINE(EventTests, FullTestsParams); -// note: there is no matching THRUST_SUPPRESS_DEPRECATED_POP, so the warning suppression leaks into more content of the -// generated cudafe1.stub.c file. -THRUST_SUPPRESS_DEPRECATED_PUSH - /////////////////////////////////////////////////////////////////////////////// TEST(EventTests, test_event_default_constructed) diff --git a/projects/rocthrust/test/test_find.cpp b/projects/rocthrust/test/test_find.cpp index 12bc4bc1ff1a..59a49a33de0d 100644 --- a/projects/rocthrust/test/test_find.cpp +++ b/projects/rocthrust/test/test_find.cpp @@ -15,10 +15,11 @@ * limitations under the License. */ -#include +#include #include +#include #include -#include +#include #include "test_param_fixtures.hpp" #include "test_utils.hpp" @@ -35,7 +36,7 @@ struct equal_to_value_pred : value(value) {} - THRUST_HOST_DEVICE bool operator()(T v) const + __host__ __device__ bool operator()(T v) const { return v == value; } @@ -50,7 +51,7 @@ struct not_equal_to_value_pred : value(value) {} - THRUST_HOST_DEVICE bool operator()(T v) const + __host__ __device__ bool operator()(T v) const { return v != value; } @@ -65,7 +66,7 @@ struct less_than_value_pred : value(value) {} - THRUST_HOST_DEVICE bool operator()(T v) const + __host__ __device__ bool operator()(T v) const { return v < value; } @@ -74,17 +75,24 @@ struct less_than_value_pred TYPED_TEST(FindTestsVector, TestFindSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; + using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector vec{1, 2, 3, 3, 5}; - - ASSERT_EQ(thrust::find(vec.begin(), vec.end(), 0) - vec.begin(), 5); - ASSERT_EQ(thrust::find(vec.begin(), vec.end(), 1) - vec.begin(), 0); - ASSERT_EQ(thrust::find(vec.begin(), vec.end(), 2) - vec.begin(), 1); - ASSERT_EQ(thrust::find(vec.begin(), vec.end(), 3) - vec.begin(), 2); - ASSERT_EQ(thrust::find(vec.begin(), vec.end(), 4) - vec.begin(), 5); - ASSERT_EQ(thrust::find(vec.begin(), vec.end(), 5) - vec.begin(), 4); + Vector vec(5); + vec[0] = T(1); + vec[1] = T(2); + vec[2] = T(3); + vec[3] = T(3); + vec[4] = T(5); + + ASSERT_EQ(thrust::find(Policy{}, vec.begin(), vec.end(), T(0)) - vec.begin(), 5); + ASSERT_EQ(thrust::find(Policy{}, vec.begin(), vec.end(), T(1)) - vec.begin(), 0); + ASSERT_EQ(thrust::find(Policy{}, vec.begin(), vec.end(), T(2)) - vec.begin(), 1); + ASSERT_EQ(thrust::find(Policy{}, vec.begin(), vec.end(), T(3)) - vec.begin(), 2); + ASSERT_EQ(thrust::find(Policy{}, vec.begin(), vec.end(), T(4)) - vec.begin(), 5); + ASSERT_EQ(thrust::find(Policy{}, vec.begin(), vec.end(), T(5)) - vec.begin(), 4); } template @@ -127,18 +135,24 @@ TEST(FindTests, TestFindDispatchImplicit) TYPED_TEST(FindTestsVector, TestFindIfSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector vec{1, 2, 3, 3, 5}; - - ASSERT_EQ(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(0)) - vec.begin(), 5); - ASSERT_EQ(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(1)) - vec.begin(), 0); - ASSERT_EQ(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(2)) - vec.begin(), 1); - ASSERT_EQ(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(3)) - vec.begin(), 2); - ASSERT_EQ(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(4)) - vec.begin(), 5); - ASSERT_EQ(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(5)) - vec.begin(), 4); + Vector vec(5); + vec[0] = T(1); + vec[1] = T(2); + vec[2] = T(3); + vec[3] = T(3); + vec[4] = T(5); + + ASSERT_EQ(thrust::find_if(Policy{}, vec.begin(), vec.end(), equal_to_value_pred(0)) - vec.begin(), 5); + ASSERT_EQ(thrust::find_if(Policy{}, vec.begin(), vec.end(), equal_to_value_pred(1)) - vec.begin(), 0); + ASSERT_EQ(thrust::find_if(Policy{}, vec.begin(), vec.end(), equal_to_value_pred(2)) - vec.begin(), 1); + ASSERT_EQ(thrust::find_if(Policy{}, vec.begin(), vec.end(), equal_to_value_pred(3)) - vec.begin(), 2); + ASSERT_EQ(thrust::find_if(Policy{}, vec.begin(), vec.end(), equal_to_value_pred(4)) - vec.begin(), 5); + ASSERT_EQ(thrust::find_if(Policy{}, vec.begin(), vec.end(), equal_to_value_pred(5)) - vec.begin(), 4); } template @@ -155,7 +169,7 @@ TEST(FindTests, TestFindIfDispatchExplicit) thrust::device_vector vec(1); my_system sys(0); - thrust::find_if(sys, vec.begin(), vec.end(), ::internal::identity{}); + thrust::find_if(sys, vec.begin(), vec.end(), thrust::identity()); ASSERT_EQ(true, sys.is_valid()); } @@ -173,7 +187,7 @@ TEST(FindTests, TestFindIfDispatchImplicit) thrust::device_vector vec(1); - thrust::find_if(thrust::retag(vec.begin()), thrust::retag(vec.end()), ::internal::identity{}); + thrust::find_if(thrust::retag(vec.begin()), thrust::retag(vec.end()), thrust::identity()); ASSERT_EQ(13, vec.front()); } @@ -181,18 +195,24 @@ TEST(FindTests, TestFindIfDispatchImplicit) TYPED_TEST(FindTestsVector, TestFindIfNotSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector vec{0, 1, 2, 3, 4}; - - ASSERT_EQ(0, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(0)) - vec.begin()); - ASSERT_EQ(1, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(1)) - vec.begin()); - ASSERT_EQ(2, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(2)) - vec.begin()); - ASSERT_EQ(3, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(3)) - vec.begin()); - ASSERT_EQ(4, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(4)) - vec.begin()); - ASSERT_EQ(5, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(5)) - vec.begin()); + Vector vec(5); + vec[0] = T(0); + vec[1] = T(1); + vec[2] = T(2); + vec[3] = T(3); + vec[4] = T(4); + + ASSERT_EQ(0, thrust::find_if_not(Policy{}, vec.begin(), vec.end(), less_than_value_pred(0)) - vec.begin()); + ASSERT_EQ(1, thrust::find_if_not(Policy{}, vec.begin(), vec.end(), less_than_value_pred(1)) - vec.begin()); + ASSERT_EQ(2, thrust::find_if_not(Policy{}, vec.begin(), vec.end(), less_than_value_pred(2)) - vec.begin()); + ASSERT_EQ(3, thrust::find_if_not(Policy{}, vec.begin(), vec.end(), less_than_value_pred(3)) - vec.begin()); + ASSERT_EQ(4, thrust::find_if_not(Policy{}, vec.begin(), vec.end(), less_than_value_pred(4)) - vec.begin()); + ASSERT_EQ(5, thrust::find_if_not(Policy{}, vec.begin(), vec.end(), less_than_value_pred(5)) - vec.begin()); } template @@ -209,7 +229,7 @@ TEST(FindTests, TestFindIfNotDispatchExplicit) thrust::device_vector vec(1); my_system sys(0); - thrust::find_if_not(sys, vec.begin(), vec.end(), ::internal::identity{}); + thrust::find_if_not(sys, vec.begin(), vec.end(), thrust::identity()); ASSERT_EQ(true, sys.is_valid()); } @@ -227,7 +247,7 @@ TEST(FindTests, TestFindIfNotDispatchImplicit) thrust::device_vector vec(1); - thrust::find_if_not(thrust::retag(vec.begin()), thrust::retag(vec.end()), ::internal::identity{}); + thrust::find_if_not(thrust::retag(vec.begin()), thrust::retag(vec.end()), thrust::identity()); ASSERT_EQ(13, vec.front()); } @@ -236,6 +256,9 @@ TYPED_TEST(FindTests, TestFind) { using T = typename TestFixture::input_type; + using HostIterator = typename thrust::host_vector::iterator; + using DeviceIterator = typename thrust::device_vector::iterator; + SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); for (auto size : get_sizes()) @@ -250,8 +273,8 @@ TYPED_TEST(FindTests, TestFind) get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); thrust::device_vector d_data = h_data; - typename thrust::host_vector::iterator h_iter; - typename thrust::device_vector::iterator d_iter; + HostIterator h_iter; + DeviceIterator d_iter; h_iter = thrust::find(h_data.begin(), h_data.end(), T(0)); d_iter = thrust::find(d_data.begin(), d_data.end(), T(0)); @@ -272,6 +295,9 @@ TYPED_TEST(FindTests, TestFindIf) { using T = typename TestFixture::input_type; + using HostIterator = typename thrust::host_vector::iterator; + using DeviceIterator = typename thrust::device_vector::iterator; + SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); for (auto size : get_sizes()) @@ -286,8 +312,8 @@ TYPED_TEST(FindTests, TestFindIf) get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); thrust::device_vector d_data = h_data; - typename thrust::host_vector::iterator h_iter; - typename thrust::device_vector::iterator d_iter; + HostIterator h_iter; + DeviceIterator d_iter; h_iter = thrust::find_if(h_data.begin(), h_data.end(), equal_to_value_pred(0)); d_iter = thrust::find_if(d_data.begin(), d_data.end(), equal_to_value_pred(0)); @@ -308,6 +334,9 @@ TYPED_TEST(FindTests, TestFindIfNot) { using T = typename TestFixture::input_type; + using HostIterator = typename thrust::host_vector::iterator; + using DeviceIterator = typename thrust::device_vector::iterator; + SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); for (auto size : get_sizes()) @@ -322,8 +351,8 @@ TYPED_TEST(FindTests, TestFindIfNot) get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); thrust::device_vector d_data = h_data; - typename thrust::host_vector::iterator h_iter; - typename thrust::device_vector::iterator d_iter; + HostIterator h_iter; + DeviceIterator d_iter; h_iter = thrust::find_if_not(h_data.begin(), h_data.end(), not_equal_to_value_pred(0)); d_iter = thrust::find_if_not(d_data.begin(), d_data.end(), not_equal_to_value_pred(0)); @@ -340,63 +369,6 @@ TYPED_TEST(FindTests, TestFindIfNot) } } -void TestFindWithBigIndexesHelper(int magnitude) -{ - thrust::counting_iterator begin(1); - thrust::counting_iterator end = begin + (1ll << magnitude); - ASSERT_EQ(thrust::distance(begin, end), 1ll << magnitude); - - thrust::detail::intmax_t distance_low_value = thrust::distance(begin, thrust::find(thrust::device, begin, end, 17)); - - thrust::detail::intmax_t distance_high_value = - thrust::distance(begin, thrust::find(thrust::device, begin, end, (1ll << magnitude) - 17)); - - ASSERT_EQ(distance_low_value, 16); - ASSERT_EQ(distance_high_value, (1ll << magnitude) - 18); -} - -TEST(FindTests, TestFindWithBigIndexes) -{ - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - - TestFindWithBigIndexesHelper(30); - TestFindWithBigIndexesHelper(31); - TestFindWithBigIndexesHelper(32); - TestFindWithBigIndexesHelper(33); -} - -namespace -{ - -class Weird -{ - int value; - -public: - THRUST_HOST_DEVICE Weird(int val, int) - : value(val) - {} - - friend THRUST_HOST_DEVICE bool operator==(int x, Weird y) - { - return x == y.value; - } -}; - -} // namespace - -TEST(FindTests, TestFindAsymmetricEquality) -{ // Regression test for NVIDIA/thrust#1229 - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - - thrust::host_vector v(1000); - thrust::sequence(v.begin(), v.end()); - thrust::device_vector dv(v); - auto result = thrust::find(dv.begin(), dv.end(), Weird(333, 0)); - ASSERT_EQ(*result, 333); - ASSERT_EQ(result - dv.begin(), 333); -} - __global__ THRUST_HIP_LAUNCH_BOUNDS_DEFAULT void FindKernel(int const N, int* in_array, int value, int* out_array) { if (threadIdx.x == 0) diff --git a/projects/rocthrust/test/test_functional.cpp b/projects/rocthrust/test/test_functional.cpp index 97c9ef50b482..8560f16389f0 100644 --- a/projects/rocthrust/test/test_functional.cpp +++ b/projects/rocthrust/test/test_functional.cpp @@ -215,8 +215,6 @@ typename _THRUST_STD::add_const<_Tp>::type& as_const(_Tp& __t) noexcept // Ad-hoc testing for other functionals TEST(AllTypesTests, TestIdentityFunctional) THRUST_DISABLE_BROKEN_GCC_VECTORIZER { - THRUST_SUPPRESS_DEPRECATED_PUSH - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); int i = 42; @@ -248,7 +246,6 @@ TEST(AllTypesTests, TestIdentityFunctional) THRUST_DISABLE_BROKEN_GCC_VECTORIZER static_assert(_THRUST_STD::is_same{}(_THRUST_STD::move(d))), int&&>::value, ""); static_assert(_THRUST_STD::is_same{}(static_cast(d))), int&&>::value, ""); - THRUST_SUPPRESS_DEPRECATED_POP } TYPED_TEST(VectorTests, TestIdentityFunctionalVector) THRUST_DISABLE_BROKEN_GCC_VECTORIZER @@ -256,9 +253,10 @@ TYPED_TEST(VectorTests, TestIdentityFunctionalVector) THRUST_DISABLE_BROKEN_GCC_ SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using Vector = typename TestFixture::input_type; + using T = typename Vector::value_type; Vector input{0, 1, 2, 3}; Vector output(4); - thrust::transform(input.begin(), input.end(), output.begin(), ::internal::identity{}); + thrust::transform(input.begin(), input.end(), output.begin(), thrust::identity()); ASSERT_EQ(input, output); } @@ -337,12 +335,13 @@ TYPED_TEST(IntegralVectorTests, TestNot1) THRUST_DISABLE_BROKEN_GCC_VECTORIZER SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); using Vector = typename TestFixture::input_type; + using T = typename Vector::value_type; Vector input{1, 0, 1, 1, 0}; Vector output(5); - thrust::transform(input.begin(), input.end(), output.begin(), thrust::not_fn(::internal::identity{})); + thrust::transform(input.begin(), input.end(), output.begin(), thrust::not_fn(thrust::identity())); Vector ref{0, 1, 0, 0, 1}; ASSERT_EQ(output, ref); diff --git a/projects/rocthrust/test/test_future.cpp b/projects/rocthrust/test/test_future.cpp index 702cdb04c254..35ddf37c8c24 100644 --- a/projects/rocthrust/test/test_future.cpp +++ b/projects/rocthrust/test/test_future.cpp @@ -25,10 +25,6 @@ # include "test_real_assertions.hpp" # include "test_utils.hpp" -// note: there is no matching THRUST_SUPPRESS_DEPRECATED_POP, so the warning suppression leaks into more content of the -// generated cudafe1.stub.c file. -THRUST_SUPPRESS_DEPRECATED_PUSH - struct mock {}; diff --git a/projects/rocthrust/test/test_is_partitioned.cpp b/projects/rocthrust/test/test_is_partitioned.cpp index 730447bb8515..59ac3006599e 100644 --- a/projects/rocthrust/test/test_is_partitioned.cpp +++ b/projects/rocthrust/test/test_is_partitioned.cpp @@ -30,7 +30,7 @@ TESTS_DEFINE(IsPartitionedVectorTests, VectorSignedIntegerTestsParams); template struct is_even { - THRUST_HOST_DEVICE bool operator()(T x) const + __host__ __device__ bool operator()(T x) const { return ((int) x % 2) == 0; } @@ -39,30 +39,38 @@ struct is_even TYPED_TEST(IsPartitionedVectorTests, TestIsPartitionedSimple) { using Vector = typename TestFixture::input_type; + using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector v{1, 1, 1, 0}; + Vector v(4); + v[0] = 1; + v[1] = 1; + v[2] = 1; + v[3] = 0; // empty partition - ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.begin(), ::internal::identity{})); + ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.begin(), thrust::identity())); // one element true partition - ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 1, ::internal::identity{})); + ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 1, thrust::identity())); // just true partition - ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 2, ::internal::identity{})); + ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 2, thrust::identity())); // both true & false partitions - ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.end(), ::internal::identity{})); + ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin(), v.end(), thrust::identity())); // one element false partition - ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin() + 3, v.end(), ::internal::identity{})); + ASSERT_EQ_QUIET(true, thrust::is_partitioned(v.begin() + 3, v.end(), thrust::identity())); - v = {1, 0, 1, 1}; + v[0] = 1; + v[1] = 0; + v[2] = 1; + v[3] = 1; // not partitioned - ASSERT_EQ_QUIET(false, thrust::is_partitioned(v.begin(), v.end(), ::internal::identity{})); + ASSERT_EQ_QUIET(false, thrust::is_partitioned(v.begin(), v.end(), thrust::identity())); } TYPED_TEST(IsPartitionedVectorTests, TestIsPartitioned) @@ -92,7 +100,7 @@ TYPED_TEST(IsPartitionedVectorTests, TestIsPartitioned) } template -bool is_partitioned(my_system& system, InputIterator /*first*/, InputIterator, Predicate) +__host__ __device__ bool is_partitioned(my_system& system, InputIterator, InputIterator, Predicate) { system.validate_dispatch(); return false; @@ -111,7 +119,7 @@ TEST(IsPartitionedTests, TestIsPartitionedDispatchExplicit) } template -bool is_partitioned(my_tag, InputIterator first, InputIterator, Predicate) +__host__ __device__ bool is_partitioned(my_tag, InputIterator first, InputIterator, Predicate) { *first = 13; return false; diff --git a/projects/rocthrust/test/test_logical.cpp b/projects/rocthrust/test/test_logical.cpp index f4d2d8874fc1..f578947d025b 100644 --- a/projects/rocthrust/test/test_logical.cpp +++ b/projects/rocthrust/test/test_logical.cpp @@ -34,16 +34,16 @@ TYPED_TEST(LogicalTests, TestAllOf) Vector v(3, T{1}); - ASSERT_EQ(thrust::all_of(v.begin(), v.end(), ::internal::identity{}), true); + ASSERT_EQ(thrust::all_of(v.begin(), v.end(), thrust::identity()), true); v[1] = T{0}; - ASSERT_EQ(thrust::all_of(v.begin(), v.end(), ::internal::identity{}), false); + ASSERT_EQ(thrust::all_of(v.begin(), v.end(), thrust::identity()), false); - ASSERT_EQ(thrust::all_of(v.begin() + 0, v.begin() + 0, ::internal::identity{}), true); - ASSERT_EQ(thrust::all_of(v.begin() + 0, v.begin() + 1, ::internal::identity{}), true); - ASSERT_EQ(thrust::all_of(v.begin() + 0, v.begin() + 2, ::internal::identity{}), false); - ASSERT_EQ(thrust::all_of(v.begin() + 1, v.begin() + 2, ::internal::identity{}), false); + ASSERT_EQ(thrust::all_of(v.begin() + 0, v.begin() + 0, thrust::identity()), true); + ASSERT_EQ(thrust::all_of(v.begin() + 0, v.begin() + 1, thrust::identity()), true); + ASSERT_EQ(thrust::all_of(v.begin() + 0, v.begin() + 2, thrust::identity()), false); + ASSERT_EQ(thrust::all_of(v.begin() + 1, v.begin() + 2, thrust::identity()), false); } template @@ -92,16 +92,16 @@ TYPED_TEST(LogicalTests, TestAnyOf) Vector v(3, T{1}); - ASSERT_EQ(thrust::any_of(v.begin(), v.end(), ::internal::identity{}), true); + ASSERT_EQ(thrust::any_of(v.begin(), v.end(), thrust::identity()), true); v[1] = 0; - ASSERT_EQ(thrust::any_of(v.begin(), v.end(), ::internal::identity{}), true); + ASSERT_EQ(thrust::any_of(v.begin(), v.end(), thrust::identity()), true); - ASSERT_EQ(thrust::any_of(v.begin() + 0, v.begin() + 0, ::internal::identity{}), false); - ASSERT_EQ(thrust::any_of(v.begin() + 0, v.begin() + 1, ::internal::identity{}), true); - ASSERT_EQ(thrust::any_of(v.begin() + 0, v.begin() + 2, ::internal::identity{}), true); - ASSERT_EQ(thrust::any_of(v.begin() + 1, v.begin() + 2, ::internal::identity{}), false); + ASSERT_EQ(thrust::any_of(v.begin() + 0, v.begin() + 0, thrust::identity()), false); + ASSERT_EQ(thrust::any_of(v.begin() + 0, v.begin() + 1, thrust::identity()), true); + ASSERT_EQ(thrust::any_of(v.begin() + 0, v.begin() + 2, thrust::identity()), true); + ASSERT_EQ(thrust::any_of(v.begin() + 1, v.begin() + 2, thrust::identity()), false); } template @@ -150,16 +150,16 @@ TYPED_TEST(LogicalTests, TestNoneOf) Vector v(3, T{1}); - ASSERT_EQ(thrust::none_of(v.begin(), v.end(), ::internal::identity{}), false); + ASSERT_EQ(thrust::none_of(v.begin(), v.end(), thrust::identity()), false); v[1] = 0; - ASSERT_EQ(thrust::none_of(v.begin(), v.end(), ::internal::identity{}), false); + ASSERT_EQ(thrust::none_of(v.begin(), v.end(), thrust::identity()), false); - ASSERT_EQ(thrust::none_of(v.begin() + 0, v.begin() + 0, ::internal::identity{}), true); - ASSERT_EQ(thrust::none_of(v.begin() + 0, v.begin() + 1, ::internal::identity{}), false); - ASSERT_EQ(thrust::none_of(v.begin() + 0, v.begin() + 2, ::internal::identity{}), false); - ASSERT_EQ(thrust::none_of(v.begin() + 1, v.begin() + 2, ::internal::identity{}), true); + ASSERT_EQ(thrust::none_of(v.begin() + 0, v.begin() + 0, thrust::identity()), true); + ASSERT_EQ(thrust::none_of(v.begin() + 0, v.begin() + 1, thrust::identity()), false); + ASSERT_EQ(thrust::none_of(v.begin() + 0, v.begin() + 2, thrust::identity()), false); + ASSERT_EQ(thrust::none_of(v.begin() + 1, v.begin() + 2, thrust::identity()), true); } template diff --git a/projects/rocthrust/test/test_optional.cpp b/projects/rocthrust/test/test_optional.cpp new file mode 100644 index 000000000000..cd00b3a9d304 --- /dev/null +++ b/projects/rocthrust/test/test_optional.cpp @@ -0,0 +1,69 @@ +/* + * Copyright© 2024-2025 Advanced Micro Devices, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include "test_param_fixtures.hpp" +#include "test_utils.hpp" + +TEST(OptionalTests, IsTriviallyCopyable) +{ + static_assert(std::is_trivially_copyable::value == true, + "type is not trivially copyable even though it should be!"); + static_assert(std::is_trivially_copyable>::value == true, + "type is not trivially copyable even though it should be!"); +} + +TEST(OptionalTests, EmplaceReference) +{ + // See https://github.com/ROCm/rocThrust/issues/404 + { + int a = 10; + + thrust::optional maybe(a); + + int b = 20; + maybe.emplace(b); + + ASSERT_EQ(maybe.value(), 20); + // Emplacing with b shouldn't change a + ASSERT_EQ(a, 10); + + int c = 30; + maybe.emplace(c); + + ASSERT_EQ(maybe.value(), 30); + ASSERT_EQ(b, 20); + } + + { + thrust::optional maybe; + + int b = 21; + maybe.emplace(b); + + ASSERT_EQ(maybe.value(), 21); + + int c = 31; + maybe.emplace(c); + + ASSERT_EQ(maybe.value(), 31); + ASSERT_EQ(b, 21); + } +} diff --git a/projects/rocthrust/test/test_partition.cpp b/projects/rocthrust/test/test_partition.cpp index 9440b5826ab3..7bbdca0b5826 100644 --- a/projects/rocthrust/test/test_partition.cpp +++ b/projects/rocthrust/test/test_partition.cpp @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -166,6 +165,7 @@ TYPED_TEST(PartitionVectorTests, TestStablePartitionSimple) TYPED_TEST(PartitionVectorTests, TestStablePartitionStencilSimple) { using Vector = typename TestFixture::input_type; + using T = typename Vector::value_type; using Iterator = typename Vector::iterator; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); @@ -174,7 +174,7 @@ TYPED_TEST(PartitionVectorTests, TestStablePartitionStencilSimple) Vector stencil{0, 1, 0, 0, 1}; - Iterator iter = thrust::stable_partition(data.begin(), data.end(), stencil.begin(), ::internal::identity{}); + Iterator iter = thrust::stable_partition(data.begin(), data.end(), stencil.begin(), thrust::identity()); Vector ref{2, 2, 1, 1, 3}; @@ -210,17 +210,19 @@ TYPED_TEST(PartitionVectorTests, TestStablePartitionCopySimple) TYPED_TEST(PartitionVectorTests, TestStablePartitionCopyStencilSimple) { using Vector = typename TestFixture::input_type; + using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector data{1, 2, 1, 1, 2}; + Vector stencil{false, true, false, false, true}; Vector true_results(2); Vector false_results(3); thrust::pair ends = thrust::stable_partition_copy( - data.begin(), data.end(), stencil.begin(), true_results.begin(), false_results.begin(), ::internal::identity{}); + data.begin(), data.end(), stencil.begin(), true_results.begin(), false_results.begin(), thrust::identity()); Vector true_ref(2, 2); diff --git a/projects/rocthrust/test/test_partition_point.cpp b/projects/rocthrust/test/test_partition_point.cpp index ac2f38ae8115..ff92c4194650 100644 --- a/projects/rocthrust/test/test_partition_point.cpp +++ b/projects/rocthrust/test/test_partition_point.cpp @@ -28,7 +28,7 @@ TESTS_DEFINE(PartitionPointVectorTests, VectorSignedIntegerTestsParams); template struct is_even { - THRUST_HOST_DEVICE bool operator()(T x) const + __host__ __device__ bool operator()(T x) const { return ((int) x % 2) == 0; } @@ -37,21 +37,26 @@ struct is_even TYPED_TEST(PartitionPointVectorTests, TestPartitionPointSimple) { using Vector = typename TestFixture::input_type; + using T = typename Vector::value_type; using Iterator = typename Vector::iterator; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector v{1, 1, 1, 0}; + Vector v(4); + v[0] = 1; + v[1] = 1; + v[2] = 1; + v[3] = 0; Iterator first = v.begin(); Iterator last = v.begin() + 4; Iterator ref = first + 3; - ASSERT_EQ_QUIET(ref, thrust::partition_point(first, last, ::internal::identity{})); + ASSERT_EQ_QUIET(ref, thrust::partition_point(first, last, thrust::identity())); last = v.begin() + 3; ref = last; - ASSERT_EQ_QUIET(ref, thrust::partition_point(first, last, ::internal::identity{})); + ASSERT_EQ_QUIET(ref, thrust::partition_point(first, last, thrust::identity())); } TYPED_TEST(PartitionPointVectorTests, TestPartitionPoint) @@ -77,7 +82,7 @@ TYPED_TEST(PartitionPointVectorTests, TestPartitionPoint) } template -ForwardIterator partition_point(my_system& system, ForwardIterator first, ForwardIterator, Predicate) +__host__ __device__ ForwardIterator partition_point(my_system& system, ForwardIterator first, ForwardIterator, Predicate) { system.validate_dispatch(); return first; @@ -96,7 +101,7 @@ TEST(PartitionPointTests, TestPartitionPointDispatchExplicit) } template -ForwardIterator partition_point(my_tag, ForwardIterator first, ForwardIterator, Predicate) +__host__ __device__ ForwardIterator partition_point(my_tag, ForwardIterator first, ForwardIterator, Predicate) { *first = 13; return first; @@ -112,34 +117,3 @@ TEST(PartitionPointTests, TestPartitionPointDispatchImplicit) ASSERT_EQ(13, vec.front()); } - -struct test_less_than -{ - long long expected; - - THRUST_DEVICE bool operator()(long long y) - { - return y < expected; - } -}; - -void TestPartitionPointWithBigIndexesHelper(int magnitude) -{ - thrust::counting_iterator begin(0); - thrust::counting_iterator end = begin + (1ll << magnitude); - ASSERT_EQ(thrust::distance(begin, end), 1ll << magnitude); - - test_less_than fn = {(1ll << magnitude) - 17}; - - ASSERT_EQ(thrust::distance(begin, thrust::partition_point(thrust::device, begin, end, fn)), (1ll << magnitude) - 17); -} - -TEST(PartitionPointTests, TestPartitionPointWithBigIndexes) -{ - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - - TestPartitionPointWithBigIndexesHelper(30); - TestPartitionPointWithBigIndexesHelper(31); - TestPartitionPointWithBigIndexesHelper(32); - TestPartitionPointWithBigIndexesHelper(33); -} diff --git a/projects/rocthrust/test/test_permutation_iterator.cpp b/projects/rocthrust/test/test_permutation_iterator.cpp index 4ee229c5691c..26454cf001b5 100644 --- a/projects/rocthrust/test/test_permutation_iterator.cpp +++ b/projects/rocthrust/test/test_permutation_iterator.cpp @@ -15,31 +15,16 @@ * limitations under the License. */ -#include #include #include #include #include #include -#include #include "test_param_fixtures.hpp" #include "test_utils.hpp" -#include _THRUST_STD_INCLUDE(type_traits) - -using IntegralVectorTestsParams = - ::testing::Types>, - Params>, - Params>, - Params>, - Params>, - Params>, - Params>, - Params>>; - TESTS_DEFINE(PermutationIteratorTests, FullTestsParams); -TESTS_DEFINE(PermutationIteratorIntegralVectorTests, IntegralVectorTestsParams); TEST(PermutationIteratorTests, UsingHip) { @@ -48,7 +33,7 @@ TEST(PermutationIteratorTests, UsingHip) ASSERT_EQ(THRUST_DEVICE_SYSTEM, THRUST_DEVICE_SYSTEM_HIP); } -TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorSimple) +TYPED_TEST(PermutationIteratorTests, PermutationIteratorSimple) { using Vector = typename TestFixture::input_type; using T = typename Vector::value_type; @@ -57,11 +42,16 @@ TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorSimple) SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + thrust::permutation_iterator begin(source.begin(), indices.begin()); thrust::permutation_iterator end(source.begin(), indices.end()); @@ -82,13 +72,17 @@ TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorSimple) *begin = 10; *end = 20; - Vector ref{10, 2, 3, 4, 5, 20, 7, 8}; - ASSERT_EQ(source, ref); + ASSERT_EQ(source[0], 10); + ASSERT_EQ(source[1], 2); + ASSERT_EQ(source[2], 3); + ASSERT_EQ(source[3], 4); + ASSERT_EQ(source[4], 5); + ASSERT_EQ(source[5], 20); + ASSERT_EQ(source[6], 7); + ASSERT_EQ(source[7], 8); } -static_assert(_THRUST_STD::is_trivially_copy_constructible>::value, ""); -static_assert(_THRUST_STD::is_trivially_copyable>::value, ""); -TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorGather) +TYPED_TEST(PermutationIteratorTests, PermutationIteratorGather) { using Vector = typename TestFixture::input_type; using Iterator = typename Vector::iterator; @@ -96,21 +90,28 @@ TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorGather) SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(4, 10); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + thrust::permutation_iterator p_source(source.begin(), indices.begin()); thrust::copy(p_source, p_source + 4, output.begin()); - Vector ref{4, 1, 6, 8}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], 4); + ASSERT_EQ(output[1], 1); + ASSERT_EQ(output[2], 6); + ASSERT_EQ(output[3], 8); } -TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorScatter) +TYPED_TEST(PermutationIteratorTests, PermutationIteratorScatter) { using Vector = typename TestFixture::input_type; using Iterator = typename Vector::iterator; @@ -118,43 +119,61 @@ TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorScatter) SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector source(4, 10); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(8); // initialize output thrust::sequence(output.begin(), output.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + // construct transform_iterator thrust::permutation_iterator p_output(output.begin(), indices.begin()); thrust::copy(source.begin(), source.end(), p_output); - Vector ref{10, 2, 3, 10, 5, 10, 7, 10}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], 10); + ASSERT_EQ(output[1], 2); + ASSERT_EQ(output[2], 3); + ASSERT_EQ(output[3], 10); + ASSERT_EQ(output[4], 5); + ASSERT_EQ(output[5], 10); + ASSERT_EQ(output[6], 7); + ASSERT_EQ(output[7], 10); } -TYPED_TEST(PermutationIteratorTests, TestMakePermutationIterator) +TYPED_TEST(PermutationIteratorTests, MakePermutationIterator) { using Vector = typename TestFixture::input_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(4, 10); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + thrust::copy(thrust::make_permutation_iterator(source.begin(), indices.begin()), thrust::make_permutation_iterator(source.begin(), indices.begin()) + 4, output.begin()); - Vector ref{4, 1, 6, 8}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], 4); + ASSERT_EQ(output[1], 1); + ASSERT_EQ(output[2], 6); + ASSERT_EQ(output[3], 8); } -TYPED_TEST(PermutationIteratorIntegralVectorTests, TestPermutationIteratorReduce) +TYPED_TEST(PermutationIteratorTests, PermutationIteratorReduce) { using Vector = typename TestFixture::input_type; using T = typename Vector::value_type; @@ -163,19 +182,24 @@ TYPED_TEST(PermutationIteratorIntegralVectorTests, TestPermutationIteratorReduce SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(4, 10); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + // construct transform_iterator thrust::permutation_iterator iter(source.begin(), indices.begin()); T result1 = thrust::reduce(thrust::make_permutation_iterator(source.begin(), indices.begin()), thrust::make_permutation_iterator(source.begin(), indices.begin()) + 4); - ASSERT_EQ(result1, 19); + ASSERT_EQ(result1, (T) 19); T result2 = thrust::transform_reduce( thrust::make_permutation_iterator(source.begin(), indices.begin()), @@ -183,106 +207,132 @@ TYPED_TEST(PermutationIteratorIntegralVectorTests, TestPermutationIteratorReduce thrust::negate(), T(0), thrust::plus()); - ASSERT_EQ(result2, -19); + ASSERT_EQ(result2, (T) -19); }; -TEST(PermutationIteratorTests, TestPermutationIteratorHostDeviceGather) +TEST(PermutationIteratorTests, PermutationIteratorHostDeviceGather) { using T = int; - using HostVector = thrust::host_vector; - using DeviceVector = thrust::host_vector; - using HostIterator = HostVector::iterator; - using DeviceIterator = DeviceVector::iterator; + using HostVector = typename thrust::host_vector; + using DeviceVector = typename thrust::host_vector; + using HostIterator = typename HostVector::iterator; + using DeviceIterator = typename DeviceVector::iterator; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); HostVector h_source(8); - HostVector h_indices{3, 0, 5, 7}; + HostVector h_indices(4); HostVector h_output(4, 10); DeviceVector d_source(8); - DeviceVector d_indices(h_indices); + DeviceVector d_indices(4); DeviceVector d_output(4, 10); // initialize source thrust::sequence(h_source.begin(), h_source.end(), 1); thrust::sequence(d_source.begin(), d_source.end(), 1); + h_indices[0] = d_indices[0] = 3; + h_indices[1] = d_indices[1] = 0; + h_indices[2] = d_indices[2] = 5; + h_indices[3] = d_indices[3] = 7; + thrust::permutation_iterator p_h_source(h_source.begin(), h_indices.begin()); thrust::permutation_iterator p_d_source(d_source.begin(), d_indices.begin()); // gather host->device thrust::copy(p_h_source, p_h_source + 4, d_output.begin()); - DeviceVector dref{4, 1, 6, 8}; - ASSERT_EQ(d_output, dref); + ASSERT_EQ(d_output[0], 4); + ASSERT_EQ(d_output[1], 1); + ASSERT_EQ(d_output[2], 6); + ASSERT_EQ(d_output[3], 8); // gather device->host thrust::copy(p_d_source, p_d_source + 4, h_output.begin()); - HostVector href{4, 1, 6, 8}; - ASSERT_EQ(h_output, href); + ASSERT_EQ(h_output[0], 4); + ASSERT_EQ(h_output[1], 1); + ASSERT_EQ(h_output[2], 6); + ASSERT_EQ(h_output[3], 8); } -TEST(PermutationIteratorTests, TestPermutationIteratorHostDeviceScatter) +TEST(PermutationIteratorTests, PermutationIteratorHostDeviceScatter) { using T = int; - using HostVector = thrust::host_vector; - using DeviceVector = thrust::host_vector; - using HostIterator = HostVector::iterator; - using DeviceIterator = DeviceVector::iterator; + using HostVector = typename thrust::host_vector; + using DeviceVector = typename thrust::host_vector; + using HostIterator = typename HostVector::iterator; + using DeviceIterator = typename DeviceVector::iterator; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); HostVector h_source(4, 10); - HostVector h_indices{3, 0, 5, 7}; + HostVector h_indices(4); HostVector h_output(8); DeviceVector d_source(4, 10); - DeviceVector d_indices(h_indices); + DeviceVector d_indices(4); DeviceVector d_output(8); // initialize source thrust::sequence(h_output.begin(), h_output.end(), 1); thrust::sequence(d_output.begin(), d_output.end(), 1); + h_indices[0] = d_indices[0] = 3; + h_indices[1] = d_indices[1] = 0; + h_indices[2] = d_indices[2] = 5; + h_indices[3] = d_indices[3] = 7; + thrust::permutation_iterator p_h_output(h_output.begin(), h_indices.begin()); thrust::permutation_iterator p_d_output(d_output.begin(), d_indices.begin()); // scatter host->device thrust::copy(h_source.begin(), h_source.end(), p_d_output); - DeviceVector dref{10, 2, 3, 10, 5, 10, 7, 10}; - ASSERT_EQ(d_output, dref); + ASSERT_EQ(d_output[0], 10); + ASSERT_EQ(d_output[1], 2); + ASSERT_EQ(d_output[2], 3); + ASSERT_EQ(d_output[3], 10); + ASSERT_EQ(d_output[4], 5); + ASSERT_EQ(d_output[5], 10); + ASSERT_EQ(d_output[6], 7); + ASSERT_EQ(d_output[7], 10); // scatter device->host thrust::copy(d_source.begin(), d_source.end(), p_h_output); - HostVector href(dref); - ASSERT_EQ(h_output, href); + ASSERT_EQ(h_output[0], 10); + ASSERT_EQ(h_output[1], 2); + ASSERT_EQ(h_output[2], 3); + ASSERT_EQ(h_output[3], 10); + ASSERT_EQ(h_output[4], 5); + ASSERT_EQ(h_output[5], 10); + ASSERT_EQ(h_output[6], 7); + ASSERT_EQ(h_output[7], 10); } -TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorWithCountingIterator) +TYPED_TEST(PermutationIteratorTests, PermutationIteratorWithCountingIterator) { using Vector = typename TestFixture::input_type; using T = typename Vector::value_type; - using diff_t = typename thrust::counting_iterator::difference_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - thrust::counting_iterator input(0), index(0); + typename thrust::counting_iterator input(0), index(0); // test copy() { Vector output(4, 0); - auto first = thrust::make_permutation_iterator(input, index); - auto last = thrust::make_permutation_iterator(input, index + static_cast(output.size())); - - thrust::copy(first, last, output.begin()); + thrust::copy(thrust::make_permutation_iterator(input, index), + thrust::make_permutation_iterator(input, index + output.size()), + output.begin()); - Vector ref{0, 1, 2, 3}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], 0); + ASSERT_EQ(output[1], 1); + ASSERT_EQ(output[2], 2); + ASSERT_EQ(output[3], 3); } // test copy() @@ -292,9 +342,11 @@ TYPED_TEST(PermutationIteratorTests, TestPermutationIteratorWithCountingIterator thrust::transform(thrust::make_permutation_iterator(input, index), thrust::make_permutation_iterator(input, index + 4), output.begin(), - ::internal::identity{}); + thrust::identity()); - Vector ref{0, 1, 2, 3}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], 0); + ASSERT_EQ(output[1], 1); + ASSERT_EQ(output[2], 2); + ASSERT_EQ(output[3], 3); } } diff --git a/projects/rocthrust/test/test_remove.cpp b/projects/rocthrust/test/test_remove.cpp index c8e86c51b52f..45029660f47b 100644 --- a/projects/rocthrust/test/test_remove.cpp +++ b/projects/rocthrust/test/test_remove.cpp @@ -22,8 +22,6 @@ #include #include -#include - #include "test_param_fixtures.hpp" #include "test_real_assertions.hpp" #include "test_utils.hpp" @@ -35,7 +33,7 @@ TESTS_DEFINE(RemoveVariableTests, NumericalTestsParams); template struct is_even { - THRUST_HOST_DEVICE bool operator()(T x) + __host__ __device__ bool operator()(T x) { return (static_cast(x) & 1) == 0; } @@ -44,7 +42,7 @@ struct is_even template struct is_true { - THRUST_HOST_DEVICE bool operator()(T x) + __host__ __device__ bool operator()(T x) { return x ? true : false; } @@ -53,19 +51,25 @@ struct is_true TYPED_TEST(RemoveTests, TestRemoveSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = T(1); + data[1] = T(2); + data[2] = T(1); + data[3] = T(3); + data[4] = T(2); - typename Vector::iterator end = thrust::remove(data.begin(), data.end(), (T) 2); + typename Vector::iterator end = thrust::remove(Policy{}, data.begin(), data.end(), (T) 2); ASSERT_EQ(end - data.begin(), 3); - data.resize(end - data.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQ(data, ref); + ASSERT_EQ(data[0], T(1)); + ASSERT_EQ(data[1], T(1)); + ASSERT_EQ(data[2], T(3)); } template @@ -107,21 +111,27 @@ TEST(RemoveTests, TestRemoveDispatchImplicit) TYPED_TEST(RemoveTests, TestRemoveCopySimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = T(1); + data[1] = T(2); + data[2] = T(1); + data[3] = T(3); + data[4] = T(2); Vector result(5); - typename Vector::iterator end = thrust::remove_copy(data.begin(), data.end(), result.begin(), (T) 2); + typename Vector::iterator end = thrust::remove_copy(Policy{}, data.begin(), data.end(), result.begin(), T(2)); ASSERT_EQ(end - result.begin(), 3); - result.resize(end - result.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQ(result, ref); + ASSERT_EQ(result[0], T(1)); + ASSERT_EQ(result[1], T(1)); + ASSERT_EQ(result[2], T(3)); } template @@ -165,23 +175,29 @@ TEST(RemoveTests, TestRemoveCopyDispatchImplicit) TYPED_TEST(RemoveTests, TestRemoveIfSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; - typename Vector::iterator end = thrust::remove_if(data.begin(), data.end(), is_even()); + typename Vector::iterator end = thrust::remove_if(Policy{}, data.begin(), data.end(), is_even()); ASSERT_EQ(end - data.begin(), 3); - data.resize(end - data.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQ(data, ref); + ASSERT_EQ(data[0], 1); + ASSERT_EQ(data[1], 1); + ASSERT_EQ(data[2], 3); } template -ForwardIterator remove_if(my_system& system, ForwardIterator first, ForwardIterator, Predicate) +__host__ __device__ ForwardIterator remove_if(my_system& system, ForwardIterator first, ForwardIterator, Predicate) { system.validate_dispatch(); return first; @@ -200,7 +216,7 @@ TEST(RemoveTests, TestRemoveIfDispatchExplicit) } template -ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, Predicate) +__host__ __device__ ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, Predicate) { *first = 13; return first; @@ -220,23 +236,38 @@ TEST(RemoveTests, TestRemoveIfDispatchImplicit) TYPED_TEST(RemoveTests, TestRemoveIfStencilSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; + using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector data{1, 2, 1, 3, 2}; - Vector stencil{0, 1, 0, 0, 1}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; + + Vector stencil(5); + stencil[0] = 0; + stencil[1] = 1; + stencil[2] = 0; + stencil[3] = 0; + stencil[4] = 1; - typename Vector::iterator end = thrust::remove_if(data.begin(), data.end(), stencil.begin(), ::internal::identity{}); + typename Vector::iterator end = + thrust::remove_if(Policy{}, data.begin(), data.end(), stencil.begin(), thrust::identity()); ASSERT_EQ(end - data.begin(), 3); - data.resize(end - data.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQ(data, ref); + ASSERT_EQ(data[0], 1); + ASSERT_EQ(data[1], 1); + ASSERT_EQ(data[2], 3); } template -ForwardIterator remove_if(my_system& system, ForwardIterator first, ForwardIterator, InputIterator, Predicate) +__host__ __device__ ForwardIterator +remove_if(my_system& system, ForwardIterator first, ForwardIterator, InputIterator, Predicate) { system.validate_dispatch(); return first; @@ -255,7 +286,7 @@ TEST(RemoveTests, TestRemoveIfStencilDispatchExplicit) } template -ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, InputIterator, Predicate) +__host__ __device__ ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, InputIterator, Predicate) { *first = 13; return first; @@ -276,25 +307,33 @@ TEST(RemoveTests, TestRemoveIfStencilDispatchImplicit) TYPED_TEST(RemoveTests, TestRemoveCopyIfSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; Vector result(5); - typename Vector::iterator end = thrust::remove_copy_if(data.begin(), data.end(), result.begin(), is_even()); + typename Vector::iterator end = + thrust::remove_copy_if(Policy{}, data.begin(), data.end(), result.begin(), is_even()); ASSERT_EQ(end - result.begin(), 3); - result.resize(end - result.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQ(result, ref); + ASSERT_EQ(result[0], 1); + ASSERT_EQ(result[1], 1); + ASSERT_EQ(result[2], 3); } template -InputIterator remove_copy_if(my_system& system, InputIterator first, InputIterator, OutputIterator, Predicate) +__host__ __device__ InputIterator +remove_copy_if(my_system& system, InputIterator first, InputIterator, OutputIterator, Predicate) { system.validate_dispatch(); return first; @@ -313,7 +352,7 @@ TEST(RemoveTests, TestRemoveCopyIfDispatchExplicit) } template -InputIterator remove_copy_if(my_tag, InputIterator first, InputIterator, OutputIterator, Predicate) +__host__ __device__ InputIterator remove_copy_if(my_tag, InputIterator first, InputIterator, OutputIterator, Predicate) { *first = 13; return first; @@ -334,26 +373,39 @@ TEST(RemoveTests, TestRemoveCopyIfDispatchImplicit) TYPED_TEST(RemoveTests, TestRemoveCopyIfStencilSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; + using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - Vector data{1, 2, 1, 3, 2}; - Vector stencil{0, 1, 0, 0, 1}; + Vector data(5); + data[0] = T(1); + data[1] = T(2); + data[2] = T(1); + data[3] = T(3); + data[4] = T(2); + + Vector stencil(5); + stencil[0] = T(0); + stencil[1] = T(1); + stencil[2] = T(0); + stencil[3] = T(0); + stencil[4] = T(1); Vector result(5); typename Vector::iterator end = - thrust::remove_copy_if(data.begin(), data.end(), stencil.begin(), result.begin(), ::internal::identity{}); + thrust::remove_copy_if(Policy{}, data.begin(), data.end(), stencil.begin(), result.begin(), thrust::identity()); ASSERT_EQ(end - result.begin(), 3); - result.resize(end - result.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQ(result, ref); + ASSERT_EQ(result[0], T(1)); + ASSERT_EQ(result[1], T(1)); + ASSERT_EQ(result[2], T(3)); } template -OutputIterator +__host__ __device__ OutputIterator remove_copy_if(my_system& system, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, Predicate) { system.validate_dispatch(); @@ -373,7 +425,8 @@ TEST(RemoveTests, TestRemoveCopyIfStencilDispatchExplicit) } template -OutputIterator remove_copy_if(my_tag, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, Predicate) +__host__ __device__ OutputIterator +remove_copy_if(my_tag, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, Predicate) { *result = 13; return result; @@ -411,6 +464,7 @@ TYPED_TEST(RemoveVariableTests, TestRemove) thrust::host_vector h_data = get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); + thrust::device_vector d_data = h_data; size_t h_size = thrust::remove(h_data.begin(), h_data.end(), T(0)) - h_data.begin(); @@ -442,6 +496,7 @@ TYPED_TEST(RemoveVariableTests, TestRemoveIf) thrust::host_vector h_data = get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); + thrust::device_vector d_data = h_data; size_t h_size = thrust::remove_if(h_data.begin(), h_data.end(), is_true()) - h_data.begin(); @@ -473,11 +528,12 @@ TYPED_TEST(RemoveVariableTests, TestRemoveIfStencil) thrust::host_vector h_data = get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); + thrust::device_vector d_data = h_data; thrust::host_vector h_stencil = get_random_data( size, std::numeric_limits::min(), std::numeric_limits::max(), seed + seed_value_addition); - thrust::device_vector d_stencil = h_stencil; + thrust::device_vector d_stencil = h_stencil; size_t h_size = thrust::remove_if(h_data.begin(), h_data.end(), h_stencil.begin(), is_true()) - h_data.begin(); size_t d_size = thrust::remove_if(d_data.begin(), d_data.end(), d_stencil.begin(), is_true()) - d_data.begin(); @@ -508,6 +564,7 @@ TYPED_TEST(RemoveVariableTests, TestRemoveCopy) thrust::host_vector h_data = get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); + thrust::device_vector d_data = h_data; thrust::host_vector h_result(size); @@ -518,10 +575,10 @@ TYPED_TEST(RemoveVariableTests, TestRemoveCopy) ASSERT_EQ(h_size, d_size); - h_result.resize(h_size); - d_result.resize(d_size); + h_data.resize(h_size); + d_data.resize(d_size); - ASSERT_EQ(h_result, d_result); + ASSERT_EQ(h_data, d_data); } } } @@ -542,6 +599,7 @@ TYPED_TEST(RemoveVariableTests, TestRemoveCopyToDiscardIterator) thrust::host_vector h_data = get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); + thrust::device_vector d_data = h_data; size_t num_zeros = thrust::count(h_data.begin(), h_data.end(), T(0)); @@ -555,8 +613,8 @@ TYPED_TEST(RemoveVariableTests, TestRemoveCopyToDiscardIterator) thrust::discard_iterator<> reference(num_nonzeros); - ASSERT_EQ_QUIET(reference, h_result); - ASSERT_EQ_QUIET(reference, d_result); + ASSERT_EQ(reference, h_result); + ASSERT_EQ(reference, d_result); } } } @@ -701,7 +759,7 @@ TYPED_TEST(RemoveVariableTests, TestRemoveCopyIfStencil) thrust::device_vector d_data = h_data; thrust::host_vector h_stencil = - get_random_data(size, get_default_limits::min(), get_default_limits::max(), seed); + get_random_data(size, std::numeric_limits::min(), std::numeric_limits::max(), seed); thrust::device_vector d_stencil = h_stencil; thrust::host_vector h_result(size); @@ -743,7 +801,7 @@ TYPED_TEST(RemoveVariableTests, TestRemoveCopyIfStencilToDiscardIterator) thrust::device_vector d_data = h_data; thrust::host_vector h_stencil = get_random_data( - size, get_default_limits::min(), get_default_limits::max(), seed + seed_value_addition); + size, std::numeric_limits::min(), std::numeric_limits::max(), seed + seed_value_addition); thrust::device_vector d_stencil = h_stencil; size_t num_false = thrust::count_if(h_stencil.begin(), h_stencil.end(), thrust::not_fn(is_true())); diff --git a/projects/rocthrust/test/test_scan.cpp b/projects/rocthrust/test/test_scan.cpp index ae3accc6a765..fd37d5b37005 100644 --- a/projects/rocthrust/test/test_scan.cpp +++ b/projects/rocthrust/test/test_scan.cpp @@ -775,16 +775,6 @@ struct iterator_traits }; THRUST_NAMESPACE_END -namespace std -{ -template <> -struct iterator_traits -{ - using value_type = long long; - using reference = only_set_when_expected_it; -}; -} // namespace std - void TestInclusiveScanWithBigIndexesHelper(int magnitude) { thrust::constant_iterator begin(1); diff --git a/projects/rocthrust/test/test_tabulate.cpp b/projects/rocthrust/test/test_tabulate.cpp index 7b249344d2fe..8c2d5a002932 100644 --- a/projects/rocthrust/test/test_tabulate.cpp +++ b/projects/rocthrust/test/test_tabulate.cpp @@ -15,33 +15,18 @@ * limitations under the License. */ +#include #include #include #include #include -#include #include "test_param_fixtures.hpp" #include "test_real_assertions.hpp" #include "test_utils.hpp" -using VectorTestsParams = ::testing::Types< - Params>, - Params>, - Params>, - Params>, - Params>>, - Params>, - Params>, - Params>, - Params>, - Params>>, - Params>, - Params>>; - TESTS_DEFINE(TabulateTests, FullTestsParams); TESTS_DEFINE(TabulatePrimitiveTests, NumericalTestsParams); -TESTS_DEFINE(TabulateVectorTests, VectorTestsParams) template void tabulate(my_system& system, ForwardIterator, ForwardIterator, UnaryOperation) @@ -56,7 +41,7 @@ TEST(TabulateTests, TestTabulateDispatchExplicit) thrust::device_vector vec(1); my_system sys(0); - thrust::tabulate(sys, vec.begin(), vec.end(), ::internal::identity{}); + thrust::tabulate(sys, vec.begin(), vec.end(), thrust::identity()); ASSERT_EQ(true, sys.is_valid()); } @@ -73,34 +58,45 @@ TEST(TabulateTests, TestTabulateDispatchImplicit) thrust::device_vector vec(1); - thrust::tabulate(thrust::retag(vec.begin()), thrust::retag(vec.end()), ::internal::identity{}); + thrust::tabulate(thrust::retag(vec.begin()), thrust::retag(vec.end()), thrust::identity()); ASSERT_EQ(13, vec.front()); } -TYPED_TEST(TabulateVectorTests, TestTabulateSimple) +TYPED_TEST(TabulateTests, TestTabulateSimple) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; + using T = typename Vector::value_type; using namespace thrust::placeholders; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector v(5); - thrust::tabulate(v.begin(), v.end(), ::internal::identity{}); + thrust::tabulate(Policy{}, v.begin(), v.end(), thrust::identity()); - Vector ref{0, 1, 2, 3, 4}; - ASSERT_EQ(v, ref); + ASSERT_EQ(v[0], T(0)); + ASSERT_EQ(v[1], T(1)); + ASSERT_EQ(v[2], T(2)); + ASSERT_EQ(v[3], T(3)); + ASSERT_EQ(v[4], T(4)); - thrust::tabulate(v.begin(), v.end(), -_1); + thrust::tabulate(Policy{}, v.begin(), v.end(), -_1); - ref = {0, -1, -2, -3, -4}; - ASSERT_EQ(v, ref); + ASSERT_EQ(v[0], T(0)); + ASSERT_EQ(v[1], T(-1)); + ASSERT_EQ(v[2], T(-2)); + ASSERT_EQ(v[3], T(-3)); + ASSERT_EQ(v[4], T(-4)); - thrust::tabulate(v.begin(), v.end(), _1 * _1 * _1); + thrust::tabulate(Policy{}, v.begin(), v.end(), _1 * _1 * _1); - ref = {0, 1, 8, 27, 64}; - ASSERT_EQ(v, ref); + ASSERT_EQ(v[0], T(0)); + ASSERT_EQ(v[1], T(1)); + ASSERT_EQ(v[2], T(8)); + ASSERT_EQ(v[3], T(27)); + ASSERT_EQ(v[4], T(64)); } template @@ -116,13 +112,14 @@ struct nonconst_op TYPED_TEST(TabulateTests, TestTabulateSimpleNonConstOP) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); Vector v(5); - thrust::tabulate(v.begin(), v.end(), nonconst_op()); + thrust::tabulate(Policy{}, v.begin(), v.end(), nonconst_op()); ASSERT_EQ(v[0], T(0)); ASSERT_EQ(v[1], T(0)); @@ -145,13 +142,17 @@ TYPED_TEST(TabulatePrimitiveTests, TestTabulate) thrust::host_vector h_data(size); thrust::device_vector d_data(size); - thrust::tabulate(h_data.begin(), h_data.end(), _1 * _1 + 13); - thrust::tabulate(d_data.begin(), d_data.end(), _1 * _1 + 13); + thrust::tabulate(h_data.begin(), h_data.end(), _1 * _1 + T(13)); + thrust::tabulate(d_data.begin(), d_data.end(), _1 * _1 + T(13)); - ASSERT_EQ(h_data, d_data); + thrust::host_vector h_result = d_data; + for (size_t i = 0; i < size; i++) + { + ASSERT_EQ(h_data[i], h_result[i]) << "where index = " << i; + } - thrust::tabulate(h_data.begin(), h_data.end(), (_1 - 7) * _1); - thrust::tabulate(d_data.begin(), d_data.end(), (_1 - 7) * _1); + thrust::tabulate(h_data.begin(), h_data.end(), (_1 - T(7)) * _1); + thrust::tabulate(d_data.begin(), d_data.end(), (_1 - T(7)) * _1); ASSERT_EQ(h_data, d_data); } @@ -163,12 +164,9 @@ TEST(TabulateTests, TestTabulateToDiscardIterator) for (auto size : get_sizes()) { - SCOPED_TRACE(testing::Message() << "with size = " << size); - thrust::tabulate(thrust::discard_iterator(), thrust::discard_iterator(size), - ::internal::identity{}); + thrust::identity()); } - // nothing to check -- just make sure it compiles } diff --git a/projects/rocthrust/test/test_transform.cpp b/projects/rocthrust/test/test_transform.cpp index eeaa4668c29f..b12aa2a17054 100644 --- a/projects/rocthrust/test/test_transform.cpp +++ b/projects/rocthrust/test/test_transform.cpp @@ -15,7 +15,6 @@ * limitations under the License. */ -#include #include #include #include @@ -213,7 +212,7 @@ TYPED_TEST(TransformVectorTests, TestTransformIfUnaryNoStencilSimple) THRUST_DIS Vector output{-1, -2, -3}; Vector result{-1, 2, -3}; - iter = thrust::transform_if(input.begin(), input.end(), output.begin(), thrust::negate(), ::internal::identity{}); + iter = thrust::transform_if(input.begin(), input.end(), output.begin(), thrust::negate(), thrust::identity()); ASSERT_EQ(std::size_t(iter - output.begin()), input.size()); ASSERT_EQ(output, result); @@ -277,7 +276,7 @@ TYPED_TEST(TransformVectorTests, TestTransformIfUnarySimple) THRUST_DISABLE_BROK Vector result{-1, 2, -3}; iter = thrust::transform_if( - input.begin(), input.end(), stencil.begin(), output.begin(), thrust::negate(), ::internal::identity{}); + input.begin(), input.end(), stencil.begin(), output.begin(), thrust::negate(), thrust::identity()); ASSERT_EQ(std::size_t(iter - output.begin()), input.size()); ASSERT_EQ(output, result); @@ -411,7 +410,7 @@ TYPED_TEST(TransformVectorTests, TestTransformIfBinarySimple) THRUST_DISABLE_BRO Vector output{1, 2, 3}; Vector result{5, 2, -3}; - ::internal::identity identity; + thrust::identity identity; iter = thrust::transform_if( input1.begin(), @@ -957,18 +956,18 @@ TYPED_TEST(TransformInOutTests, TestTransformUnaryCountingIterator) THRUST_DISAB SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - size_t const n = 15 * sizeof(T); + size_t const size = 15 * sizeof(T); - ASSERT_LE(T(n), truncate_to_max_representable(n)); + ASSERT_LE(T(size), truncate_to_max_representable(size)); thrust::counting_iterator h_first = thrust::make_counting_iterator(0); thrust::counting_iterator d_first = thrust::make_counting_iterator(0); - thrust::host_vector h_result(n); - thrust::device_vector d_result(n); + thrust::host_vector h_result(size); + thrust::device_vector d_result(size); - thrust::transform(h_first, h_first + n, h_result.begin(), ::internal::identity{}); - thrust::transform(d_first, d_first + n, d_result.begin(), ::internal::identity{}); + thrust::transform(h_first, h_first + size, h_result.begin(), thrust::identity()); + thrust::transform(d_first, d_first + size, d_result.begin(), thrust::identity()); ASSERT_EQ(h_result, d_result); } diff --git a/projects/rocthrust/test/test_transform_input_output_iterator.cpp b/projects/rocthrust/test/test_transform_input_output_iterator.cpp index a73533ca7605..a97fb33dd980 100644 --- a/projects/rocthrust/test/test_transform_input_output_iterator.cpp +++ b/projects/rocthrust/test/test_transform_input_output_iterator.cpp @@ -157,8 +157,8 @@ TYPED_TEST(TransformInputOutputIteratorVariableUnitTests, TestTransformInputOutp // run on host (uses forward iterator negate) thrust::inclusive_scan( - thrust::make_transform_input_output_iterator(h_data.begin(), thrust::negate(), ::internal::identity{}), - thrust::make_transform_input_output_iterator(h_data.end(), thrust::negate(), ::internal::identity{}), + thrust::make_transform_input_output_iterator(h_data.begin(), thrust::negate(), thrust::identity()), + thrust::make_transform_input_output_iterator(h_data.end(), thrust::negate(), thrust::identity()), h_result.begin()); // run on device (uses reverse iterator negate) thrust::inclusive_scan( diff --git a/projects/rocthrust/test/test_transform_iterator.cpp b/projects/rocthrust/test/test_transform_iterator.cpp index 5e4862e2af4f..8f92864459a9 100644 --- a/projects/rocthrust/test/test_transform_iterator.cpp +++ b/projects/rocthrust/test/test_transform_iterator.cpp @@ -15,55 +15,19 @@ * limitations under the License. */ -#include - -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC -// suppress warnings on thrust::identity -THRUST_SUPPRESS_DEPRECATED_PUSH -#endif // THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC - #include #include #include #include #include #include -#include - -#include -#include #include "test_param_fixtures.hpp" #include "test_real_assertions.hpp" #include "test_utils.hpp" -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -# include -# include -# include -#endif - -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC - -using VectorTestsParams = ::testing::Types< - Params>, - Params>, - Params>, - Params>, - Params>>, - Params>, - Params>, - Params>, - Params>, - Params>>, - Params>, - Params>>; - TESTS_DEFINE(TransformIteratorTests, FullTestsParams); TESTS_DEFINE(PrimitiveTransformIteratorTests, NumericalTestsParams); -TESTS_DEFINE(VectorTransformIteratorTests, VectorTestsParams); TEST(TransformIteratorTests, UsingHip) { @@ -72,9 +36,10 @@ TEST(TransformIteratorTests, UsingHip) ASSERT_EQ(THRUST_DEVICE_SYSTEM, THRUST_DEVICE_SYSTEM_HIP); } -TYPED_TEST(VectorTransformIteratorTests, TestTransformIterator) +TYPED_TEST(TransformIteratorTests, TransformIterator) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); @@ -86,20 +51,23 @@ TYPED_TEST(VectorTransformIteratorTests, TestTransformIterator) Vector output(4); // initialize input - thrust::sequence(input.begin(), input.end(), 1); + thrust::sequence(Policy{}, input.begin(), input.end(), 1); // construct transform_iterator thrust::transform_iterator iter(input.begin(), UnaryFunction()); - thrust::copy(iter, iter + 4, output.begin()); + thrust::copy(Policy{}, iter, iter + 4, output.begin()); - Vector ref{-1, -2, -3, -4}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], (T) -1); + ASSERT_EQ(output[1], (T) -2); + ASSERT_EQ(output[2], (T) -3); + ASSERT_EQ(output[3], (T) -4); } -TYPED_TEST(VectorTransformIteratorTests, TestMakeTransformIterator) +TYPED_TEST(TransformIteratorTests, MakeTransformIterator) { using Vector = typename TestFixture::input_type; + using Policy = typename TestFixture::execution_policy; using T = typename Vector::value_type; SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); @@ -111,20 +79,23 @@ TYPED_TEST(VectorTransformIteratorTests, TestMakeTransformIterator) Vector output(4); // initialize input - thrust::sequence(input.begin(), input.end(), 1); + thrust::sequence(Policy{}, input.begin(), input.end(), 1); // construct transform_iterator thrust::transform_iterator iter(input.begin(), UnaryFunction()); - thrust::copy(thrust::make_transform_iterator(input.begin(), UnaryFunction()), + thrust::copy(Policy{}, + thrust::make_transform_iterator(input.begin(), UnaryFunction()), thrust::make_transform_iterator(input.end(), UnaryFunction()), output.begin()); - Vector ref{-1, -2, -3, -4}; - ASSERT_EQ(output, ref); + ASSERT_EQ(output[0], (T) -1); + ASSERT_EQ(output[1], (T) -2); + ASSERT_EQ(output[2], (T) -3); + ASSERT_EQ(output[3], (T) -4); } -TYPED_TEST(PrimitiveTransformIteratorTests, TestTransformIteratorReduce) +TYPED_TEST(PrimitiveTransformIteratorTests, TransformIteratorReduce) { using T = typename TestFixture::input_type; @@ -134,18 +105,25 @@ TYPED_TEST(PrimitiveTransformIteratorTests, TestTransformIteratorReduce) { SCOPED_TRACE(testing::Message() << "with size= " << size); - thrust::host_vector h_data = random_samples(size); - thrust::device_vector d_data = h_data; + T error_margin = (T) 0.01 * size; + + for (auto seed : get_seeds()) + { + SCOPED_TRACE(testing::Message() << "with seed= " << seed); + + thrust::host_vector h_data = get_random_data(size, 0, 10, seed); + thrust::device_vector d_data = h_data; - // run on host - T h_result = thrust::reduce(thrust::make_transform_iterator(h_data.begin(), thrust::negate()), - thrust::make_transform_iterator(h_data.end(), thrust::negate())); + // run on host + T h_result = thrust::reduce(thrust::make_transform_iterator(h_data.begin(), thrust::negate()), + thrust::make_transform_iterator(h_data.end(), thrust::negate())); - // run on device - T d_result = thrust::reduce(thrust::make_transform_iterator(d_data.begin(), thrust::negate()), - thrust::make_transform_iterator(d_data.end(), thrust::negate())); + // run on device + T d_result = thrust::reduce(thrust::make_transform_iterator(d_data.begin(), thrust::negate()), + thrust::make_transform_iterator(d_data.end(), thrust::negate())); - ASSERT_EQ(h_result, d_result); + ASSERT_NEAR(h_result, d_result, error_margin); + } } } @@ -159,8 +137,6 @@ struct ExtractValue TEST(TransformIteratorTests, TestTransformIteratorNonCopyable) { - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - thrust::host_vector> hv(4); hv[0].reset(new int{1}); hv[1].reset(new int{2}); @@ -185,168 +161,7 @@ struct DeviceOp /// Tests compilation of device-only operators. TEST(TransformIteratorTests, TestDeviceOperator) { - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - thrust::device_vector dv(1); auto iter = thrust::make_transform_iterator(dv.begin(), DeviceOp{}); THRUST_UNUSED_VAR(iter); } - -struct flip_value -{ - THRUST_HOST_DEVICE bool operator()(bool b) const - { - return !b; - } -}; - -struct pass_ref -{ - THRUST_HOST_DEVICE const bool& operator()(const bool& b) const - { - return b; - } -}; - -// a user provided functor that forwards its argument -struct forward -{ - template - constexpr _Tp&& operator()(_Tp&& __t) const noexcept - { - return _THRUST_STD::forward<_Tp>(__t); - } -}; - -TEST(TransformIteratorTests, TestTransformIteratorReferenceAndValueType) -{ - THRUST_SUPPRESS_DEPRECATED_PUSH - - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - - using _THRUST_STD::is_same; - using _THRUST_STD::negate; - { - thrust::host_vector v; - - auto it = v.begin(); - static_assert(is_same::value, ""); // ordinary reference - static_assert(is_same::value, ""); - - auto it_tr_val = thrust::make_transform_iterator(it, flip_value{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_val; - - auto it_tr_ref = thrust::make_transform_iterator(it, pass_ref{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_ref; - - auto it_tr_fwd = thrust::make_transform_iterator(it, forward{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_fwd; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - - auto it_tr_cid = thrust::make_transform_iterator(it, ::internal::identity{}); - static_assert(is_same::value, ""); // special handling by - // transform_iterator_reference - static_assert(is_same::value, ""); - (void) it_tr_cid; - } - - { - thrust::device_vector v; - - auto it = v.begin(); - static_assert(is_same>::value, ""); // proxy reference - static_assert(is_same::value, ""); - - auto it_tr_val = thrust::make_transform_iterator(it, flip_value{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_val; - - auto it_tr_ref = thrust::make_transform_iterator(it, pass_ref{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_ref; - - auto it_tr_fwd = thrust::make_transform_iterator(it, forward{}); - static_assert(is_same::value, ""); // wrapped reference is decayed - static_assert(is_same::value, ""); - (void) it_tr_fwd; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - - auto it_tr_cid = thrust::make_transform_iterator(it, ::internal::identity{}); - static_assert(is_same::value, ""); // special handling by - // transform_iterator_reference - static_assert(is_same::value, ""); - (void) it_tr_cid; - } - - { - std::vector v; - - auto it = v.begin(); - static_assert(is_same::reference>::value, ""); // proxy reference - static_assert(is_same::value, ""); - - auto it_tr_val = thrust::make_transform_iterator(it, flip_value{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_val; - - auto it_tr_ref = thrust::make_transform_iterator(it, pass_ref{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - (void) it_tr_ref; - - auto it_tr_fwd = thrust::make_transform_iterator(it, forward{}); - static_assert(is_same::value, ""); // proxy reference is decayed - static_assert(is_same::value, ""); - (void) it_tr_fwd; - - auto it_tr_ide = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_ide; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - - auto it_tr_cid = thrust::make_transform_iterator(it, ::internal::identity{}); - static_assert(is_same::value, ""); // special handling by - // transform_iterator_reference - static_assert(is_same::value, ""); - (void) it_tr_cid; - } - THRUST_SUPPRESS_DEPRECATED_POP -} - -TEST(TransformIteratorTests, TestTransformIteratorIdentity) -{ - THRUST_SUPPRESS_DEPRECATED_PUSH - - SCOPED_TRACE(testing::Message() << "with device_id= " << test::set_device_from_ctest()); - - thrust::device_vector v(3, 42); - - ASSERT_EQ(*thrust::make_transform_iterator(v.begin(), thrust::identity{}), 42); - ASSERT_EQ(*thrust::make_transform_iterator(v.begin(), thrust::identity<>{}), 42); - ASSERT_EQ(*thrust::make_transform_iterator(v.begin(), ::internal::identity{}), 42); - using namespace thrust::placeholders; - ASSERT_EQ(*thrust::make_transform_iterator(v.begin(), _1), 42); - THRUST_SUPPRESS_DEPRECATED_POP -} diff --git a/projects/rocthrust/test/test_transform_scan.cpp b/projects/rocthrust/test/test_transform_scan.cpp index 4ee2e0803e0b..62ebb24fc497 100644 --- a/projects/rocthrust/test/test_transform_scan.cpp +++ b/projects/rocthrust/test/test_transform_scan.cpp @@ -419,20 +419,20 @@ TYPED_TEST(TransformScanVariablesTests, TestValueCategoryDeduction) vec.assign((T*) a_h, a_h + 10); thrust::transform_inclusive_scan( - thrust::device, vec.cbegin(), vec.cend(), vec.begin(), ::internal::identity{}, thrust::maximum<>{}); + thrust::device, vec.cbegin(), vec.cend(), vec.begin(), thrust::identity<>{}, thrust::maximum<>{}); ASSERT_EQ((thrust::device_vector{5, 5, 5, 8, 8, 8, 8, 8, 8, 9}), vec); vec.assign((T*) a_h, a_h + 10); thrust::transform_inclusive_scan( - thrust::device, vec.cbegin(), vec.cend(), vec.begin(), ::internal::identity{}, T{}, thrust::maximum<>{}); + thrust::device, vec.cbegin(), vec.cend(), vec.begin(), thrust::identity<>{}, T{}, thrust::maximum<>{}); ASSERT_EQ((thrust::device_vector{5, 5, 5, 8, 8, 8, 8, 8, 8, 9}), vec); vec.assign((T*) a_h, a_h + 10); thrust::transform_exclusive_scan( - thrust::device, vec.cbegin(), vec.cend(), vec.begin(), ::internal::identity{}, T{}, thrust::maximum<>{}); + thrust::device, vec.cbegin(), vec.cend(), vec.begin(), thrust::identity<>{}, T{}, thrust::maximum<>{}); ASSERT_EQ((thrust::device_vector{0, 5, 5, 5, 8, 8, 8, 8, 8, 8}), vec); } diff --git a/projects/rocthrust/test/test_tuple.cpp b/projects/rocthrust/test/test_tuple.cpp index f0de36c9fc34..9f9f51d0e9c9 100644 --- a/projects/rocthrust/test/test_tuple.cpp +++ b/projects/rocthrust/test/test_tuple.cpp @@ -29,11 +29,6 @@ TESTS_DEFINE(TupleTests, NumericalTestsParams); -// Yes we're using 'thrust::null_type', I don't care >:( -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -THRUST_SUPPRESS_DEPRECATED_PUSH -#endif - TYPED_TEST(TupleTests, TestTupleConstructor) { using T = typename TestFixture::input_type; @@ -570,12 +565,7 @@ TEST(TupleTests, TestTupleCTAD) } #endif // THRUST_CPP_DIALECT >= 2017 -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -THRUST_SUPPRESS_DEPRECATED_POP -#endif - // Ensure that we are backwards compatible with the old thrust::tuple implementation -THRUST_SUPPRESS_DEPRECATED_PUSH static_assert( thrust::tuple_size>::value == 9, ""); static_assert(thrust::tuple_size>::value == 10, ""); -THRUST_SUPPRESS_DEPRECATED_POP diff --git a/projects/rocthrust/test/test_type_traits.cpp b/projects/rocthrust/test/test_type_traits.cpp index 5255333f7acb..b83f29c91b21 100644 --- a/projects/rocthrust/test/test_type_traits.cpp +++ b/projects/rocthrust/test/test_type_traits.cpp @@ -15,11 +15,8 @@ * limitations under the License. */ -#include - #include #include -#include #include #include #include @@ -65,23 +62,14 @@ TEST(TypeTraitsTests, TestIsContiguousIterator) using HostIteratorTuple = thrust::tuple; - using ConstantIterator = thrust::constant_iterator; - using CountingIterator = thrust::counting_iterator; - THRUST_SUPPRESS_DEPRECATED_PUSH - using TransformIterator1 = thrust::transform_iterator, HostVector::iterator>; - THRUST_SUPPRESS_DEPRECATED_POP - using TransformIterator2 = thrust::transform_iterator<::internal::identity, HostVector::iterator>; - using ZipIterator = thrust::zip_iterator; + using ConstantIterator = thrust::constant_iterator; + using CountingIterator = thrust::counting_iterator; + using TransformIterator = thrust::transform_iterator, HostVector::iterator>; + using ZipIterator = thrust::zip_iterator; ASSERT_EQ((bool) thrust::is_contiguous_iterator::value, false); ASSERT_EQ((bool) thrust::is_contiguous_iterator::value, false); -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_NVHPC - // thrust::identity creates a deprecated warning that could not be worked around - THRUST_SUPPRESS_DEPRECATED_PUSH - ASSERT_EQ((bool) thrust::is_contiguous_iterator::value, false); - THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_NVHPC - ASSERT_EQ((bool) thrust::is_contiguous_iterator::value, false); + ASSERT_EQ((bool) thrust::is_contiguous_iterator::value, false); ASSERT_EQ((bool) thrust::is_contiguous_iterator::value, false); } diff --git a/projects/rocthrust/test/test_utils.hpp b/projects/rocthrust/test/test_utils.hpp index 0bc87a96c839..d90e714bdca2 100644 --- a/projects/rocthrust/test/test_utils.hpp +++ b/projects/rocthrust/test/test_utils.hpp @@ -31,10 +31,6 @@ #include #include #include -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -// Use rocprim::numeric_limits if thrust/detail/type_traits.h uses rocprim::arithmetic -# include -#endif #include "test_seed.hpp" @@ -745,21 +741,17 @@ thrust::host_vector random_samples(const size_t N) // Use this with counting_iterator to avoid generating a range larger than we // can represent. template -typename THRUST_NS_QUALIFIER::detail::disable_if<_THRUST_STD::is_floating_point::value, T>::type +typename thrust::detail::disable_if<::std::is_floating_point::value, T>::type truncate_to_max_representable(std::size_t n) { - // Use rocprim::numeric_limits if thrust/detail/type_traits.h uses rocprim::arithmetic - return static_cast( - THRUST_NS_QUALIFIER::min(n, static_cast(_THRUST_STD::numeric_limits::max()))); + return thrust::min(n, static_cast(thrust::numeric_limits::max())); } // TODO: This probably won't work for `half`. template -typename _THRUST_STD::enable_if_t<_THRUST_STD::is_floating_point::value, T> -truncate_to_max_representable(std::size_t n) +typename ::std::enable_if<::std::is_floating_point::value, T>::type truncate_to_max_representable(std::size_t n) { - // Use rocprim::numeric_limits if thrust/detail/type_traits.h uses rocprim::arithmetic - return THRUST_NS_QUALIFIER::min(static_cast(n), _THRUST_STD::numeric_limits::max()); + return thrust::min(n, thrust::numeric_limits::max()); } enum threw_status diff --git a/projects/rocthrust/testing/allocator_aware_policies.cu b/projects/rocthrust/testing/allocator_aware_policies.cu index df34f0f915d8..ecd71a86e962 100644 --- a/projects/rocthrust/testing/allocator_aware_policies.cu +++ b/projects/rocthrust/testing/allocator_aware_policies.cu @@ -15,11 +15,6 @@ * limitations under the License. */ -#include - -// need to suppress deprecation warnings for execute_with_allocator_and_dependencies here and inside type traits -THRUST_SUPPRESS_DEPRECATED_PUSH - #include #include #include @@ -133,5 +128,3 @@ using hip_par_info = policy_info> TestAllocatorAttachmentInstance; - -THRUST_SUPPRESS_DEPRECATED_POP diff --git a/projects/rocthrust/testing/async/exclusive_scan/counting_iterator.cu b/projects/rocthrust/testing/async/exclusive_scan/counting_iterator.cu index 1817bd6f44ce..0891592f131c 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/counting_iterator.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/counting_iterator.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -58,9 +56,4 @@ struct test_counting_iterator // the custom_numeric. DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_counting_iterator, UnsignedIntegralTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/discard_output.cu b/projects/rocthrust/testing/async/exclusive_scan/discard_output.cu index 9659f4f72520..d75886b9870e 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/discard_output.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/discard_output.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -55,9 +53,4 @@ struct test_discard }; DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_discard, NumericTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/large_indices.cu b/projects/rocthrust/testing/async/exclusive_scan/large_indices.cu index a68006f6a019..5d4a98078c6a 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/large_indices.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/large_indices.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -82,18 +80,18 @@ struct assert_sequence_iterator unexpected_value = nullptr; } - __host__ __device__ assert_sequence_iterator operator+(difference_type i) const + THRUST_HOST_DEVICE assert_sequence_iterator operator+(difference_type i) const { return clone(expected + i); } - __host__ __device__ reference operator[](difference_type i) const + THRUST_HOST_DEVICE reference operator[](difference_type i) const { return clone(expected + i); } // Some weirdness, this iterator acts like its own reference - __device__ assert_sequence_iterator operator=(value_type val) + THRUST_DEVICE assert_sequence_iterator operator=(value_type val) { if (val != expected) { @@ -109,7 +107,7 @@ struct assert_sequence_iterator } private: - __host__ __device__ assert_sequence_iterator clone(value_type new_expected) const + THRUST_HOST_DEVICE assert_sequence_iterator clone(value_type new_expected) const { return {new_expected, max, found_max, unexpected_value}; } @@ -261,9 +259,4 @@ void test_large_indices_custom_scan_op() } DECLARE_UNITTEST(test_large_indices_custom_scan_op); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/large_types.cu b/projects/rocthrust/testing/async/exclusive_scan/large_types.cu index 36ce5542a3be..8e9ea35392c4 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/large_types.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/large_types.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -70,9 +68,4 @@ struct test_large_types }; DECLARE_UNITTEST(test_large_types); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/mixed_types.cu b/projects/rocthrust/testing/async/exclusive_scan/mixed_types.cu index 9bcb7e8f2972..df9860dc592b 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/mixed_types.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/mixed_types.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -135,9 +133,4 @@ void test_scan_mixed_types(size_t num_values) } DECLARE_SIZED_UNITTEST(test_scan_mixed_types); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/mixin.h b/projects/rocthrust/testing/async/exclusive_scan/mixin.h index f04e006fec19..3a9a692acca7 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/mixin.h +++ b/projects/rocthrust/testing/async/exclusive_scan/mixin.h @@ -110,14 +110,12 @@ struct simple PostfixArgTuple&& postfix_tuple, std::index_sequence) { - THRUST_SUPPRESS_DEPRECATED_PUSH auto e = thrust::async::exclusive_scan( std::get(THRUST_FWD(prefix_tuple))..., input.cbegin(), input.cend(), output.begin(), std::get(THRUST_FWD(postfix_tuple))...); - THRUST_SUPPRESS_DEPRECATED_POP return e; } }; diff --git a/projects/rocthrust/testing/async/exclusive_scan/simple.cu b/projects/rocthrust/testing/async/exclusive_scan/simple.cu index 9ec8c71edda2..4603ec5a085c 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/simple.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/simple.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -89,9 +87,4 @@ struct test_simple_in_place }; DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_simple_in_place, NumericTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/stateful_operator.cu b/projects/rocthrust/testing/async/exclusive_scan/stateful_operator.cu index a00992b018a7..14a5b935e6f1 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/stateful_operator.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/stateful_operator.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -33,7 +31,7 @@ struct stateful_operator { T offset; - __host__ __device__ T operator()(T v1, T v2) + THRUST_HOST_DEVICE T operator()(T v1, T v2) { return v1 + v2 + offset; } @@ -80,9 +78,4 @@ struct test_stateful_operator }; DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_stateful_operator, NumericTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/exclusive_scan/using_vs_adl.cu b/projects/rocthrust/testing/async/exclusive_scan/using_vs_adl.cu index 47ac349fafb5..cd6d27f3924e 100644 --- a/projects/rocthrust/testing/async/exclusive_scan/using_vs_adl.cu +++ b/projects/rocthrust/testing/async/exclusive_scan/using_vs_adl.cu @@ -17,10 +17,6 @@ #include -#include - -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -50,7 +46,7 @@ struct adl_host_synchronous thrust::host_vector host_input(input.cbegin(), input.cend()); thrust::host_vector host_output(host_input.size()); - using OutIter = ::internal::remove_cvref_t; + using OutIter = thrust::remove_cvref_t; // ADL should resolve this to the synchronous `thrust::` algorithm. // This is checked by ensuring that the call returns an output iterator. @@ -90,7 +86,6 @@ struct using_namespace // Importing the CPO into the current namespace should unambiguously resolve // this call to the CPO, as opposed to resolving to the thrust:: algorithm // via ADL. This is verified by checking that an event is returned. - THRUST_SUPPRESS_DEPRECATED_PUSH using namespace thrust::async; thrust::device_event e = exclusive_scan( std::get(THRUST_FWD(prefix_tuple))..., @@ -98,7 +93,6 @@ struct using_namespace input.cend(), output.begin(), std::get(THRUST_FWD(postfix_tuple))...); - THRUST_SUPPRESS_DEPRECATED_POP return e; } }; @@ -123,14 +117,12 @@ struct using_cpo // this call to the CPO, as opposed to resolving to the thrust:: algorithm // via ADL. This is verified by checking that an event is returned. using thrust::async::exclusive_scan; - THRUST_SUPPRESS_DEPRECATED_PUSH thrust::device_event e = exclusive_scan( std::get(THRUST_FWD(prefix_tuple))..., input.cbegin(), input.cend(), output.begin(), std::get(THRUST_FWD(postfix_tuple))...); - THRUST_SUPPRESS_DEPRECATED_POP return e; } }; @@ -188,9 +180,4 @@ void test_using_cpo() } DECLARE_UNITTEST(test_using_cpo); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/counting_iterator.cu b/projects/rocthrust/testing/async/inclusive_scan/counting_iterator.cu index d594a53511c1..3bed83d1f255 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/counting_iterator.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/counting_iterator.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -57,9 +55,4 @@ struct test_counting_iterator // the custom_numeric. DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_counting_iterator, UnsignedIntegralTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/discard_output.cu b/projects/rocthrust/testing/async/inclusive_scan/discard_output.cu index 3a3046578250..ffc72dcd30da 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/discard_output.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/discard_output.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -53,9 +51,4 @@ struct test_discard }; DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_discard, NumericTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/large_indices.cu b/projects/rocthrust/testing/async/inclusive_scan/large_indices.cu index 9ce6d843f83e..7fffb288eed6 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/large_indices.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/large_indices.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -81,18 +79,18 @@ struct assert_sequence_iterator unexpected_value = nullptr; } - __host__ __device__ assert_sequence_iterator operator+(difference_type i) const + THRUST_HOST_DEVICE assert_sequence_iterator operator+(difference_type i) const { return clone(expected + i); } - __host__ __device__ reference operator[](difference_type i) const + THRUST_HOST_DEVICE reference operator[](difference_type i) const { return clone(expected + i); } // Some weirdness, this iterator acts like its own reference - __device__ assert_sequence_iterator operator=(value_type val) + THRUST_DEVICE assert_sequence_iterator operator=(value_type val) { if (val != expected) { @@ -109,7 +107,7 @@ struct assert_sequence_iterator } private: - __host__ __device__ assert_sequence_iterator clone(value_type new_expected) const + THRUST_HOST_DEVICE assert_sequence_iterator clone(value_type new_expected) const { return {new_expected, max, found_max, unexpected_value}; } @@ -255,9 +253,4 @@ void test_large_indices_custom_scan_op() } DECLARE_UNITTEST(test_large_indices_custom_scan_op); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/large_types.cu b/projects/rocthrust/testing/async/inclusive_scan/large_types.cu index 0f9bd9ec1fa5..eb070a9b009c 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/large_types.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/large_types.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -70,9 +68,4 @@ struct test_large_types }; DECLARE_UNITTEST(test_large_types); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/mixed_types.cu b/projects/rocthrust/testing/async/inclusive_scan/mixed_types.cu index e7da5ee0194f..2c33f97c3e0b 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/mixed_types.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/mixed_types.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -124,9 +122,4 @@ void test_scan_mixed_types(size_t num_values) } DECLARE_SIZED_UNITTEST(test_scan_mixed_types); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/mixin.h b/projects/rocthrust/testing/async/inclusive_scan/mixin.h index 101280f4e2a1..0bec41dbbc94 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/mixin.h +++ b/projects/rocthrust/testing/async/inclusive_scan/mixin.h @@ -126,14 +126,12 @@ struct simple PostfixArgTuple&& postfix_tuple, std::index_sequence) { - THRUST_SUPPRESS_DEPRECATED_PUSH auto e = thrust::async::inclusive_scan( std::get(THRUST_FWD(prefix_tuple))..., input.cbegin(), input.cend(), output.begin(), std::get(THRUST_FWD(postfix_tuple))...); - THRUST_SUPPRESS_DEPRECATED_POP return e; } }; diff --git a/projects/rocthrust/testing/async/inclusive_scan/simple.cu b/projects/rocthrust/testing/async/inclusive_scan/simple.cu index 1833366fe02c..2865cf97ddc2 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/simple.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/simple.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -113,9 +111,4 @@ struct test_simple_in_place }; DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_simple_in_place, NumericTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/stateful_operator.cu b/projects/rocthrust/testing/async/inclusive_scan/stateful_operator.cu index 5ac573849496..60006758802f 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/stateful_operator.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/stateful_operator.cu @@ -17,8 +17,6 @@ #include -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -33,7 +31,7 @@ struct stateful_operator { T offset; - __host__ __device__ T operator()(T v1, T v2) + THRUST_HOST_DEVICE T operator()(T v1, T v2) { return v1 + v2 + offset; } @@ -80,9 +78,4 @@ struct test_stateful_operator }; DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_stateful_operator, NumericTypes); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/inclusive_scan/using_vs_adl.cu b/projects/rocthrust/testing/async/inclusive_scan/using_vs_adl.cu index 091d46061c6a..1cd6c979d953 100644 --- a/projects/rocthrust/testing/async/inclusive_scan/using_vs_adl.cu +++ b/projects/rocthrust/testing/async/inclusive_scan/using_vs_adl.cu @@ -17,10 +17,6 @@ #include -#include - -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -50,7 +46,7 @@ struct adl_host_synchronous thrust::host_vector host_input(input.cbegin(), input.cend()); thrust::host_vector host_output(host_input.size()); - using OutIter = ::internal::remove_cvref_t; + using OutIter = thrust::remove_cvref_t; // ADL should resolve this to the synchronous `thrust::` algorithm. // This is checked by ensuring that the call returns an output iterator. @@ -90,7 +86,6 @@ struct using_namespace // Importing the CPO into the current namespace should unambiguously resolve // this call to the CPO, as opposed to resolving to the thrust:: algorithm // via ADL. This is verified by checking that an event is returned. - THRUST_SUPPRESS_DEPRECATED_PUSH using namespace thrust::async; thrust::device_event e = inclusive_scan( std::get(THRUST_FWD(prefix_tuple))..., @@ -98,7 +93,6 @@ struct using_namespace input.cend(), output.begin(), std::get(THRUST_FWD(postfix_tuple))...); - THRUST_SUPPRESS_DEPRECATED_POP return e; } }; @@ -123,14 +117,12 @@ struct using_cpo // this call to the CPO, as opposed to resolving to the thrust:: algorithm // via ADL. This is verified by checking that an event is returned. using thrust::async::inclusive_scan; - THRUST_SUPPRESS_DEPRECATED_PUSH thrust::device_event e = inclusive_scan( std::get(THRUST_FWD(prefix_tuple))..., input.cbegin(), input.cend(), output.begin(), std::get(THRUST_FWD(postfix_tuple))...); - THRUST_SUPPRESS_DEPRECATED_POP return e; } }; @@ -186,9 +178,4 @@ void test_using_cpo() } DECLARE_UNITTEST(test_using_cpo); -#endif // C++17 - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC +#endif // C++14 diff --git a/projects/rocthrust/testing/async/test_policy_overloads.h b/projects/rocthrust/testing/async/test_policy_overloads.h index 826e78e3d5cf..6f612b01d21b 100644 --- a/projects/rocthrust/testing/async/test_policy_overloads.h +++ b/projects/rocthrust/testing/async/test_policy_overloads.h @@ -21,7 +21,6 @@ #if THRUST_CPP_DIALECT >= 2017 -# include # include # include @@ -118,13 +117,23 @@ struct test_policy_overloads { // When a policy uses the default stream, the algorithm implementation // should spawn a new stream in the returned event: +# if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_HIP auto using_default_stream = [](auto& e) { ASSERT_NOT_EQUAL(thrust::hip_rocprim::default_stream(), e.stream().native_handle()); }; - +# else + auto using_default_stream = [](auto& e) { + ASSERT_NOT_EQUAL(thrust::cuda_cub::default_stream(), e.stream().native_handle()); + }; +# endif // When a policy uses a non-default stream, the implementation should pass // the stream through to the output: + +# if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_HIP thrust::system::hip::detail::unique_stream test_stream{}; +# else + thrust::system::cuda::detail::unique_stream test_stream{}; +# endif auto using_test_stream = [&test_stream](auto& e) { ASSERT_EQUAL(test_stream.native_handle(), e.stream().native_handle()); }; @@ -165,7 +174,7 @@ struct test_policy_overloads { // Sink the prefix tuple into a const local so it can be safely passed to // multiple invocations without worrying about potential modifications. - using prefix_tuple_type = ::internal::remove_cvref_t; + using prefix_tuple_type = thrust::remove_cvref_t; prefix_tuple_type const prefix_tuple = THRUST_FWD(prefix_tuple_ref); using postfix_tuple_type = std::tuple_element_t; @@ -222,9 +231,9 @@ struct test_policy_overloads // debugging: using overload_t = std::tuple_element_t; - std::string const overload_desc = unittest::type_name(); - std::string const input_desc = unittest::type_name(); - std::string const output_desc = unittest::type_name(); + std::string const overload_desc = unittest::demangle(typeid(overload_t).name()); + std::string const input_desc = unittest::demangle(typeid(input_type).name()); + std::string const output_desc = unittest::demangle(typeid(output_type).name()); exc << "\n" @@ -274,8 +283,11 @@ struct test_policy_overloads auto const stream_a = e_a.stream().native_handle(); // Execution on default stream should create a new stream in the result: +# if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_HIP ASSERT_NOT_EQUAL_QUIET(thrust::hip_rocprim::default_stream(), stream_a); - +# else + ASSERT_NOT_EQUAL_QUIET(thrust::cuda_cub::default_stream(), stream_a); +# endif //-------------------------------------------------------------------------- // Test event consumption when the event is an rvalue. //-------------------------------------------------------------------------- diff --git a/projects/rocthrust/testing/async_copy.cu b/projects/rocthrust/testing/async_copy.cu index c94b1a269426..8d0f45315ff3 100644 --- a/projects/rocthrust/testing/async_copy.cu +++ b/projects/rocthrust/testing/async_copy.cu @@ -17,9 +17,6 @@ #include -// need to suppress deprecation warnings inside a lot of thrust headers -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2014 # include @@ -339,8 +336,3 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(test_async_copy_after, BuiltinNumericT // Can't do this today because we can't do cross-system with explicit policies. #endif - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC diff --git a/projects/rocthrust/testing/async_for_each.cu b/projects/rocthrust/testing/async_for_each.cu index e8a50b493140..95ac9acc2521 100644 --- a/projects/rocthrust/testing/async_for_each.cu +++ b/projects/rocthrust/testing/async_for_each.cu @@ -25,8 +25,6 @@ # include -THRUST_SUPPRESS_DEPRECATED_PUSH - # define DEFINE_ASYNC_FOR_EACH_CALLABLE(name, ...) \ struct THRUST_PP_CAT2(name, _fn) \ { \ @@ -40,6 +38,7 @@ THRUST_SUPPRESS_DEPRECATED_PUSH /**/ DEFINE_ASYNC_FOR_EACH_CALLABLE(invoke_async_for_each); + DEFINE_ASYNC_FOR_EACH_CALLABLE(invoke_async_for_each_device, thrust::device); # undef DEFINE_ASYNC_FOR_EACH_CALLABLE diff --git a/projects/rocthrust/testing/async_reduce.cu b/projects/rocthrust/testing/async_reduce.cu index c57ad756671d..7f011f575c17 100644 --- a/projects/rocthrust/testing/async_reduce.cu +++ b/projects/rocthrust/testing/async_reduce.cu @@ -19,9 +19,6 @@ #include -// need to suppress deprecation warnings inside several thrust headers -THRUST_SUPPRESS_DEPRECATED_PUSH - #if THRUST_CPP_DIALECT >= 2017 # include @@ -921,8 +918,3 @@ struct test_async_reduce_bug1886 DECLARE_UNITTEST(test_async_reduce_bug1886); #endif - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC diff --git a/projects/rocthrust/testing/async_reduce_into.cu b/projects/rocthrust/testing/async_reduce_into.cu index 6ae3b9376780..9c3e24f6e3df 100644 --- a/projects/rocthrust/testing/async_reduce_into.cu +++ b/projects/rocthrust/testing/async_reduce_into.cu @@ -30,8 +30,6 @@ # include # include -THRUST_SUPPRESS_DEPRECATED_PUSH - template struct custom_plus { diff --git a/projects/rocthrust/testing/async_sort.cu b/projects/rocthrust/testing/async_sort.cu index 198fe4783f1b..a7281d3becd9 100644 --- a/projects/rocthrust/testing/async_sort.cu +++ b/projects/rocthrust/testing/async_sort.cu @@ -17,9 +17,6 @@ #include -// need to suppress deprecation warnings inside a lot of thrust headers -THRUST_SUPPRESS_DEPRECATED_PUSH - // Disabled on MSVC && NVCC < 11.1 for GH issue #1098. #if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && defined(__CUDACC__) # if (__CUDACC_VER_MAJOR__ < 11) || (__CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ < 1) @@ -195,8 +192,3 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES_AND_NAME( // TODO: Test future return type. #endif - -// we need to leak the suppression on clang/MSVC to suppresses warnings from the cudafe1.stub.c file -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_CLANG && THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC diff --git a/projects/rocthrust/testing/async_transform.cu b/projects/rocthrust/testing/async_transform.cu index 6b5fe54bda18..fdbd604c4559 100644 --- a/projects/rocthrust/testing/async_transform.cu +++ b/projects/rocthrust/testing/async_transform.cu @@ -27,8 +27,6 @@ # include # include -THRUST_SUPPRESS_DEPRECATED_PUSH - template struct divide_by_2 { @@ -430,16 +428,12 @@ struct test_async_transform_using // When you import the customization points into the global namespace, // they should be selected instead of the synchronous algorithms. { - THRUST_SUPPRESS_DEPRECATED_PUSH using namespace thrust::async; f0a = transform(d0a.begin(), d0a.end(), d1a.begin(), op); - THRUST_SUPPRESS_DEPRECATED_POP } { - THRUST_SUPPRESS_DEPRECATED_PUSH using thrust::async::transform; f0b = transform(d0b.begin(), d0b.end(), d1b.begin(), op); - THRUST_SUPPRESS_DEPRECATED_POP } // ADL should find the synchronous algorithms. diff --git a/projects/rocthrust/testing/cuda/adjacent_difference.cu b/projects/rocthrust/testing/cuda/adjacent_difference.cu index 842c82ef276a..96c4486588e9 100644 --- a/projects/rocthrust/testing/cuda/adjacent_difference.cu +++ b/projects/rocthrust/testing/cuda/adjacent_difference.cu @@ -116,7 +116,7 @@ struct detect_wrong_difference using value_type = void; using pointer = void; using reference = void; - using iterator_category = ::cuda::std::output_iterator_tag; + using iterator_category = std::output_iterator_tag; bool* flag; diff --git a/projects/rocthrust/testing/cuda/copy_if.cu b/projects/rocthrust/testing/cuda/copy_if.cu index 1d6793496644..6a8e650226fb 100644 --- a/projects/rocthrust/testing/cuda/copy_if.cu +++ b/projects/rocthrust/testing/cuda/copy_if.cu @@ -25,7 +25,7 @@ template struct is_even { - _CCCL_HOST_DEVICE bool operator()(T x) + THRUST_HOST_DEVICE bool operator()(T x) { return (static_cast(x) & 1) == 0; } @@ -34,7 +34,7 @@ struct is_even template struct mod_3 { - _CCCL_HOST_DEVICE unsigned int operator()(T x) + THRUST_HOST_DEVICE unsigned int operator()(T x) { return static_cast(x) % 3; } @@ -44,7 +44,7 @@ template struct mod_n { T mod; - _CCCL_HOST_DEVICE bool operator()(T x) + THRUST_HOST_DEVICE bool operator()(T x) { return (x % mod == 0) ? true : false; } @@ -54,7 +54,7 @@ template struct multiply_n { T multiplier; - _CCCL_HOST_DEVICE T operator()(T x) + THRUST_HOST_DEVICE T operator()(T x) { return x * multiplier; } @@ -144,8 +144,14 @@ void TestCopyIfCudaStreams(ExecutionPolicy policy) { using Vector = thrust::device_vector; - Vector data{1, 2, 1, 3, 2}; - Vector result(data.size()); + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; + + Vector result(5); cudaStream_t s; cudaStreamCreate(&s); @@ -153,9 +159,9 @@ void TestCopyIfCudaStreams(ExecutionPolicy policy) Vector::iterator end = thrust::copy_if(policy.on(s), data.begin(), data.end(), result.begin(), is_even()); ASSERT_EQUAL(end - result.begin(), 2); - result.resize(end - result.begin()); - Vector ref{2, 2}; - ASSERT_EQUAL(result, ref); + + ASSERT_EQUAL(result[0], 2); + ASSERT_EQUAL(result[1], 2); cudaStreamDestroy(s); } @@ -273,23 +279,32 @@ void TestCopyIfStencilCudaStreams(ExecutionPolicy policy) using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; Vector result(5); - Vector stencil{0, 1, 0, 0, 1}; + Vector stencil(5); + stencil[0] = 0; + stencil[1] = 1; + stencil[2] = 0; + stencil[3] = 0; + stencil[4] = 1; cudaStream_t s; cudaStreamCreate(&s); Vector::iterator end = - thrust::copy_if(policy.on(s), data.begin(), data.end(), stencil.begin(), result.begin(), ::cuda::std::identity{}); + thrust::copy_if(policy.on(s), data.begin(), data.end(), stencil.begin(), result.begin(), thrust::identity()); ASSERT_EQUAL(end - result.begin(), 2); - result.resize(end - result.begin()); - Vector ref{2, 2}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 2); + ASSERT_EQUAL(result[1], 2); cudaStreamDestroy(s); } diff --git a/projects/rocthrust/testing/cuda/is_partitioned.cu b/projects/rocthrust/testing/cuda/is_partitioned.cu index 9b1c6d837c5e..1b45eba8a5ea 100644 --- a/projects/rocthrust/testing/cuda/is_partitioned.cu +++ b/projects/rocthrust/testing/cuda/is_partitioned.cu @@ -32,7 +32,7 @@ is_partitioned_kernel(ExecutionPolicy exec, Iterator first, Iterator last, Predi template struct is_even { - _CCCL_HOST_DEVICE bool operator()(T x) const + THRUST_HOST_DEVICE bool operator()(T x) const { return ((int) x % 2) == 0; } @@ -97,23 +97,23 @@ void TestIsPartitionedCudaStreams() // empty partition ASSERT_EQUAL_QUIET(true, - thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.begin(), ::cuda::std::identity{})); + thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.begin(), thrust::identity())); // one element true partition ASSERT_EQUAL_QUIET( - true, thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.begin() + 1, ::cuda::std::identity{})); + true, thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.begin() + 1, thrust::identity())); // just true partition ASSERT_EQUAL_QUIET( - true, thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.begin() + 2, ::cuda::std::identity{})); + true, thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.begin() + 2, thrust::identity())); // both true & false partitions ASSERT_EQUAL_QUIET(true, - thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{})); + thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity())); // one element false partition ASSERT_EQUAL_QUIET(true, - thrust::is_partitioned(thrust::cuda::par.on(s), v.begin() + 3, v.end(), ::cuda::std::identity{})); + thrust::is_partitioned(thrust::cuda::par.on(s), v.begin() + 3, v.end(), thrust::identity())); v[0] = 1; v[1] = 0; @@ -122,7 +122,7 @@ void TestIsPartitionedCudaStreams() // not partitioned ASSERT_EQUAL_QUIET(false, - thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{})); + thrust::is_partitioned(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity())); cudaStreamDestroy(s); } diff --git a/projects/rocthrust/testing/cuda/logical.cu b/projects/rocthrust/testing/cuda/logical.cu index 8dcd79ef6382..6237c23d0eba 100644 --- a/projects/rocthrust/testing/cuda/logical.cu +++ b/projects/rocthrust/testing/cuda/logical.cu @@ -35,7 +35,7 @@ void TestAllOfDevice(ExecutionPolicy exec) thrust::device_vector v(3, 1); thrust::device_vector result(1); - all_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}, result.begin()); + all_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -45,7 +45,7 @@ void TestAllOfDevice(ExecutionPolicy exec) v[1] = 0; - all_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}, result.begin()); + all_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -53,7 +53,7 @@ void TestAllOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(false, result[0]); - all_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 0, ::cuda::std::identity{}, result.begin()); + all_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 0, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -61,7 +61,7 @@ void TestAllOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(true, result[0]); - all_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 1, ::cuda::std::identity{}, result.begin()); + all_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 1, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -69,7 +69,7 @@ void TestAllOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(true, result[0]); - all_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 2, ::cuda::std::identity{}, result.begin()); + all_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 2, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -77,7 +77,7 @@ void TestAllOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(false, result[0]); - all_of_kernel<<<1, 1>>>(exec, v.begin() + 1, v.begin() + 2, ::cuda::std::identity{}, result.begin()); + all_of_kernel<<<1, 1>>>(exec, v.begin() + 1, v.begin() + 2, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -109,16 +109,16 @@ void TestAllOfCudaStreams() cudaStream_t s; cudaStreamCreate(&s); - ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}), true); + ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()), true); v[1] = 0; - ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}), false); + ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()), false); - ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 0, ::cuda::std::identity{}), true); - ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 1, ::cuda::std::identity{}), true); - ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 2, ::cuda::std::identity{}), false); - ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 1, v.begin() + 2, ::cuda::std::identity{}), false); + ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 0, thrust::identity()), true); + ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 1, thrust::identity()), true); + ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 2, thrust::identity()), false); + ASSERT_EQUAL(thrust::all_of(thrust::cuda::par.on(s), v.begin() + 1, v.begin() + 2, thrust::identity()), false); cudaStreamDestroy(s); } @@ -139,7 +139,7 @@ void TestAnyOfDevice(ExecutionPolicy exec) thrust::device_vector v(3, 1); thrust::device_vector result(1); - any_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}, result.begin()); + any_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -149,7 +149,7 @@ void TestAnyOfDevice(ExecutionPolicy exec) v[1] = 0; - any_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}, result.begin()); + any_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -157,7 +157,7 @@ void TestAnyOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(true, result[0]); - any_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 0, ::cuda::std::identity{}, result.begin()); + any_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 0, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -165,7 +165,7 @@ void TestAnyOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(false, result[0]); - any_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 1, ::cuda::std::identity{}, result.begin()); + any_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 1, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -173,7 +173,7 @@ void TestAnyOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(true, result[0]); - any_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 2, ::cuda::std::identity{}, result.begin()); + any_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 2, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -181,7 +181,7 @@ void TestAnyOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(true, result[0]); - any_of_kernel<<<1, 1>>>(exec, v.begin() + 1, v.begin() + 2, ::cuda::std::identity{}, result.begin()); + any_of_kernel<<<1, 1>>>(exec, v.begin() + 1, v.begin() + 2, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -213,16 +213,16 @@ void TestAnyOfCudaStreams() cudaStream_t s; cudaStreamCreate(&s); - ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}), true); + ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()), true); v[1] = 0; - ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}), true); + ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()), true); - ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 0, ::cuda::std::identity{}), false); - ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 1, ::cuda::std::identity{}), true); - ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 2, ::cuda::std::identity{}), true); - ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 1, v.begin() + 2, ::cuda::std::identity{}), false); + ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 0, thrust::identity()), false); + ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 1, thrust::identity()), true); + ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 2, thrust::identity()), true); + ASSERT_EQUAL(thrust::any_of(thrust::cuda::par.on(s), v.begin() + 1, v.begin() + 2, thrust::identity()), false); cudaStreamDestroy(s); } @@ -243,7 +243,7 @@ void TestNoneOfDevice(ExecutionPolicy exec) thrust::device_vector v(3, 1); thrust::device_vector result(1); - none_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}, result.begin()); + none_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -253,7 +253,7 @@ void TestNoneOfDevice(ExecutionPolicy exec) v[1] = 0; - none_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}, result.begin()); + none_of_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -261,7 +261,7 @@ void TestNoneOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(false, result[0]); - none_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 0, ::cuda::std::identity{}, result.begin()); + none_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 0, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -269,7 +269,7 @@ void TestNoneOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(true, result[0]); - none_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 1, ::cuda::std::identity{}, result.begin()); + none_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 1, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -277,7 +277,7 @@ void TestNoneOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(false, result[0]); - none_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 2, ::cuda::std::identity{}, result.begin()); + none_of_kernel<<<1, 1>>>(exec, v.begin() + 0, v.begin() + 2, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -285,7 +285,7 @@ void TestNoneOfDevice(ExecutionPolicy exec) ASSERT_EQUAL(false, result[0]); - none_of_kernel<<<1, 1>>>(exec, v.begin() + 1, v.begin() + 2, ::cuda::std::identity{}, result.begin()); + none_of_kernel<<<1, 1>>>(exec, v.begin() + 1, v.begin() + 2, thrust::identity(), result.begin()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -317,16 +317,16 @@ void TestNoneOfCudaStreams() cudaStream_t s; cudaStreamCreate(&s); - ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}), false); + ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()), false); v[1] = 0; - ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}), false); + ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()), false); - ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 0, ::cuda::std::identity{}), true); - ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 1, ::cuda::std::identity{}), false); - ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 2, ::cuda::std::identity{}), false); - ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 1, v.begin() + 2, ::cuda::std::identity{}), true); + ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 0, thrust::identity()), true); + ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 1, thrust::identity()), false); + ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 0, v.begin() + 2, thrust::identity()), false); + ASSERT_EQUAL(thrust::none_of(thrust::cuda::par.on(s), v.begin() + 1, v.begin() + 2, thrust::identity()), true); cudaStreamDestroy(s); } diff --git a/projects/rocthrust/testing/cuda/mismatch.cu b/projects/rocthrust/testing/cuda/mismatch.cu index ae2b929da77a..bce6e456350c 100644 --- a/projects/rocthrust/testing/cuda/mismatch.cu +++ b/projects/rocthrust/testing/cuda/mismatch.cu @@ -31,8 +31,16 @@ mismatch_kernel(ExecutionPolicy exec, Iterator1 first1, Iterator1 last1, Iterato template void TestMismatchDevice(ExecutionPolicy exec) { - thrust::device_vector a = {1, 2, 3, 4}; - thrust::device_vector b = {1, 2, 4, 3}; + thrust::device_vector a(4); + thrust::device_vector b(4); + a[0] = 1; + b[0] = 1; + a[1] = 2; + b[1] = 2; + a[2] = 3; + b[2] = 4; + a[3] = 4; + b[3] = 3; using pair_type = thrust::pair::iterator, typename thrust::device_vector::iterator>; @@ -88,8 +96,16 @@ void TestMismatchCudaStreams() { using Vector = thrust::device_vector; - Vector a = {1, 2, 3, 4}; - Vector b = {1, 2, 4, 3}; + Vector a(4); + Vector b(4); + a[0] = 1; + b[0] = 1; + a[1] = 2; + b[1] = 2; + a[2] = 3; + b[2] = 4; + a[3] = 4; + b[3] = 3; cudaStream_t s; cudaStreamCreate(&s); @@ -110,36 +126,3 @@ void TestMismatchCudaStreams() cudaStreamDestroy(s); } DECLARE_UNITTEST(TestMismatchCudaStreams); - -// see https://github.com/NVIDIA/cccl/issues/3591 -template -class Wrapper -{ -public: - Wrapper() - { - ++my_count; - } - - _CCCL_HOST_DEVICE bool operator==(const Wrapper& input) const - { - return true; - } - - ~Wrapper() - { - --my_count; - } - -private: - static std::atomic my_count; - T dummy; -}; - -void TestMismatchBug3591() -{ - using T = Wrapper; - T* p = nullptr; - thrust::mismatch(thrust::device, p, p, p, cuda::std::equal_to()); -} -DECLARE_UNITTEST(TestMismatchBug3591); diff --git a/projects/rocthrust/testing/cuda/partition_point.cu b/projects/rocthrust/testing/cuda/partition_point.cu index 0ba20894c0f8..75e64bfb09bf 100644 --- a/projects/rocthrust/testing/cuda/partition_point.cu +++ b/projects/rocthrust/testing/cuda/partition_point.cu @@ -32,7 +32,7 @@ partition_point_kernel(ExecutionPolicy exec, Iterator1 first, Iterator1 last, Pr template struct is_even { - _CCCL_HOST_DEVICE bool operator()(T x) const + THRUST_HOST_DEVICE bool operator()(T x) const { return ((int) x % 2) == 0; } @@ -88,11 +88,11 @@ void TestPartitionPointCudaStreams() cudaStream_t s; cudaStreamCreate(&s); - ASSERT_EQUAL_QUIET(ref, thrust::partition_point(thrust::cuda::par.on(s), first, last, ::cuda::std::identity{})); + ASSERT_EQUAL_QUIET(ref, thrust::partition_point(thrust::cuda::par.on(s), first, last, thrust::identity())); last = v.begin() + 3; ref = last; - ASSERT_EQUAL_QUIET(ref, thrust::partition_point(thrust::cuda::par.on(s), first, last, ::cuda::std::identity{})); + ASSERT_EQUAL_QUIET(ref, thrust::partition_point(thrust::cuda::par.on(s), first, last, thrust::identity())); cudaStreamDestroy(s); } diff --git a/projects/rocthrust/testing/cuda/remove.cu b/projects/rocthrust/testing/cuda/remove.cu index dc7160efa4ec..5a7cc3ffa758 100644 --- a/projects/rocthrust/testing/cuda/remove.cu +++ b/projects/rocthrust/testing/cuda/remove.cu @@ -76,7 +76,7 @@ __global__ void remove_copy_if_kernel( template struct is_even { - _CCCL_HOST_DEVICE bool operator()(T x) + THRUST_HOST_DEVICE bool operator()(T x) { return (static_cast(x) & 1) == 0; } @@ -85,7 +85,7 @@ struct is_even template struct is_true { - _CCCL_HOST_DEVICE bool operator()(T x) + THRUST_HOST_DEVICE bool operator()(T x) { return x ? true : false; } @@ -346,7 +346,12 @@ void TestRemoveCudaStreams() using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; cudaStream_t s; cudaStreamCreate(&s); @@ -354,10 +359,10 @@ void TestRemoveCudaStreams() Vector::iterator end = thrust::remove(thrust::cuda::par.on(s), data.begin(), data.end(), (T) 2); ASSERT_EQUAL(end - data.begin(), 3); - data.erase(end, data.end()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(data, ref); + ASSERT_EQUAL(data[0], 1); + ASSERT_EQUAL(data[1], 1); + ASSERT_EQUAL(data[2], 3); cudaStreamDestroy(s); } @@ -368,7 +373,12 @@ void TestRemoveCopyCudaStreams() using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; Vector result(5); @@ -378,10 +388,10 @@ void TestRemoveCopyCudaStreams() Vector::iterator end = thrust::remove_copy(thrust::cuda::par.on(s), data.begin(), data.end(), result.begin(), (T) 2); ASSERT_EQUAL(end - result.begin(), 3); - result.erase(end, result.end()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 1); + ASSERT_EQUAL(result[1], 1); + ASSERT_EQUAL(result[2], 3); cudaStreamDestroy(s); } @@ -392,7 +402,12 @@ void TestRemoveIfCudaStreams() using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; cudaStream_t s; cudaStreamCreate(&s); @@ -400,10 +415,10 @@ void TestRemoveIfCudaStreams() Vector::iterator end = thrust::remove_if(thrust::cuda::par.on(s), data.begin(), data.end(), is_even()); ASSERT_EQUAL(end - data.begin(), 3); - data.erase(end, data.end()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(data, ref); + ASSERT_EQUAL(data[0], 1); + ASSERT_EQUAL(data[1], 1); + ASSERT_EQUAL(data[2], 3); cudaStreamDestroy(s); } @@ -414,21 +429,31 @@ void TestRemoveIfStencilCudaStreams() using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; - Vector stencil{0, 1, 0, 0, 1}; + Vector stencil(5); + stencil[0] = 0; + stencil[1] = 1; + stencil[2] = 0; + stencil[3] = 0; + stencil[4] = 1; cudaStream_t s; cudaStreamCreate(&s); Vector::iterator end = - thrust::remove_if(thrust::cuda::par.on(s), data.begin(), data.end(), stencil.begin(), ::cuda::std::identity{}); + thrust::remove_if(thrust::cuda::par.on(s), data.begin(), data.end(), stencil.begin(), thrust::identity()); ASSERT_EQUAL(end - data.begin(), 3); - data.erase(end, data.end()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(data, ref); + ASSERT_EQUAL(data[0], 1); + ASSERT_EQUAL(data[1], 1); + ASSERT_EQUAL(data[2], 3); cudaStreamDestroy(s); } @@ -439,7 +464,12 @@ void TestRemoveCopyIfCudaStreams() using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; Vector result(5); @@ -450,10 +480,10 @@ void TestRemoveCopyIfCudaStreams() thrust::remove_copy_if(thrust::cuda::par.on(s), data.begin(), data.end(), result.begin(), is_even()); ASSERT_EQUAL(end - result.begin(), 3); - result.erase(end, result.end()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 1); + ASSERT_EQUAL(result[1], 1); + ASSERT_EQUAL(result[2], 3); cudaStreamDestroy(s); } @@ -464,9 +494,19 @@ void TestRemoveCopyIfStencilCudaStreams() using Vector = thrust::device_vector; using T = Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; - Vector stencil{0, 1, 0, 0, 1}; + Vector stencil(5); + stencil[0] = 0; + stencil[1] = 1; + stencil[2] = 0; + stencil[3] = 0; + stencil[4] = 1; Vector result(5); @@ -474,13 +514,13 @@ void TestRemoveCopyIfStencilCudaStreams() cudaStreamCreate(&s); Vector::iterator end = thrust::remove_copy_if( - thrust::cuda::par.on(s), data.begin(), data.end(), stencil.begin(), result.begin(), ::cuda::std::identity{}); + thrust::cuda::par.on(s), data.begin(), data.end(), stencil.begin(), result.begin(), thrust::identity()); ASSERT_EQUAL(end - result.begin(), 3); - result.erase(end, result.end()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 1); + ASSERT_EQUAL(result[1], 1); + ASSERT_EQUAL(result[2], 3); cudaStreamDestroy(s); } diff --git a/projects/rocthrust/testing/cuda/tabulate.cu b/projects/rocthrust/testing/cuda/tabulate.cu index 504b1a9ae112..12fb3c8161d6 100644 --- a/projects/rocthrust/testing/cuda/tabulate.cu +++ b/projects/rocthrust/testing/cuda/tabulate.cu @@ -37,14 +37,17 @@ void TestTabulateDevice(ExecutionPolicy exec) Vector v(5); - tabulate_kernel<<<1, 1>>>(exec, v.begin(), v.end(), ::cuda::std::identity{}); + tabulate_kernel<<<1, 1>>>(exec, v.begin(), v.end(), thrust::identity()); { cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); } - Vector ref{0, 1, 2, 3, 4}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], 1); + ASSERT_EQUAL(v[2], 2); + ASSERT_EQUAL(v[3], 3); + ASSERT_EQUAL(v[4], 4); tabulate_kernel<<<1, 1>>>(exec, v.begin(), v.end(), -_1); { @@ -52,8 +55,11 @@ void TestTabulateDevice(ExecutionPolicy exec) ASSERT_EQUAL(cudaSuccess, err); } - ref = {0, -1, -2, -3, -4}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], -1); + ASSERT_EQUAL(v[2], -2); + ASSERT_EQUAL(v[3], -3); + ASSERT_EQUAL(v[4], -4); tabulate_kernel<<<1, 1>>>(exec, v.begin(), v.end(), _1 * _1 * _1); { @@ -61,8 +67,11 @@ void TestTabulateDevice(ExecutionPolicy exec) ASSERT_EQUAL(cudaSuccess, err); } - ref = {0, 1, 8, 27, 64}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], 1); + ASSERT_EQUAL(v[2], 8); + ASSERT_EQUAL(v[3], 27); + ASSERT_EQUAL(v[4], 64); } void TestTabulateDeviceSeq() @@ -89,23 +98,32 @@ void TestTabulateCudaStreams() cudaStream_t s; cudaStreamCreate(&s); - thrust::tabulate(thrust::cuda::par.on(s), v.begin(), v.end(), ::cuda::std::identity{}); + thrust::tabulate(thrust::cuda::par.on(s), v.begin(), v.end(), thrust::identity()); cudaStreamSynchronize(s); - Vector ref{0, 1, 2, 3, 4}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], 1); + ASSERT_EQUAL(v[2], 2); + ASSERT_EQUAL(v[3], 3); + ASSERT_EQUAL(v[4], 4); thrust::tabulate(thrust::cuda::par.on(s), v.begin(), v.end(), -_1); cudaStreamSynchronize(s); - ref = {0, -1, -2, -3, -4}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], -1); + ASSERT_EQUAL(v[2], -2); + ASSERT_EQUAL(v[3], -3); + ASSERT_EQUAL(v[4], -4); thrust::tabulate(thrust::cuda::par.on(s), v.begin(), v.end(), _1 * _1 * _1); cudaStreamSynchronize(s); - ref = {0, 1, 8, 27, 64}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], 1); + ASSERT_EQUAL(v[2], 8); + ASSERT_EQUAL(v[3], 27); + ASSERT_EQUAL(v[4], 64); cudaStreamSynchronize(s); } diff --git a/projects/rocthrust/testing/cuda/transform.cu b/projects/rocthrust/testing/cuda/transform.cu index 63d9bf81b324..eecb02608e27 100644 --- a/projects/rocthrust/testing/cuda/transform.cu +++ b/projects/rocthrust/testing/cuda/transform.cu @@ -97,7 +97,7 @@ void TestTransformIfUnaryNoStencilDevice(ExecutionPolicy exec) thrust::device_vector iter_vec(1); transform_if_kernel<<<1, 1>>>( - exec, input.begin(), input.end(), output.begin(), thrust::negate(), ::cuda::std::identity{}, iter_vec.begin()); + exec, input.begin(), input.end(), output.begin(), thrust::negate(), thrust::identity(), iter_vec.begin()); cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -161,7 +161,7 @@ void TestTransformIfUnaryDevice(ExecutionPolicy exec) stencil.begin(), output.begin(), thrust::negate(), - ::cuda::std::identity{}, + thrust::identity(), iter_vec.begin()); cudaError_t const err = cudaDeviceSynchronize(); ASSERT_EQUAL(cudaSuccess, err); @@ -276,7 +276,7 @@ void TestTransformIfBinaryDevice(ExecutionPolicy exec) Vector output{1, 2, 3}; Vector result{5, 2, -3}; - ::cuda::std::identity identity; + thrust::identity identity; thrust::device_vector iter_vec(1); diff --git a/projects/rocthrust/testing/cuda/transform_scan.cu b/projects/rocthrust/testing/cuda/transform_scan.cu index c322a671ee6a..a7f4593e56b5 100644 --- a/projects/rocthrust/testing/cuda/transform_scan.cu +++ b/projects/rocthrust/testing/cuda/transform_scan.cu @@ -305,8 +305,7 @@ void TestTransformScanConstAccumulator() Vector reference(5); Vector output(5); - thrust::transform_inclusive_scan( - input.begin(), input.end(), output.begin(), ::cuda::std::identity{}, thrust::plus()); + thrust::transform_inclusive_scan(input.begin(), input.end(), output.begin(), thrust::identity(), thrust::plus()); thrust::inclusive_scan(input.begin(), input.end(), reference.begin(), thrust::plus()); ASSERT_EQUAL(output, reference); diff --git a/projects/rocthrust/testing/dependencies_aware_policies.cu b/projects/rocthrust/testing/dependencies_aware_policies.cu index 3153ef825aa2..0ad6e923acdc 100644 --- a/projects/rocthrust/testing/dependencies_aware_policies.cu +++ b/projects/rocthrust/testing/dependencies_aware_policies.cu @@ -17,9 +17,6 @@ #include -// need to suppress deprecation warnings for execute_with_allocator_and_dependencies inside type traits -THRUST_SUPPRESS_DEPRECATED_PUSH - #include #include #include @@ -129,5 +126,3 @@ SimpleUnitTest> TestDependencyAttachmentInstance; - -THRUST_SUPPRESS_DEPRECATED_POP diff --git a/projects/rocthrust/testing/dereference.cu b/projects/rocthrust/testing/dereference.cu index a3c5d7430839..93c1c3ca044b 100644 --- a/projects/rocthrust/testing/dereference.cu +++ b/projects/rocthrust/testing/dereference.cu @@ -73,8 +73,8 @@ void TestDeviceDereferenceTransformIterator() thrust::device_vector input = unittest::random_integers(100); thrust::device_vector output(input.size(), 0); - simple_copy(thrust::make_transform_iterator(input.begin(), ::internal::identity{}), - thrust::make_transform_iterator(input.end(), ::internal::identity{}), + simple_copy(thrust::make_transform_iterator(input.begin(), thrust::identity()), + thrust::make_transform_iterator(input.end(), thrust::identity()), output.begin()); ASSERT_EQUAL(input, output); @@ -86,8 +86,8 @@ void TestDeviceDereferenceTransformIteratorInputConversion() thrust::device_vector input = unittest::random_integers(100); thrust::device_vector output(input.size(), 0); - simple_copy(thrust::make_transform_iterator(input.begin(), ::internal::identity{}), - thrust::make_transform_iterator(input.end(), ::internal::identity{}), + simple_copy(thrust::make_transform_iterator(input.begin(), thrust::identity()), + thrust::make_transform_iterator(input.end(), thrust::identity()), output.begin()); ASSERT_EQUAL(input == output, true); @@ -99,8 +99,8 @@ void TestDeviceDereferenceTransformIteratorOutputConversion() thrust::device_vector input = unittest::random_integers(100); thrust::device_vector output(input.size(), 0); - simple_copy(thrust::make_transform_iterator(input.begin(), ::internal::identity{}), - thrust::make_transform_iterator(input.end(), ::internal::identity{}), + simple_copy(thrust::make_transform_iterator(input.begin(), thrust::identity()), + thrust::make_transform_iterator(input.end(), thrust::identity()), output.begin()); ASSERT_EQUAL(input == output, true); diff --git a/projects/rocthrust/testing/event.cu b/projects/rocthrust/testing/event.cu index 1beaa60cedd2..c4a99103bff6 100644 --- a/projects/rocthrust/testing/event.cu +++ b/projects/rocthrust/testing/event.cu @@ -24,10 +24,6 @@ # include # include -// note: there is no matching THRUST_SUPPRESS_DEPRECATED_POP, so the warning suppression leaks into more content of the -// generated cudafe1.stub.c file. -THRUST_SUPPRESS_DEPRECATED_PUSH - /////////////////////////////////////////////////////////////////////////////// THRUST_HOST void test_event_default_constructed() diff --git a/projects/rocthrust/testing/find.cu b/projects/rocthrust/testing/find.cu index 7e13062522e4..2d9001d81db4 100644 --- a/projects/rocthrust/testing/find.cu +++ b/projects/rocthrust/testing/find.cu @@ -16,7 +16,6 @@ */ #include -#include #include #include @@ -68,9 +67,14 @@ struct less_than_value_pred }; template -void TestFindSimple() +void TestFindSimple(void) { - Vector vec{1, 2, 3, 3, 5}; + Vector vec(5); + vec[0] = 1; + vec[1] = 2; + vec[2] = 3; + vec[3] = 3; + vec[4] = 5; ASSERT_EQUAL(thrust::find(vec.begin(), vec.end(), 0) - vec.begin(), 5); ASSERT_EQUAL(thrust::find(vec.begin(), vec.end(), 1) - vec.begin(), 0); @@ -117,11 +121,16 @@ void TestFindDispatchImplicit() DECLARE_UNITTEST(TestFindDispatchImplicit); template -void TestFindIfSimple() +void TestFindIfSimple(void) { using T = typename Vector::value_type; - Vector vec{1, 2, 3, 3, 5}; + Vector vec(5); + vec[0] = 1; + vec[1] = 2; + vec[2] = 3; + vec[3] = 3; + vec[4] = 5; ASSERT_EQUAL(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(0)) - vec.begin(), 5); ASSERT_EQUAL(thrust::find_if(vec.begin(), vec.end(), equal_to_value_pred(1)) - vec.begin(), 0); @@ -144,7 +153,7 @@ void TestFindIfDispatchExplicit() thrust::device_vector vec(1); my_system sys(0); - thrust::find_if(sys, vec.begin(), vec.end(), ::internal::identity{}); + thrust::find_if(sys, vec.begin(), vec.end(), thrust::identity()); ASSERT_EQUAL(true, sys.is_valid()); } @@ -161,18 +170,23 @@ void TestFindIfDispatchImplicit() { thrust::device_vector vec(1); - thrust::find_if(thrust::retag(vec.begin()), thrust::retag(vec.end()), ::internal::identity{}); + thrust::find_if(thrust::retag(vec.begin()), thrust::retag(vec.end()), thrust::identity()); ASSERT_EQUAL(13, vec.front()); } DECLARE_UNITTEST(TestFindIfDispatchImplicit); template -void TestFindIfNotSimple() +void TestFindIfNotSimple(void) { using T = typename Vector::value_type; - Vector vec{0, 1, 2, 3, 4}; + Vector vec(5); + vec[0] = 0; + vec[1] = 1; + vec[2] = 2; + vec[3] = 3; + vec[4] = 4; ASSERT_EQUAL(0, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(0)) - vec.begin()); ASSERT_EQUAL(1, thrust::find_if_not(vec.begin(), vec.end(), less_than_value_pred(1)) - vec.begin()); @@ -195,7 +209,7 @@ void TestFindIfNotDispatchExplicit() thrust::device_vector vec(1); my_system sys(0); - thrust::find_if_not(sys, vec.begin(), vec.end(), ::internal::identity{}); + thrust::find_if_not(sys, vec.begin(), vec.end(), thrust::identity()); ASSERT_EQUAL(true, sys.is_valid()); } @@ -212,7 +226,7 @@ void TestFindIfNotDispatchImplicit() { thrust::device_vector vec(1); - thrust::find_if_not(thrust::retag(vec.begin()), thrust::retag(vec.end()), ::internal::identity{}); + thrust::find_if_not(thrust::retag(vec.begin()), thrust::retag(vec.end()), thrust::identity()); ASSERT_EQUAL(13, vec.front()); } diff --git a/projects/rocthrust/testing/functional.cu b/projects/rocthrust/testing/functional.cu index d0cb6b41a25b..fec5dfda6977 100644 --- a/projects/rocthrust/testing/functional.cu +++ b/projects/rocthrust/testing/functional.cu @@ -212,7 +212,6 @@ typename _THRUST_STD::add_const<_Tp>::type& as_const(_Tp& __t) noexcept // Ad-hoc testing for other functionals THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestIdentityFunctional() { - THRUST_SUPPRESS_DEPRECATED_PUSH int i = 42; double d = 3.14; @@ -242,16 +241,16 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestIdentityFunctional() static_assert(_THRUST_STD::is_same{}(_THRUST_STD::move(d))), int&&>::value, ""); static_assert(_THRUST_STD::is_same{}(static_cast(d))), int&&>::value, ""); - THRUST_SUPPRESS_DEPRECATED_POP } DECLARE_UNITTEST(TestIdentityFunctional); template THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestIdentityFunctionalVector() { + using T = typename Vector::value_type; Vector input{0, 1, 2, 3}; Vector output(4); - thrust::transform(input.begin(), input.end(), output.begin(), ::internal::identity{}); + thrust::transform(input.begin(), input.end(), output.begin(), thrust::identity()); ASSERT_EQUAL(input, output); } DECLARE_VECTOR_UNITTEST(TestIdentityFunctionalVector); @@ -325,11 +324,13 @@ DECLARE_VECTOR_UNITTEST(TestMinimumFunctional); template THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestNot1() { + using T = typename Vector::value_type; + Vector input{1, 0, 1, 1, 0}; Vector output(5); - thrust::transform(input.begin(), input.end(), output.begin(), thrust::not_fn(::internal::identity{})); + thrust::transform(input.begin(), input.end(), output.begin(), thrust::not_fn(thrust::identity())); Vector ref{0, 1, 0, 0, 1}; ASSERT_EQUAL(output, ref); diff --git a/projects/rocthrust/testing/future.cu b/projects/rocthrust/testing/future.cu index 5b24debcaebf..8f52e4bed0cd 100644 --- a/projects/rocthrust/testing/future.cu +++ b/projects/rocthrust/testing/future.cu @@ -24,10 +24,6 @@ # include # include -// note: there is no matching THRUST_SUPPRESS_DEPRECATED_POP, so the warning suppression leaks into more content of the -// generated cudafe1.stub.c file. -THRUST_SUPPRESS_DEPRECATED_PUSH - struct mock {}; diff --git a/projects/rocthrust/testing/is_partitioned.cu b/projects/rocthrust/testing/is_partitioned.cu index 0a92b45ea108..51ea983ac72a 100644 --- a/projects/rocthrust/testing/is_partitioned.cu +++ b/projects/rocthrust/testing/is_partitioned.cu @@ -31,34 +31,43 @@ struct is_even }; template -void TestIsPartitionedSimple() +void TestIsPartitionedSimple(void) { - Vector v{1, 1, 1, 0}; + using T = typename Vector::value_type; + + Vector v(4); + v[0] = 1; + v[1] = 1; + v[2] = 1; + v[3] = 0; // empty partition - ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.begin(), ::internal::identity{})); + ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.begin(), thrust::identity())); // one element true partition - ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 1, ::internal::identity{})); + ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 1, thrust::identity())); // just true partition - ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 2, ::internal::identity{})); + ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.begin() + 2, thrust::identity())); // both true & false partitions - ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.end(), ::internal::identity{})); + ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin(), v.end(), thrust::identity())); // one element false partition - ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin() + 3, v.end(), ::internal::identity{})); + ASSERT_EQUAL_QUIET(true, thrust::is_partitioned(v.begin() + 3, v.end(), thrust::identity())); - v = {1, 0, 1, 1}; + v[0] = 1; + v[1] = 0; + v[2] = 1; + v[3] = 1; // not partitioned - ASSERT_EQUAL_QUIET(false, thrust::is_partitioned(v.begin(), v.end(), ::internal::identity{})); + ASSERT_EQUAL_QUIET(false, thrust::is_partitioned(v.begin(), v.end(), thrust::identity())); } DECLARE_VECTOR_UNITTEST(TestIsPartitionedSimple); template -void TestIsPartitioned() +void TestIsPartitioned(void) { using T = typename Vector::value_type; @@ -78,7 +87,7 @@ void TestIsPartitioned() DECLARE_INTEGRAL_VECTOR_UNITTEST(TestIsPartitioned); template -bool is_partitioned(my_system& system, InputIterator /*first*/, InputIterator, Predicate) +THRUST_HOST_DEVICE bool is_partitioned(my_system& system, InputIterator /*first*/, InputIterator, Predicate) { system.validate_dispatch(); return false; @@ -96,7 +105,7 @@ void TestIsPartitionedDispatchExplicit() DECLARE_UNITTEST(TestIsPartitionedDispatchExplicit); template -bool is_partitioned(my_tag, InputIterator first, InputIterator, Predicate) +THRUST_HOST_DEVICE bool is_partitioned(my_tag, InputIterator first, InputIterator, Predicate) { *first = 13; return false; diff --git a/projects/rocthrust/testing/logical.cu b/projects/rocthrust/testing/logical.cu index f644cae9e922..8e86afe13520 100644 --- a/projects/rocthrust/testing/logical.cu +++ b/projects/rocthrust/testing/logical.cu @@ -28,16 +28,16 @@ void TestAllOf() Vector v(3, T{1}); - ASSERT_EQUAL(thrust::all_of(v.begin(), v.end(), ::internal::identity{}), true); + ASSERT_EQUAL(thrust::all_of(v.begin(), v.end(), thrust::identity()), true); v[1] = T{0}; - ASSERT_EQUAL(thrust::all_of(v.begin(), v.end(), ::internal::identity{}), false); + ASSERT_EQUAL(thrust::all_of(v.begin(), v.end(), thrust::identity()), false); - ASSERT_EQUAL(thrust::all_of(v.begin() + 0, v.begin() + 0, ::internal::identity{}), true); - ASSERT_EQUAL(thrust::all_of(v.begin() + 0, v.begin() + 1, ::internal::identity{}), true); - ASSERT_EQUAL(thrust::all_of(v.begin() + 0, v.begin() + 2, ::internal::identity{}), false); - ASSERT_EQUAL(thrust::all_of(v.begin() + 1, v.begin() + 2, ::internal::identity{}), false); + ASSERT_EQUAL(thrust::all_of(v.begin() + 0, v.begin() + 0, thrust::identity()), true); + ASSERT_EQUAL(thrust::all_of(v.begin() + 0, v.begin() + 1, thrust::identity()), true); + ASSERT_EQUAL(thrust::all_of(v.begin() + 0, v.begin() + 2, thrust::identity()), false); + ASSERT_EQUAL(thrust::all_of(v.begin() + 1, v.begin() + 2, thrust::identity()), false); } DECLARE_VECTOR_UNITTEST(TestAllOf); @@ -83,16 +83,16 @@ void TestAnyOf() Vector v(3, T{1}); - ASSERT_EQUAL(thrust::any_of(v.begin(), v.end(), ::internal::identity{}), true); + ASSERT_EQUAL(thrust::any_of(v.begin(), v.end(), thrust::identity()), true); v[1] = 0; - ASSERT_EQUAL(thrust::any_of(v.begin(), v.end(), ::internal::identity{}), true); + ASSERT_EQUAL(thrust::any_of(v.begin(), v.end(), thrust::identity()), true); - ASSERT_EQUAL(thrust::any_of(v.begin() + 0, v.begin() + 0, ::internal::identity{}), false); - ASSERT_EQUAL(thrust::any_of(v.begin() + 0, v.begin() + 1, ::internal::identity{}), true); - ASSERT_EQUAL(thrust::any_of(v.begin() + 0, v.begin() + 2, ::internal::identity{}), true); - ASSERT_EQUAL(thrust::any_of(v.begin() + 1, v.begin() + 2, ::internal::identity{}), false); + ASSERT_EQUAL(thrust::any_of(v.begin() + 0, v.begin() + 0, thrust::identity()), false); + ASSERT_EQUAL(thrust::any_of(v.begin() + 0, v.begin() + 1, thrust::identity()), true); + ASSERT_EQUAL(thrust::any_of(v.begin() + 0, v.begin() + 2, thrust::identity()), true); + ASSERT_EQUAL(thrust::any_of(v.begin() + 1, v.begin() + 2, thrust::identity()), false); } DECLARE_VECTOR_UNITTEST(TestAnyOf); @@ -138,16 +138,16 @@ void TestNoneOf() Vector v(3, T{1}); - ASSERT_EQUAL(thrust::none_of(v.begin(), v.end(), ::internal::identity{}), false); + ASSERT_EQUAL(thrust::none_of(v.begin(), v.end(), thrust::identity()), false); v[1] = 0; - ASSERT_EQUAL(thrust::none_of(v.begin(), v.end(), ::internal::identity{}), false); + ASSERT_EQUAL(thrust::none_of(v.begin(), v.end(), thrust::identity()), false); - ASSERT_EQUAL(thrust::none_of(v.begin() + 0, v.begin() + 0, ::internal::identity{}), true); - ASSERT_EQUAL(thrust::none_of(v.begin() + 0, v.begin() + 1, ::internal::identity{}), false); - ASSERT_EQUAL(thrust::none_of(v.begin() + 0, v.begin() + 2, ::internal::identity{}), false); - ASSERT_EQUAL(thrust::none_of(v.begin() + 1, v.begin() + 2, ::internal::identity{}), true); + ASSERT_EQUAL(thrust::none_of(v.begin() + 0, v.begin() + 0, thrust::identity()), true); + ASSERT_EQUAL(thrust::none_of(v.begin() + 0, v.begin() + 1, thrust::identity()), false); + ASSERT_EQUAL(thrust::none_of(v.begin() + 0, v.begin() + 2, thrust::identity()), false); + ASSERT_EQUAL(thrust::none_of(v.begin() + 1, v.begin() + 2, thrust::identity()), true); } DECLARE_VECTOR_UNITTEST(TestNoneOf); diff --git a/projects/rocthrust/testing/partition.cu b/projects/rocthrust/testing/partition.cu index 5c81a0e84854..e0ad600afeed 100644 --- a/projects/rocthrust/testing/partition.cu +++ b/projects/rocthrust/testing/partition.cu @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -157,13 +156,14 @@ DECLARE_INTEGRAL_VECTOR_UNITTEST(TestStablePartitionSimple); template void TestStablePartitionStencilSimple() { + using T = typename Vector::value_type; using Iterator = typename Vector::iterator; Vector data{1, 2, 1, 3, 2}; Vector stencil{0, 1, 0, 0, 1}; - Iterator iter = thrust::stable_partition(data.begin(), data.end(), stencil.begin(), ::internal::identity{}); + Iterator iter = thrust::stable_partition(data.begin(), data.end(), stencil.begin(), thrust::identity()); Vector ref{2, 2, 1, 1, 3}; @@ -199,14 +199,17 @@ DECLARE_INTEGRAL_VECTOR_UNITTEST(TestStablePartitionCopySimple); template void TestStablePartitionCopyStencilSimple() { + using T = typename Vector::value_type; + Vector data{1, 2, 1, 1, 2}; + Vector stencil{false, true, false, false, true}; Vector true_results(2); Vector false_results(3); thrust::pair ends = thrust::stable_partition_copy( - data.begin(), data.end(), stencil.begin(), true_results.begin(), false_results.begin(), ::internal::identity{}); + data.begin(), data.end(), stencil.begin(), true_results.begin(), false_results.begin(), thrust::identity()); Vector true_ref(2, 2); diff --git a/projects/rocthrust/testing/partition_point.cu b/projects/rocthrust/testing/partition_point.cu index 1610d2a5d8c7..71188059a158 100644 --- a/projects/rocthrust/testing/partition_point.cu +++ b/projects/rocthrust/testing/partition_point.cu @@ -31,26 +31,31 @@ struct is_even }; template -void TestPartitionPointSimple() +void TestPartitionPointSimple(void) { + using T = typename Vector::value_type; using Iterator = typename Vector::iterator; - Vector v{1, 1, 1, 0}; + Vector v(4); + v[0] = 1; + v[1] = 1; + v[2] = 1; + v[3] = 0; Iterator first = v.begin(); Iterator last = v.begin() + 4; Iterator ref = first + 3; - ASSERT_EQUAL_QUIET(ref, thrust::partition_point(first, last, ::internal::identity{})); + ASSERT_EQUAL_QUIET(ref, thrust::partition_point(first, last, thrust::identity())); last = v.begin() + 3; ref = last; - ASSERT_EQUAL_QUIET(ref, thrust::partition_point(first, last, ::internal::identity{})); + ASSERT_EQUAL_QUIET(ref, thrust::partition_point(first, last, thrust::identity())); } DECLARE_VECTOR_UNITTEST(TestPartitionPointSimple); template -void TestPartitionPoint() +void TestPartitionPoint(void) { using T = typename Vector::value_type; using Iterator = typename Vector::iterator; @@ -66,7 +71,7 @@ void TestPartitionPoint() DECLARE_INTEGRAL_VECTOR_UNITTEST(TestPartitionPoint); template -ForwardIterator partition_point(my_system& system, ForwardIterator first, ForwardIterator, Predicate) +THRUST_HOST_DEVICE ForwardIterator partition_point(my_system& system, ForwardIterator first, ForwardIterator, Predicate) { system.validate_dispatch(); return first; @@ -84,7 +89,7 @@ void TestPartitionPointDispatchExplicit() DECLARE_UNITTEST(TestPartitionPointDispatchExplicit); template -ForwardIterator partition_point(my_tag, ForwardIterator first, ForwardIterator, Predicate) +THRUST_HOST_DEVICE ForwardIterator partition_point(my_tag, ForwardIterator first, ForwardIterator, Predicate) { *first = 13; return first; diff --git a/projects/rocthrust/testing/permutation_iterator.cu b/projects/rocthrust/testing/permutation_iterator.cu index 2b5f26e72a83..13161fb179f3 100644 --- a/projects/rocthrust/testing/permutation_iterator.cu +++ b/projects/rocthrust/testing/permutation_iterator.cu @@ -15,7 +15,6 @@ * limitations under the License. */ -#include #include #include #include @@ -24,20 +23,23 @@ #include -#include _THRUST_STD_INCLUDE(type_traits) - template -void TestPermutationIteratorSimple() +void TestPermutationIteratorSimple(void) { using T = typename Vector::value_type; using Iterator = typename Vector::iterator; Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + thrust::permutation_iterator begin(source.begin(), indices.begin()); thrust::permutation_iterator end(source.begin(), indices.end()); @@ -58,88 +60,124 @@ void TestPermutationIteratorSimple() *begin = 10; *end = 20; - Vector ref{10, 2, 3, 4, 5, 20, 7, 8}; - ASSERT_EQUAL(source, ref); + ASSERT_EQUAL(source[0], 10); + ASSERT_EQUAL(source[1], 2); + ASSERT_EQUAL(source[2], 3); + ASSERT_EQUAL(source[3], 4); + ASSERT_EQUAL(source[4], 5); + ASSERT_EQUAL(source[5], 20); + ASSERT_EQUAL(source[6], 7); + ASSERT_EQUAL(source[7], 8); } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestPermutationIteratorSimple); -static_assert(_THRUST_STD::is_trivially_copy_constructible>::value, ""); -static_assert(_THRUST_STD::is_trivially_copyable>::value, ""); +static_assert(std::is_trivially_copy_constructible>::value, ""); +static_assert(std::is_trivially_copyable>::value, ""); template -void TestPermutationIteratorGather() +void TestPermutationIteratorGather(void) { using Iterator = typename Vector::iterator; Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(4, 10); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + thrust::permutation_iterator p_source(source.begin(), indices.begin()); thrust::copy(p_source, p_source + 4, output.begin()); - Vector ref{4, 1, 6, 8}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], 4); + ASSERT_EQUAL(output[1], 1); + ASSERT_EQUAL(output[2], 6); + ASSERT_EQUAL(output[3], 8); } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestPermutationIteratorGather); template -void TestPermutationIteratorScatter() +void TestPermutationIteratorScatter(void) { using Iterator = typename Vector::iterator; Vector source(4, 10); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(8); // initialize output thrust::sequence(output.begin(), output.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + // construct transform_iterator thrust::permutation_iterator p_output(output.begin(), indices.begin()); thrust::copy(source.begin(), source.end(), p_output); - Vector ref{10, 2, 3, 10, 5, 10, 7, 10}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], 10); + ASSERT_EQUAL(output[1], 2); + ASSERT_EQUAL(output[2], 3); + ASSERT_EQUAL(output[3], 10); + ASSERT_EQUAL(output[4], 5); + ASSERT_EQUAL(output[5], 10); + ASSERT_EQUAL(output[6], 7); + ASSERT_EQUAL(output[7], 10); } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestPermutationIteratorScatter); template -void TestMakePermutationIterator() +void TestMakePermutationIterator(void) { Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(4, 10); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + thrust::copy(thrust::make_permutation_iterator(source.begin(), indices.begin()), thrust::make_permutation_iterator(source.begin(), indices.begin()) + 4, output.begin()); - Vector ref{4, 1, 6, 8}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], 4); + ASSERT_EQUAL(output[1], 1); + ASSERT_EQUAL(output[2], 6); + ASSERT_EQUAL(output[3], 8); } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestMakePermutationIterator); template -void TestPermutationIteratorReduce() +void TestPermutationIteratorReduce(void) { using T = typename Vector::value_type; using Iterator = typename Vector::iterator; Vector source(8); - Vector indices{3, 0, 5, 7}; + Vector indices(4); Vector output(4, 10); // initialize input thrust::sequence(source.begin(), source.end(), 1); + indices[0] = 3; + indices[1] = 0; + indices[2] = 5; + indices[3] = 7; + // construct transform_iterator thrust::permutation_iterator iter(source.begin(), indices.begin()); @@ -158,7 +196,7 @@ void TestPermutationIteratorReduce() }; DECLARE_INTEGRAL_VECTOR_UNITTEST(TestPermutationIteratorReduce); -void TestPermutationIteratorHostDeviceGather() +void TestPermutationIteratorHostDeviceGather(void) { using T = int; using HostVector = thrust::host_vector; @@ -167,35 +205,44 @@ void TestPermutationIteratorHostDeviceGather() using DeviceIterator = DeviceVector::iterator; HostVector h_source(8); - HostVector h_indices{3, 0, 5, 7}; + HostVector h_indices(4); HostVector h_output(4, 10); DeviceVector d_source(8); - DeviceVector d_indices(h_indices); + DeviceVector d_indices(4); DeviceVector d_output(4, 10); // initialize source thrust::sequence(h_source.begin(), h_source.end(), 1); thrust::sequence(d_source.begin(), d_source.end(), 1); + h_indices[0] = d_indices[0] = 3; + h_indices[1] = d_indices[1] = 0; + h_indices[2] = d_indices[2] = 5; + h_indices[3] = d_indices[3] = 7; + thrust::permutation_iterator p_h_source(h_source.begin(), h_indices.begin()); thrust::permutation_iterator p_d_source(d_source.begin(), d_indices.begin()); // gather host->device thrust::copy(p_h_source, p_h_source + 4, d_output.begin()); - DeviceVector dref{4, 1, 6, 8}; - ASSERT_EQUAL(d_output, dref); + ASSERT_EQUAL(d_output[0], 4); + ASSERT_EQUAL(d_output[1], 1); + ASSERT_EQUAL(d_output[2], 6); + ASSERT_EQUAL(d_output[3], 8); // gather device->host thrust::copy(p_d_source, p_d_source + 4, h_output.begin()); - HostVector href{4, 1, 6, 8}; - ASSERT_EQUAL(h_output, href); + ASSERT_EQUAL(h_output[0], 4); + ASSERT_EQUAL(h_output[1], 1); + ASSERT_EQUAL(h_output[2], 6); + ASSERT_EQUAL(h_output[3], 8); } DECLARE_UNITTEST(TestPermutationIteratorHostDeviceGather); -void TestPermutationIteratorHostDeviceScatter() +void TestPermutationIteratorHostDeviceScatter(void) { using T = int; using HostVector = thrust::host_vector; @@ -204,36 +251,53 @@ void TestPermutationIteratorHostDeviceScatter() using DeviceIterator = DeviceVector::iterator; HostVector h_source(4, 10); - HostVector h_indices{3, 0, 5, 7}; + HostVector h_indices(4); HostVector h_output(8); DeviceVector d_source(4, 10); - DeviceVector d_indices(h_indices); + DeviceVector d_indices(4); DeviceVector d_output(8); // initialize source thrust::sequence(h_output.begin(), h_output.end(), 1); thrust::sequence(d_output.begin(), d_output.end(), 1); + h_indices[0] = d_indices[0] = 3; + h_indices[1] = d_indices[1] = 0; + h_indices[2] = d_indices[2] = 5; + h_indices[3] = d_indices[3] = 7; + thrust::permutation_iterator p_h_output(h_output.begin(), h_indices.begin()); thrust::permutation_iterator p_d_output(d_output.begin(), d_indices.begin()); // scatter host->device thrust::copy(h_source.begin(), h_source.end(), p_d_output); - DeviceVector dref{10, 2, 3, 10, 5, 10, 7, 10}; - ASSERT_EQUAL(d_output, dref); + ASSERT_EQUAL(d_output[0], 10); + ASSERT_EQUAL(d_output[1], 2); + ASSERT_EQUAL(d_output[2], 3); + ASSERT_EQUAL(d_output[3], 10); + ASSERT_EQUAL(d_output[4], 5); + ASSERT_EQUAL(d_output[5], 10); + ASSERT_EQUAL(d_output[6], 7); + ASSERT_EQUAL(d_output[7], 10); // scatter device->host thrust::copy(d_source.begin(), d_source.end(), p_h_output); - HostVector href(dref); - ASSERT_EQUAL(h_output, href); + ASSERT_EQUAL(h_output[0], 10); + ASSERT_EQUAL(h_output[1], 2); + ASSERT_EQUAL(h_output[2], 3); + ASSERT_EQUAL(h_output[3], 10); + ASSERT_EQUAL(h_output[4], 5); + ASSERT_EQUAL(h_output[5], 10); + ASSERT_EQUAL(h_output[6], 7); + ASSERT_EQUAL(h_output[7], 10); } DECLARE_UNITTEST(TestPermutationIteratorHostDeviceScatter); template -void TestPermutationIteratorWithCountingIterator() +void TestPermutationIteratorWithCountingIterator(void) { using T = typename Vector::value_type; using diff_t = typename thrust::counting_iterator::difference_type; @@ -249,8 +313,10 @@ void TestPermutationIteratorWithCountingIterator() thrust::copy(first, last, output.begin()); - Vector ref{0, 1, 2, 3}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], 0); + ASSERT_EQUAL(output[1], 1); + ASSERT_EQUAL(output[2], 2); + ASSERT_EQUAL(output[3], 3); } // test copy() @@ -260,10 +326,12 @@ void TestPermutationIteratorWithCountingIterator() thrust::transform(thrust::make_permutation_iterator(input, index), thrust::make_permutation_iterator(input, index + 4), output.begin(), - ::internal::identity{}); + thrust::identity()); - Vector ref{0, 1, 2, 3}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], 0); + ASSERT_EQUAL(output[1], 1); + ASSERT_EQUAL(output[2], 2); + ASSERT_EQUAL(output[3], 3); } } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestPermutationIteratorWithCountingIterator); diff --git a/projects/rocthrust/testing/remove.cu b/projects/rocthrust/testing/remove.cu index a9ac6ddb8fae..54c155659e4c 100644 --- a/projects/rocthrust/testing/remove.cu +++ b/projects/rocthrust/testing/remove.cu @@ -45,24 +45,29 @@ struct is_true }; template -void TestRemoveSimple() +void TestRemoveSimple(void) { using T = typename Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; typename Vector::iterator end = thrust::remove(data.begin(), data.end(), (T) 2); ASSERT_EQUAL(end - data.begin(), 3); - data.resize(end - data.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(data, ref); + ASSERT_EQUAL(data[0], 1); + ASSERT_EQUAL(data[1], 1); + ASSERT_EQUAL(data[2], 3); } DECLARE_VECTOR_UNITTEST(TestRemoveSimple); template -ForwardIterator remove(my_system& system, ForwardIterator first, ForwardIterator, const T&) +THRUST_HOST_DEVICE ForwardIterator remove(my_system& system, ForwardIterator first, ForwardIterator, const T&) { system.validate_dispatch(); return first; @@ -80,7 +85,7 @@ void TestRemoveDispatchExplicit() DECLARE_UNITTEST(TestRemoveDispatchExplicit); template -ForwardIterator remove(my_tag, ForwardIterator first, ForwardIterator, const T&) +THRUST_HOST_DEVICE ForwardIterator remove(my_tag, ForwardIterator first, ForwardIterator, const T&) { *first = 13; return first; @@ -97,26 +102,32 @@ void TestRemoveDispatchImplicit() DECLARE_UNITTEST(TestRemoveDispatchImplicit); template -void TestRemoveCopySimple() +void TestRemoveCopySimple(void) { using T = typename Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; Vector result(5); typename Vector::iterator end = thrust::remove_copy(data.begin(), data.end(), result.begin(), (T) 2); ASSERT_EQUAL(end - result.begin(), 3); - result.resize(end - result.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 1); + ASSERT_EQUAL(result[1], 1); + ASSERT_EQUAL(result[2], 3); } DECLARE_VECTOR_UNITTEST(TestRemoveCopySimple); template -OutputIterator remove_copy(my_system& system, InputIterator, InputIterator, OutputIterator result, const T&) +THRUST_HOST_DEVICE OutputIterator +remove_copy(my_system& system, InputIterator, InputIterator, OutputIterator result, const T&) { system.validate_dispatch(); return result; @@ -134,7 +145,7 @@ void TestRemoveCopyDispatchExplicit() DECLARE_UNITTEST(TestRemoveCopyDispatchExplicit); template -OutputIterator remove_copy(my_tag, InputIterator, InputIterator, OutputIterator result, const T&) +THRUST_HOST_DEVICE OutputIterator remove_copy(my_tag, InputIterator, InputIterator, OutputIterator result, const T&) { *result = 13; return result; @@ -152,24 +163,29 @@ void TestRemoveCopyDispatchImplicit() DECLARE_UNITTEST(TestRemoveCopyDispatchImplicit); template -void TestRemoveIfSimple() +void TestRemoveIfSimple(void) { using T = typename Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; typename Vector::iterator end = thrust::remove_if(data.begin(), data.end(), is_even()); ASSERT_EQUAL(end - data.begin(), 3); - data.resize(end - data.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(data, ref); + ASSERT_EQUAL(data[0], 1); + ASSERT_EQUAL(data[1], 1); + ASSERT_EQUAL(data[2], 3); } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestRemoveIfSimple); template -ForwardIterator remove_if(my_system& system, ForwardIterator first, ForwardIterator, Predicate) +THRUST_HOST_DEVICE ForwardIterator remove_if(my_system& system, ForwardIterator first, ForwardIterator, Predicate) { system.validate_dispatch(); return first; @@ -187,7 +203,7 @@ void TestRemoveIfDispatchExplicit() DECLARE_UNITTEST(TestRemoveIfDispatchExplicit); template -ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, Predicate) +THRUST_HOST_DEVICE ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, Predicate) { *first = 13; return first; @@ -204,23 +220,37 @@ void TestRemoveIfDispatchImplicit() DECLARE_UNITTEST(TestRemoveIfDispatchImplicit); template -void TestRemoveIfStencilSimple() +void TestRemoveIfStencilSimple(void) { - Vector data{1, 2, 1, 3, 2}; - Vector stencil{0, 1, 0, 0, 1}; + using T = typename Vector::value_type; + + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; + + Vector stencil(5); + stencil[0] = 0; + stencil[1] = 1; + stencil[2] = 0; + stencil[3] = 0; + stencil[4] = 1; - typename Vector::iterator end = thrust::remove_if(data.begin(), data.end(), stencil.begin(), ::internal::identity{}); + typename Vector::iterator end = thrust::remove_if(data.begin(), data.end(), stencil.begin(), thrust::identity()); ASSERT_EQUAL(end - data.begin(), 3); - data.resize(end - data.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(data, ref); + ASSERT_EQUAL(data[0], 1); + ASSERT_EQUAL(data[1], 1); + ASSERT_EQUAL(data[2], 3); } DECLARE_VECTOR_UNITTEST(TestRemoveIfStencilSimple); template -ForwardIterator remove_if(my_system& system, ForwardIterator first, ForwardIterator, InputIterator, Predicate) +THRUST_HOST_DEVICE ForwardIterator +remove_if(my_system& system, ForwardIterator first, ForwardIterator, InputIterator, Predicate) { system.validate_dispatch(); return first; @@ -238,7 +268,7 @@ void TestRemoveIfStencilDispatchExplicit() DECLARE_UNITTEST(TestRemoveIfStencilDispatchExplicit); template -ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, InputIterator, Predicate) +THRUST_HOST_DEVICE ForwardIterator remove_if(my_tag, ForwardIterator first, ForwardIterator, InputIterator, Predicate) { *first = 13; return first; @@ -256,26 +286,32 @@ void TestRemoveIfStencilDispatchImplicit() DECLARE_UNITTEST(TestRemoveIfStencilDispatchImplicit); template -void TestRemoveCopyIfSimple() +void TestRemoveCopyIfSimple(void) { using T = typename Vector::value_type; - Vector data{1, 2, 1, 3, 2}; + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; Vector result(5); typename Vector::iterator end = thrust::remove_copy_if(data.begin(), data.end(), result.begin(), is_even()); ASSERT_EQUAL(end - result.begin(), 3); - result.resize(end - result.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 1); + ASSERT_EQUAL(result[1], 1); + ASSERT_EQUAL(result[2], 3); } DECLARE_INTEGRAL_VECTOR_UNITTEST(TestRemoveCopyIfSimple); template -InputIterator remove_copy_if(my_system& system, InputIterator first, InputIterator, OutputIterator, Predicate) +THRUST_HOST_DEVICE InputIterator +remove_copy_if(my_system& system, InputIterator first, InputIterator, OutputIterator, Predicate) { system.validate_dispatch(); return first; @@ -293,7 +329,7 @@ void TestRemoveCopyIfDispatchExplicit() DECLARE_UNITTEST(TestRemoveCopyIfDispatchExplicit); template -InputIterator remove_copy_if(my_tag, InputIterator first, InputIterator, OutputIterator, Predicate) +THRUST_HOST_DEVICE InputIterator remove_copy_if(my_tag, InputIterator first, InputIterator, OutputIterator, Predicate) { *first = 13; return first; @@ -311,26 +347,39 @@ void TestRemoveCopyIfDispatchImplicit() DECLARE_UNITTEST(TestRemoveCopyIfDispatchImplicit); template -void TestRemoveCopyIfStencilSimple() +void TestRemoveCopyIfStencilSimple(void) { - Vector data{1, 2, 1, 3, 2}; - Vector stencil{0, 1, 0, 0, 1}; + using T = typename Vector::value_type; + + Vector data(5); + data[0] = 1; + data[1] = 2; + data[2] = 1; + data[3] = 3; + data[4] = 2; + + Vector stencil(5); + stencil[0] = 0; + stencil[1] = 1; + stencil[2] = 0; + stencil[3] = 0; + stencil[4] = 1; Vector result(5); typename Vector::iterator end = - thrust::remove_copy_if(data.begin(), data.end(), stencil.begin(), result.begin(), ::internal::identity{}); + thrust::remove_copy_if(data.begin(), data.end(), stencil.begin(), result.begin(), thrust::identity()); ASSERT_EQUAL(end - result.begin(), 3); - result.resize(end - result.begin()); - Vector ref{1, 1, 3}; - ASSERT_EQUAL(result, ref); + ASSERT_EQUAL(result[0], 1); + ASSERT_EQUAL(result[1], 1); + ASSERT_EQUAL(result[2], 3); } DECLARE_VECTOR_UNITTEST(TestRemoveCopyIfStencilSimple); template -OutputIterator +THRUST_HOST_DEVICE OutputIterator remove_copy_if(my_system& system, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, Predicate) { system.validate_dispatch(); @@ -349,7 +398,8 @@ void TestRemoveCopyIfStencilDispatchExplicit() DECLARE_UNITTEST(TestRemoveCopyIfStencilDispatchExplicit); template -OutputIterator remove_copy_if(my_tag, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, Predicate) +THRUST_HOST_DEVICE OutputIterator +remove_copy_if(my_tag, InputIterator1, InputIterator1, InputIterator2, OutputIterator result, Predicate) { *result = 13; return result; diff --git a/projects/rocthrust/testing/scan.cu b/projects/rocthrust/testing/scan.cu index 729a564c594a..74319e13133d 100644 --- a/projects/rocthrust/testing/scan.cu +++ b/projects/rocthrust/testing/scan.cu @@ -613,16 +613,6 @@ struct iterator_traits }; THRUST_NAMESPACE_END -namespace std -{ -template <> -struct iterator_traits -{ - using value_type = long long; - using reference = only_set_when_expected_it; -}; -} // namespace std - void TestInclusiveScanWithBigIndexesHelper(int magnitude) { thrust::constant_iterator begin(1); diff --git a/projects/rocthrust/testing/tabulate.cu b/projects/rocthrust/testing/tabulate.cu index 34f8e4185349..c50b2f62fca5 100644 --- a/projects/rocthrust/testing/tabulate.cu +++ b/projects/rocthrust/testing/tabulate.cu @@ -33,7 +33,7 @@ void TestTabulateDispatchExplicit() thrust::device_vector vec(1); my_system sys(0); - thrust::tabulate(sys, vec.begin(), vec.end(), ::internal::identity{}); + thrust::tabulate(sys, vec.begin(), vec.end(), thrust::identity()); ASSERT_EQUAL(true, sys.is_valid()); } @@ -49,33 +49,43 @@ void TestTabulateDispatchImplicit() { thrust::device_vector vec(1); - thrust::tabulate(thrust::retag(vec.begin()), thrust::retag(vec.end()), ::internal::identity{}); + thrust::tabulate(thrust::retag(vec.begin()), thrust::retag(vec.end()), thrust::identity()); ASSERT_EQUAL(13, vec.front()); } DECLARE_UNITTEST(TestTabulateDispatchImplicit); template -void TestTabulateSimple() +void TestTabulateSimple(void) { using namespace thrust::placeholders; + using T = typename Vector::value_type; Vector v(5); - thrust::tabulate(v.begin(), v.end(), ::internal::identity{}); + thrust::tabulate(v.begin(), v.end(), thrust::identity()); - Vector ref{0, 1, 2, 3, 4}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], 1); + ASSERT_EQUAL(v[2], 2); + ASSERT_EQUAL(v[3], 3); + ASSERT_EQUAL(v[4], 4); thrust::tabulate(v.begin(), v.end(), -_1); - ref = {0, -1, -2, -3, -4}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], -1); + ASSERT_EQUAL(v[2], -2); + ASSERT_EQUAL(v[3], -3); + ASSERT_EQUAL(v[4], -4); thrust::tabulate(v.begin(), v.end(), _1 * _1 * _1); - ref = {0, 1, 8, 27, 64}; - ASSERT_EQUAL(v, ref); + ASSERT_EQUAL(v[0], 0); + ASSERT_EQUAL(v[1], 1); + ASSERT_EQUAL(v[2], 8); + ASSERT_EQUAL(v[3], 27); + ASSERT_EQUAL(v[4], 64); } DECLARE_VECTOR_UNITTEST(TestTabulateSimple); @@ -104,7 +114,7 @@ void TestTabulateToDiscardIterator(size_t n) { thrust::tabulate(thrust::discard_iterator(), thrust::discard_iterator(n), - ::internal::identity{}); + thrust::identity()); // nothing to check -- just make sure it compiles } diff --git a/projects/rocthrust/testing/transform.cu b/projects/rocthrust/testing/transform.cu index d3dfbc93585c..4df964fa1607 100644 --- a/projects/rocthrust/testing/transform.cu +++ b/projects/rocthrust/testing/transform.cu @@ -15,7 +15,6 @@ * limitations under the License. */ -#include #include #include #include @@ -99,7 +98,7 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestTransformIfUnaryNoStencilSimple() Vector output{-1, -2, -3}; Vector result{-1, 2, -3}; - iter = thrust::transform_if(input.begin(), input.end(), output.begin(), thrust::negate(), ::internal::identity{}); + iter = thrust::transform_if(input.begin(), input.end(), output.begin(), thrust::negate(), thrust::identity()); ASSERT_EQUAL(std::size_t(iter - output.begin()), input.size()); ASSERT_EQUAL(output, result); @@ -160,7 +159,7 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestTransformIfUnarySimple() Vector result{-1, 2, -3}; iter = thrust::transform_if( - input.begin(), input.end(), stencil.begin(), output.begin(), thrust::negate(), ::internal::identity{}); + input.begin(), input.end(), stencil.begin(), output.begin(), thrust::negate(), thrust::identity()); ASSERT_EQUAL(std::size_t(iter - output.begin()), input.size()); ASSERT_EQUAL(output, result); @@ -288,7 +287,7 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestTransformIfBinarySimple() Vector output{1, 2, 3}; Vector result{5, 2, -3}; - ::internal::identity identity; + thrust::identity identity; iter = thrust::transform_if( input1.begin(), @@ -693,8 +692,8 @@ THRUST_DISABLE_BROKEN_GCC_VECTORIZER void TestTransformUnaryCountingIterator() thrust::host_vector h_result(n); thrust::device_vector d_result(n); - thrust::transform(h_first, h_first + n, h_result.begin(), ::internal::identity{}); - thrust::transform(d_first, d_first + n, d_result.begin(), ::internal::identity{}); + thrust::transform(h_first, h_first + n, h_result.begin(), thrust::identity()); + thrust::transform(d_first, d_first + n, d_result.begin(), thrust::identity()); ASSERT_EQUAL(h_result, d_result); } diff --git a/projects/rocthrust/testing/transform_input_output_iterator.cu b/projects/rocthrust/testing/transform_input_output_iterator.cu index 5d537b9c81e1..d39b217ba127 100644 --- a/projects/rocthrust/testing/transform_input_output_iterator.cu +++ b/projects/rocthrust/testing/transform_input_output_iterator.cu @@ -116,8 +116,8 @@ struct TestTransformInputOutputIteratorScan // run on host (uses forward iterator negate) thrust::inclusive_scan( - thrust::make_transform_input_output_iterator(h_data.begin(), thrust::negate(), ::internal::identity{}), - thrust::make_transform_input_output_iterator(h_data.end(), thrust::negate(), ::internal::identity{}), + thrust::make_transform_input_output_iterator(h_data.begin(), thrust::negate(), thrust::identity()), + thrust::make_transform_input_output_iterator(h_data.end(), thrust::negate(), thrust::identity()), h_result.begin()); // run on device (uses reverse iterator negate) thrust::inclusive_scan( diff --git a/projects/rocthrust/testing/transform_iterator.cu b/projects/rocthrust/testing/transform_iterator.cu index e01e276f6efb..65503b013c2e 100644 --- a/projects/rocthrust/testing/transform_iterator.cu +++ b/projects/rocthrust/testing/transform_iterator.cu @@ -15,13 +15,6 @@ * limitations under the License. */ -#include - -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC -// suppress warnings on thrust::identity -THRUST_SUPPRESS_DEPRECATED_PUSH -#endif // THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC - #include #include #include @@ -30,21 +23,14 @@ THRUST_SUPPRESS_DEPRECATED_PUSH #include #include +#include +#include #include -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -# include -# include -# include -#endif #include -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC -THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVHPC - template -void TestTransformIterator() +void TestTransformIterator(void) { using T = typename Vector::value_type; @@ -62,13 +48,15 @@ void TestTransformIterator() thrust::copy(iter, iter + 4, output.begin()); - Vector ref{-1, -2, -3, -4}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], -1); + ASSERT_EQUAL(output[1], -2); + ASSERT_EQUAL(output[2], -3); + ASSERT_EQUAL(output[3], -4); } DECLARE_VECTOR_UNITTEST(TestTransformIterator); template -void TestMakeTransformIterator() +void TestMakeTransformIterator(void) { using T = typename Vector::value_type; @@ -88,8 +76,10 @@ void TestMakeTransformIterator() thrust::make_transform_iterator(input.end(), UnaryFunction()), output.begin()); - Vector ref{-1, -2, -3, -4}; - ASSERT_EQUAL(output, ref); + ASSERT_EQUAL(output[0], -1); + ASSERT_EQUAL(output[1], -2); + ASSERT_EQUAL(output[2], -3); + ASSERT_EQUAL(output[3], -4); } DECLARE_VECTOR_UNITTEST(TestMakeTransformIterator); @@ -155,142 +145,85 @@ struct pass_ref } }; -// a user provided functor that forwards its argument +// TODO(bgruber): replace by libc++ with C++14 struct forward { template constexpr _Tp&& operator()(_Tp&& __t) const noexcept { - return _THRUST_STD::forward<_Tp>(__t); + return std::forward<_Tp>(__t); } }; void TestTransformIteratorReferenceAndValueType() { - THRUST_SUPPRESS_DEPRECATED_PUSH - using _THRUST_STD::is_same; - using _THRUST_STD::negate; { thrust::host_vector v; auto it = v.begin(); - static_assert(is_same::value, ""); // ordinary reference - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); // ordinary reference + static_assert(std::is_same::value, ""); auto it_tr_val = thrust::make_transform_iterator(it, flip_value{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_val; auto it_tr_ref = thrust::make_transform_iterator(it, pass_ref{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_ref; auto it_tr_fwd = thrust::make_transform_iterator(it, forward{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_fwd; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - - auto it_tr_cid = thrust::make_transform_iterator(it, ::internal::identity{}); - static_assert(is_same::value, ""); // special handling by - // transform_iterator_reference - static_assert(is_same::value, ""); - (void) it_tr_cid; } { thrust::device_vector v; auto it = v.begin(); - static_assert(is_same>::value, ""); // proxy reference - static_assert(is_same::value, ""); + static_assert(std::is_same>::value, ""); // proxy reference + static_assert(std::is_same::value, ""); auto it_tr_val = thrust::make_transform_iterator(it, flip_value{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_val; auto it_tr_ref = thrust::make_transform_iterator(it, pass_ref{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_ref; auto it_tr_fwd = thrust::make_transform_iterator(it, forward{}); - static_assert(is_same::value, ""); // wrapped reference is decayed - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); // wrapped reference is decayed + static_assert(std::is_same::value, ""); (void) it_tr_fwd; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - - auto it_tr_cid = thrust::make_transform_iterator(it, ::internal::identity{}); - static_assert(is_same::value, ""); // special handling by - // transform_iterator_reference - static_assert(is_same::value, ""); - (void) it_tr_cid; } { std::vector v; auto it = v.begin(); - static_assert(is_same::reference>::value, ""); // proxy reference - static_assert(is_same::value, ""); + static_assert(std::is_same::reference>::value, ""); // proxy reference + static_assert(std::is_same::value, ""); auto it_tr_val = thrust::make_transform_iterator(it, flip_value{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_val; auto it_tr_ref = thrust::make_transform_iterator(it, pass_ref{}); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); (void) it_tr_ref; auto it_tr_fwd = thrust::make_transform_iterator(it, forward{}); - static_assert(is_same::value, ""); // proxy reference is decayed - static_assert(is_same::value, ""); + static_assert(std::is_same::value, ""); // proxy reference is decayed + static_assert(std::is_same::value, ""); (void) it_tr_fwd; - - auto it_tr_ide = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_ide; - - auto it_tr_tid = thrust::make_transform_iterator(it, thrust::identity{}); - static_assert(is_same::value, ""); // identity::value_type - static_assert(is_same::value, ""); - (void) it_tr_tid; - - auto it_tr_cid = thrust::make_transform_iterator(it, ::internal::identity{}); - static_assert(is_same::value, ""); // special handling by - // transform_iterator_reference - static_assert(is_same::value, ""); - (void) it_tr_cid; } - THRUST_SUPPRESS_DEPRECATED_POP } DECLARE_UNITTEST(TestTransformIteratorReferenceAndValueType); - -void TestTransformIteratorIdentity() -{ - THRUST_SUPPRESS_DEPRECATED_PUSH - thrust::device_vector v(3, 42); - - ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), thrust::identity{}), 42); - ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), thrust::identity<>{}), 42); - ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), ::internal::identity{}), 42); - using namespace thrust::placeholders; - ASSERT_EQUAL(*thrust::make_transform_iterator(v.begin(), _1), 42); - THRUST_SUPPRESS_DEPRECATED_POP -} - -DECLARE_UNITTEST(TestTransformIteratorIdentity); diff --git a/projects/rocthrust/testing/transform_scan.cu b/projects/rocthrust/testing/transform_scan.cu index bc473cc2b876..2fa273003856 100644 --- a/projects/rocthrust/testing/transform_scan.cu +++ b/projects/rocthrust/testing/transform_scan.cu @@ -379,20 +379,20 @@ void TestValueCategoryDeduction() vec.assign((T*) a_h, a_h + 10); thrust::transform_inclusive_scan( - thrust::device, vec.cbegin(), vec.cend(), vec.begin(), ::internal::identity{}, thrust::maximum<>{}); + thrust::device, vec.cbegin(), vec.cend(), vec.begin(), thrust::identity<>{}, thrust::maximum<>{}); ASSERT_EQUAL((thrust::device_vector{5, 5, 5, 8, 8, 8, 8, 8, 8, 9}), vec); vec.assign((T*) a_h, a_h + 10); thrust::transform_inclusive_scan( - thrust::device, vec.cbegin(), vec.cend(), vec.begin(), ::internal::identity{}, T{}, thrust::maximum<>{}); + thrust::device, vec.cbegin(), vec.cend(), vec.begin(), thrust::identity<>{}, T{}, thrust::maximum<>{}); ASSERT_EQUAL((thrust::device_vector{5, 5, 5, 8, 8, 8, 8, 8, 8, 9}), vec); vec.assign((T*) a_h, a_h + 10); thrust::transform_exclusive_scan( - thrust::device, vec.cbegin(), vec.cend(), vec.begin(), ::internal::identity{}, T{}, thrust::maximum<>{}); + thrust::device, vec.cbegin(), vec.cend(), vec.begin(), thrust::identity<>{}, T{}, thrust::maximum<>{}); ASSERT_EQUAL((thrust::device_vector{0, 5, 5, 5, 8, 8, 8, 8, 8, 8}), vec); } diff --git a/projects/rocthrust/testing/tuple.cu b/projects/rocthrust/testing/tuple.cu index 1c5a1465739a..816e88e4de4b 100644 --- a/projects/rocthrust/testing/tuple.cu +++ b/projects/rocthrust/testing/tuple.cu @@ -27,11 +27,6 @@ using namespace unittest; -// Yes we're using 'thrust::null_type', I don't care >:( -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -THRUST_SUPPRESS_DEPRECATED_PUSH -#endif - template struct TestTupleConstructor { @@ -554,12 +549,7 @@ void TestTupleCTAD(void) DECLARE_UNITTEST(TestTupleCTAD); #endif // THRUST_CPP_DIALECT >= 2017 -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -THRUST_SUPPRESS_DEPRECATED_POP -#endif - // Ensure that we are backwards compatible with the old thrust::tuple implementation -THRUST_SUPPRESS_DEPRECATED_PUSH static_assert( thrust::tuple_size>::value == 9, ""); static_assert(thrust::tuple_size>::value == 10, ""); -THRUST_SUPPRESS_DEPRECATED_POP diff --git a/projects/rocthrust/testing/type_traits.cu b/projects/rocthrust/testing/type_traits.cu index 5283c93a1413..6279a2a2f006 100644 --- a/projects/rocthrust/testing/type_traits.cu +++ b/projects/rocthrust/testing/type_traits.cu @@ -15,11 +15,8 @@ * limitations under the License. */ -#include - #include #include -#include #include #include #include @@ -60,23 +57,14 @@ void TestIsContiguousIterator() using HostIteratorTuple = thrust::tuple; - using ConstantIterator = thrust::constant_iterator; - using CountingIterator = thrust::counting_iterator; - THRUST_SUPPRESS_DEPRECATED_PUSH - using TransformIterator1 = thrust::transform_iterator, HostVector::iterator>; - THRUST_SUPPRESS_DEPRECATED_POP - using TransformIterator2 = thrust::transform_iterator<::internal::identity, HostVector::iterator>; - using ZipIterator = thrust::zip_iterator; + using ConstantIterator = thrust::constant_iterator; + using CountingIterator = thrust::counting_iterator; + using TransformIterator = thrust::transform_iterator, HostVector::iterator>; + using ZipIterator = thrust::zip_iterator; ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); -#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_NVHPC - // thrust::identity creates a deprecated warning that could not be worked around - THRUST_SUPPRESS_DEPRECATED_PUSH - ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); - THRUST_SUPPRESS_DEPRECATED_POP -#endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_NVHPC - ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); + ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); ASSERT_EQUAL((bool) thrust::is_contiguous_iterator::value, false); } DECLARE_UNITTEST(TestIsContiguousIterator); diff --git a/projects/rocthrust/testing/unittest/testframework.h b/projects/rocthrust/testing/unittest/testframework.h index e251e20cf8b4..09433ebab06c 100644 --- a/projects/rocthrust/testing/unittest/testframework.h +++ b/projects/rocthrust/testing/unittest/testframework.h @@ -26,13 +26,8 @@ #include #include -#if _THRUST_HAS_DEVICE_SYSTEM_STD -# include _THRUST_STD_INCLUDE(limits) -#endif - #include #include -#include #include #include #include @@ -221,30 +216,22 @@ class custom_numeric } }; -namespace std -{ -template <> -struct numeric_limits : numeric_limits -{}; -} // namespace std +THRUST_NAMESPACE_BEGIN -#if _THRUST_HAS_DEVICE_SYSTEM_STD -_THRUST_STD_NAMESPACE_BEGIN template <> struct numeric_limits : numeric_limits {}; -_THRUST_STD_NAMESPACE_END -#endif -THRUST_NAMESPACE_BEGIN namespace detail { + // For random number generation template <> class integer_traits : public integer_traits_base {}; } // namespace detail + THRUST_NAMESPACE_END using NumericTypes = unittest::type_list< diff --git a/projects/rocthrust/testing/unittest/util.h b/projects/rocthrust/testing/unittest/util.h index b3811263054b..c6269de2f7c3 100644 --- a/projects/rocthrust/testing/unittest/util.h +++ b/projects/rocthrust/testing/unittest/util.h @@ -25,8 +25,6 @@ #include #include #if !_THRUST_HAS_DEVICE_SYSTEM_STD -// Use rocprim::numeric_limits if thrust/detail/type_traits.h uses rocprim::arithmetic -# include # include #endif @@ -47,9 +45,8 @@ template typename THRUST_NS_QUALIFIER::detail::disable_if<_THRUST_STD::is_floating_point::value, T>::type truncate_to_max_representable(std::size_t n) { - // Use rocprim::numeric_limits if thrust/detail/type_traits.h uses rocprim::arithmetic return static_cast( - THRUST_NS_QUALIFIER::min(n, static_cast(_THRUST_STD::numeric_limits::max()))); + THRUST_NS_QUALIFIER::min(n, static_cast(THRUST_NS_QUALIFIER::numeric_limits::max()))); } // TODO: This probably won't work for `half`. @@ -57,8 +54,7 @@ template typename _THRUST_STD::enable_if_t<_THRUST_STD::is_floating_point::value, T> truncate_to_max_representable(std::size_t n) { - // Use rocprim::numeric_limits if thrust/detail/type_traits.h uses rocprim::arithmetic - return THRUST_NS_QUALIFIER::min(static_cast(n), _THRUST_STD::numeric_limits::max()); + return THRUST_NS_QUALIFIER::min(static_cast(n), THRUST_NS_QUALIFIER::numeric_limits::max()); } } // namespace unittest diff --git a/projects/rocthrust/thrust/async/copy.h b/projects/rocthrust/thrust/async/copy.h index b64a0c565756..f3ebf4c828ef 100644 --- a/projects/rocthrust/thrust/async/copy.h +++ b/projects/rocthrust/thrust/async/copy.h @@ -22,22 +22,15 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #if THRUST_CPP_DIALECT >= 2017 # include # include -# include # include # include +# include THRUST_NAMESPACE_BEGIN @@ -50,20 +43,14 @@ namespace async namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST event async_copy( - thrust::execution_policy& /*from_exec*/, - thrust::execution_policy& /*to_exec*/, - ForwardIt /*first*/, - Sentinel /*last*/, - OutputIt /*output*/) +THRUST_HOST event +async_copy(thrust::execution_policy&, thrust::execution_policy&, ForwardIt, Sentinel, OutputIt) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -74,7 +61,6 @@ using thrust::async::unimplemented::async_copy; struct copy_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template THRUST_HOST static auto call(thrust::detail::execution_policy_base const& from_exec, @@ -88,42 +74,39 @@ struct copy_fn final thrust::detail::derived_cast(thrust::detail::strip_const(to_exec)), THRUST_FWD(first), THRUST_FWD(last), - THRUST_FWD(output))) THRUST_SUPPRESS_DEPRECATED_POP - - template - THRUST_HOST static auto call(thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& output) - THRUST_RETURNS(copy_fn::call( - thrust::detail::derived_cast(thrust::detail::strip_const(exec)) - // Synthesize a suitable new execution policy, because we don't want to - // try and extract twice from the one we were passed. - , - typename ::internal::remove_cvref_t< - decltype(thrust::detail::derived_cast(thrust::detail::strip_const(exec)))>::tag_type{}, - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(output))) - - template - THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last, OutputIt&& output) THRUST_RETURNS(copy_fn::call( - thrust::detail::select_system(typename thrust::iterator_system<::internal::remove_cvref_t>::type{}), - thrust::detail::select_system(typename thrust::iterator_system<::internal::remove_cvref_t>::type{}), + THRUST_FWD(output))) + + template + THRUST_HOST static auto call(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& output) + THRUST_RETURNS(copy_fn::call( + thrust::detail::derived_cast(thrust::detail::strip_const(exec)) + // Synthesize a suitable new execution policy, because we don't want to + // try and extract twice from the one we were passed. + , + typename remove_cvref_t::tag_type{}, THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(output))) - template - THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const + template + THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last, OutputIt&& output) + THRUST_RETURNS(copy_fn::call( + thrust::detail::select_system(typename thrust::iterator_system>::type{}), + thrust::detail::select_system(typename thrust::iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(output))) + + template + THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; } // namespace copy_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT copy_detail::copy_fn copy{}; /*! \endcond diff --git a/projects/rocthrust/thrust/async/for_each.h b/projects/rocthrust/thrust/async/for_each.h index d7a9f05da1c5..c75ab04fb5ad 100644 --- a/projects/rocthrust/thrust/async/for_each.h +++ b/projects/rocthrust/thrust/async/for_each.h @@ -22,22 +22,15 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #if THRUST_CPP_DIALECT >= 2017 # include # include -# include # include # include +# include THRUST_NAMESPACE_BEGIN @@ -50,16 +43,14 @@ namespace async namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST event +THRUST_HOST event async_for_each(thrust::execution_policy&, ForwardIt, Sentinel, UnaryFunction) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -70,7 +61,6 @@ using thrust::async::unimplemented::async_for_each; struct for_each_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template THRUST_HOST static auto call(thrust::detail::execution_policy_base const& exec, @@ -81,26 +71,22 @@ struct for_each_fn final THRUST_RETURNS(async_for_each(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), - THRUST_FWD(f))) THRUST_SUPPRESS_DEPRECATED_POP - - template - THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last, UnaryFunction&& f) - THRUST_RETURNS(for_each_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}), - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(f))) - - template - THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const - THRUST_RETURNS(call(THRUST_FWD(args)...)) + THRUST_FWD(f))) + + template + THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last, UnaryFunction&& f) + THRUST_RETURNS(for_each_fn::call( + thrust::detail::select_system(typename iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(f))) + + template + THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; } // namespace for_each_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT for_each_detail::for_each_fn for_each{}; /*! \endcond diff --git a/projects/rocthrust/thrust/async/reduce.h b/projects/rocthrust/thrust/async/reduce.h index 2293ed02135f..dcc35b55885d 100644 --- a/projects/rocthrust/thrust/async/reduce.h +++ b/projects/rocthrust/thrust/async/reduce.h @@ -22,24 +22,17 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #if THRUST_CPP_DIALECT >= 2017 # include # include -# include # include # include # include # include +# include THRUST_NAMESPACE_BEGIN @@ -52,16 +45,14 @@ namespace async namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST future +THRUST_HOST future async_reduce(thrust::execution_policy&, ForwardIt, Sentinel, T, BinaryOp) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -72,7 +63,6 @@ using thrust::async::unimplemented::async_reduce; struct reduce_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template THRUST_HOST static auto call(thrust::detail::execution_policy_base const& exec, @@ -86,63 +76,61 @@ struct reduce_fn final THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(init), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH template - THRUST_HOST static auto call4( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - T&& init, - thrust::true_type) + THRUST_FWD(op))) + + template + THRUST_HOST static auto call4( + thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + T&& init, + thrust::true_type) // ADL dispatch. THRUST_RETURNS(async_reduce( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(init), - thrust::plus<::internal::remove_cvref_t>{})) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH template - THRUST_HOST static auto call3( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - thrust::true_type) + thrust::plus>{})) + + template + THRUST_HOST static auto call3( + thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + thrust::true_type) // ADL dispatch. THRUST_RETURNS(async_reduce( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), - typename iterator_traits<::internal::remove_cvref_t>::value_type{}, - thrust::plus< - ::internal::remove_cvref_t>::value_type>>{})) - THRUST_SUPPRESS_DEPRECATED_POP - - template - THRUST_HOST static auto call4(ForwardIt&& first, Sentinel&& last, T&& init, BinaryOp&& op, thrust::false_type) - THRUST_RETURNS(reduce_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}), - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(init), - THRUST_FWD(op))) - - template - THRUST_HOST static auto call3(ForwardIt&& first, Sentinel&& last, T&& init, thrust::false_type) - THRUST_RETURNS(reduce_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}), - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(init), - thrust::plus<::internal::remove_cvref_t>{})) + typename iterator_traits>::value_type{}, + thrust::plus>::value_type>>{})) + + template + THRUST_HOST static auto call4(ForwardIt&& first, Sentinel&& last, T&& init, BinaryOp&& op, thrust::false_type) + THRUST_RETURNS(reduce_fn::call( + thrust::detail::select_system(typename iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(init), + THRUST_FWD(op))) + + template + THRUST_HOST static auto call3(ForwardIt&& first, Sentinel&& last, T&& init, thrust::false_type) + THRUST_RETURNS(reduce_fn::call( + thrust::detail::select_system(typename iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(init), + thrust::plus>{})) // MSVC WAR: MSVC gets angsty and eats all available RAM when we try to detect // if T1 is an execution_policy by using SFINAE. Switching to a static // dispatch pattern to prevent this. template THRUST_HOST static auto call(T1&& t1, T2&& t2, T3&& t3) THRUST_RETURNS(reduce_fn::call3( - THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), thrust::is_execution_policy<::internal::remove_cvref_t>{})) + THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), thrust::is_execution_policy>{})) template THRUST_HOST static auto call(T1&& t1, T2&& t2, T3&& t3, T4&& t4) THRUST_RETURNS(reduce_fn::call4( @@ -150,27 +138,22 @@ struct reduce_fn final THRUST_FWD(t2), THRUST_FWD(t3), THRUST_FWD(t4), - thrust::is_execution_policy<::internal::remove_cvref_t>{})) + thrust::is_execution_policy>{})) template THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last) THRUST_RETURNS(reduce_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}), + thrust::detail::select_system(typename iterator_system>::type{}), THRUST_FWD(first), THRUST_FWD(last), - typename iterator_traits<::internal::remove_cvref_t>::value_type{}, - thrust::plus< - ::internal::remove_cvref_t>::value_type>>{})) + typename iterator_traits>::value_type{}, + thrust::plus>::value_type>>{})) template - THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const - THRUST_RETURNS(call(THRUST_FWD(args)...)) + THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; } // namespace reduce_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT reduce_detail::reduce_fn reduce{}; /////////////////////////////////////////////////////////////////////////////// @@ -178,16 +161,14 @@ THRUST_INLINE_CONSTANT reduce_detail::reduce_fn reduce{}; namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST event +THRUST_HOST event async_reduce_into(thrust::execution_policy&, ForwardIt, Sentinel, OutputIt, T, BinaryOp) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -198,7 +179,6 @@ using thrust::async::unimplemented::async_reduce_into; struct reduce_into_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template THRUST_HOST static auto call(thrust::detail::execution_policy_base const& exec, @@ -214,17 +194,16 @@ struct reduce_into_fn final THRUST_FWD(last), THRUST_FWD(output), THRUST_FWD(init), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template - THRUST_HOST static auto call5( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& output, - T&& init, - thrust::true_type) + THRUST_FWD(op))) + + template + THRUST_HOST static auto call5( + thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& output, + T&& init, + thrust::true_type) // ADL dispatch. THRUST_RETURNS(async_reduce_into( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), @@ -232,62 +211,58 @@ struct reduce_into_fn final THRUST_FWD(last), THRUST_FWD(output), THRUST_FWD(init), - thrust::plus<::internal::remove_cvref_t>{})) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template - THRUST_HOST static auto call4( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& output, - thrust::true_type) + thrust::plus>{})) + + template + THRUST_HOST static auto call4( + thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& output, + thrust::true_type) // ADL dispatch. THRUST_RETURNS(async_reduce_into( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(output), - typename iterator_traits<::internal::remove_cvref_t>::value_type{}, - thrust::plus< - ::internal::remove_cvref_t>::value_type>>{})) - THRUST_SUPPRESS_DEPRECATED_POP - - template - THRUST_HOST static auto call5( - ForwardIt&& first, Sentinel&& last, OutputIt&& output, T&& init, BinaryOp&& op, thrust::false_type) - THRUST_RETURNS(reduce_into_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}, - typename iterator_system<::internal::remove_cvref_t>::type{}), - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(output), - THRUST_FWD(init), - THRUST_FWD(op))) - - template - THRUST_HOST static auto call4( - ForwardIt&& first, Sentinel&& last, OutputIt&& output, T&& init, thrust::false_type) - THRUST_RETURNS(reduce_into_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}, - typename iterator_system<::internal::remove_cvref_t>::type{}), - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(output), - THRUST_FWD(init), - thrust::plus<::internal::remove_cvref_t>{})) - - template - THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last, OutputIt&& output) - THRUST_RETURNS(reduce_into_fn::call( - thrust::detail::select_system(typename iterator_system<::internal::remove_cvref_t>::type{}, - typename iterator_system<::internal::remove_cvref_t>::type{}), - THRUST_FWD(first), - THRUST_FWD(last), - THRUST_FWD(output), - typename iterator_traits<::internal::remove_cvref_t>::value_type{}, - thrust::plus<::internal::remove_cvref_t< - typename iterator_traits<::internal::remove_cvref_t>::value_type>>{})) + typename iterator_traits>::value_type{}, + thrust::plus>::value_type>>{})) + + template + THRUST_HOST static auto call5( + ForwardIt&& first, Sentinel&& last, OutputIt&& output, T&& init, BinaryOp&& op, thrust::false_type) + THRUST_RETURNS(reduce_into_fn::call( + thrust::detail::select_system(typename iterator_system>::type{}, + typename iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(output), + THRUST_FWD(init), + THRUST_FWD(op))) + + template + THRUST_HOST static auto call4( + ForwardIt&& first, Sentinel&& last, OutputIt&& output, T&& init, thrust::false_type) + THRUST_RETURNS(reduce_into_fn::call( + thrust::detail::select_system(typename iterator_system>::type{}, + typename iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(output), + THRUST_FWD(init), + thrust::plus>{})) + + template + THRUST_HOST static auto call(ForwardIt&& first, Sentinel&& last, OutputIt&& output) + THRUST_RETURNS(reduce_into_fn::call( + thrust::detail::select_system(typename iterator_system>::type{}, + typename iterator_system>::type{}), + THRUST_FWD(first), + THRUST_FWD(last), + THRUST_FWD(output), + typename iterator_traits>::value_type{}, + thrust::plus>::value_type>>{})) // MSVC WAR: MSVC gets angsty and eats all available RAM when we try to detect // if T1 is an execution_policy by using SFINAE. Switching to a static @@ -298,7 +273,7 @@ struct reduce_into_fn final THRUST_FWD(t2), THRUST_FWD(t3), THRUST_FWD(t4), - thrust::is_execution_policy<::internal::remove_cvref_t>{})) + thrust::is_execution_policy>{})) template THRUST_HOST static auto call(T1&& t1, T2&& t2, T3&& t3, T4&& t4, T5&& t5) THRUST_RETURNS(reduce_into_fn::call5( @@ -307,18 +282,14 @@ struct reduce_into_fn final THRUST_FWD(t3), THRUST_FWD(t4), THRUST_FWD(t5), - thrust::is_execution_policy<::internal::remove_cvref_t>{})) + thrust::is_execution_policy>{})) template - THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST auto operator()(Args&&... args) const - THRUST_RETURNS(call(THRUST_FWD(args)...)) + THRUST_NODISCARD THRUST_HOST auto operator()(Args&&... args) const THRUST_RETURNS(call(THRUST_FWD(args)...)) }; } // namespace reduce_into_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT reduce_into_detail::reduce_into_fn reduce_into{}; /*! \endcond diff --git a/projects/rocthrust/thrust/async/scan.h b/projects/rocthrust/thrust/async/scan.h index e964cd7043f2..dfa3c3b4184f 100644 --- a/projects/rocthrust/thrust/async/scan.h +++ b/projects/rocthrust/thrust/async/scan.h @@ -22,13 +22,6 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #if THRUST_CPP_DIALECT >= 2017 @@ -36,24 +29,26 @@ # include # include # include -# include # include # include # include # include +# include THRUST_NAMESPACE_BEGIN namespace async { +/*! \cond + */ + // Fallback implementations used when no overloads are found via ADL: namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED event +event async_inclusive_scan(thrust::execution_policy&, ForwardIt, Sentinel, OutputIt, BinaryOp) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), @@ -67,14 +62,13 @@ template -THRUST_DEPRECATED event async_exclusive_scan( +event async_exclusive_scan( thrust::execution_policy&, ForwardIt, Sentinel, OutputIt, InitialValueType, BinaryOp) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -87,51 +81,45 @@ using thrust::async::unimplemented::async_inclusive_scan; // Implementation of the thrust::async::inclusive_scan CPO. struct inclusive_scan_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template - THRUST_DEPRECATED auto operator()( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& out, - BinaryOp&& op) const + auto operator()(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& out, + BinaryOp&& op) const // ADL dispatch. THRUST_RETURNS(async_inclusive_scan( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template - THRUST_DEPRECATED auto operator()( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& out) const + THRUST_FWD(op))) + + template + auto operator()(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& out) const // ADL dispatch. THRUST_RETURNS(async_inclusive_scan( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), - thrust::plus<>{})) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template - THRUST_DEPRECATED auto operator()( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& out, - InitialValueType&& init, - BinaryOp&& op) const + thrust::plus<>{})) + + template + auto operator()(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& out, + InitialValueType&& init, + BinaryOp&& op) const // ADL dispatch. THRUST_RETURNS(async_inclusive_scan( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), @@ -139,60 +127,54 @@ struct inclusive_scan_fn final THRUST_FWD(last), THRUST_FWD(out), THRUST_FWD(init), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template >>> - THRUST_DEPRECATED auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, BinaryOp&& op) const + THRUST_FWD(op))) + + template >>> + auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, BinaryOp&& op) const // ADL dispatch. THRUST_RETURNS(async_inclusive_scan( - thrust::detail::select_system(iterator_system_t<::internal::remove_cvref_t>{}, - iterator_system_t<::internal::remove_cvref_t>{}), + thrust::detail::select_system(iterator_system_t>{}, + iterator_system_t>{}), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP + THRUST_FWD(op))) - THRUST_SUPPRESS_DEPRECATED_PUSH template - THRUST_DEPRECATED auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out) const + template + auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out) const // ADL dispatch. THRUST_RETURNS(async_inclusive_scan( - thrust::detail::select_system(iterator_system_t<::internal::remove_cvref_t>{}, - iterator_system_t<::internal::remove_cvref_t>{}), + thrust::detail::select_system(iterator_system_t>{}, + iterator_system_t>{}), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), - thrust::plus<>{})) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template >>> - THRUST_DEPRECATED auto - operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, InitialValueType&& init, BinaryOp&& op) const + thrust::plus<>{})) + + template >>> + auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, InitialValueType&& init, BinaryOp&& op) const // ADL dispatch. THRUST_RETURNS(async_inclusive_scan( - thrust::detail::select_system(iterator_system_t<::internal::remove_cvref_t>{}, - iterator_system_t<::internal::remove_cvref_t>{}), + thrust::detail::select_system(iterator_system_t>{}, + iterator_system_t>{}), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), THRUST_FWD(init), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP + THRUST_FWD(op))) }; } // namespace inclusive_scan_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT inclusive_scan_detail::inclusive_scan_fn inclusive_scan{}; namespace exclusive_scan_detail @@ -204,20 +186,18 @@ using thrust::async::unimplemented::async_exclusive_scan; // Implementation of the thrust::async::exclusive_scan CPO. struct exclusive_scan_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template - THRUST_DEPRECATED auto operator()( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& out, - InitialValueType&& init, - BinaryOp&& op) const + auto operator()(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& out, + InitialValueType&& init, + BinaryOp&& op) const // ADL dispatch. THRUST_RETURNS(async_exclusive_scan( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), @@ -225,16 +205,14 @@ struct exclusive_scan_fn final THRUST_FWD(last), THRUST_FWD(out), THRUST_FWD(init), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template - THRUST_DEPRECATED auto operator()( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& out, - InitialValueType&& init) const + THRUST_FWD(op))) + + template + auto operator()(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& out, + InitialValueType&& init) const // ADL dispatch. THRUST_RETURNS(async_exclusive_scan( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), @@ -242,80 +220,75 @@ struct exclusive_scan_fn final THRUST_FWD(last), THRUST_FWD(out), THRUST_FWD(init), - thrust::plus<>{})) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template - THRUST_DEPRECATED auto operator()( - thrust::detail::execution_policy_base const& exec, - ForwardIt&& first, - Sentinel&& last, - OutputIt&& out) const + thrust::plus<>{})) + + template + auto operator()(thrust::detail::execution_policy_base const& exec, + ForwardIt&& first, + Sentinel&& last, + OutputIt&& out) const // ADL dispatch. THRUST_RETURNS(async_exclusive_scan( thrust::detail::derived_cast(thrust::detail::strip_const(exec)), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), - iterator_value_t<::internal::remove_cvref_t>{}, - thrust::plus<>{})) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template >>> - THRUST_DEPRECATED auto - operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, InitialValueType&& init, BinaryOp&& op) const + iterator_value_t>{}, + thrust::plus<>{})) + + template >>> + auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, InitialValueType&& init, BinaryOp&& op) const // ADL dispatch. THRUST_RETURNS(async_exclusive_scan( - thrust::detail::select_system(iterator_system_t<::internal::remove_cvref_t>{}, - iterator_system_t<::internal::remove_cvref_t>{}), + thrust::detail::select_system(iterator_system_t>{}, + iterator_system_t>{}), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), THRUST_FWD(init), - THRUST_FWD(op))) THRUST_SUPPRESS_DEPRECATED_POP - - THRUST_SUPPRESS_DEPRECATED_PUSH - template >>> - THRUST_DEPRECATED auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, InitialValueType&& init) const + THRUST_FWD(op))) + + template >>> + auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out, InitialValueType&& init) const // ADL dispatch. THRUST_RETURNS(async_exclusive_scan( - thrust::detail::select_system(iterator_system_t<::internal::remove_cvref_t>{}, - iterator_system_t<::internal::remove_cvref_t>{}), + thrust::detail::select_system(iterator_system_t>{}, + iterator_system_t>{}), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), THRUST_FWD(init), - thrust::plus<>{})) THRUST_SUPPRESS_DEPRECATED_POP + thrust::plus<>{})) - THRUST_SUPPRESS_DEPRECATED_PUSH template - THRUST_DEPRECATED auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out) const + template + auto operator()(ForwardIt&& first, Sentinel&& last, OutputIt&& out) const // ADL dispatch. THRUST_RETURNS(async_exclusive_scan( - thrust::detail::select_system(iterator_system_t<::internal::remove_cvref_t>{}, - iterator_system_t<::internal::remove_cvref_t>{}), + thrust::detail::select_system(iterator_system_t>{}, + iterator_system_t>{}), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(out), - iterator_value_t<::internal::remove_cvref_t>{}, - thrust::plus<>{})) THRUST_SUPPRESS_DEPRECATED_POP + iterator_value_t>{}, + thrust::plus<>{})) }; } // namespace exclusive_scan_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT exclusive_scan_detail::exclusive_scan_fn exclusive_scan{}; +/*! \endcond + */ + } // namespace async THRUST_NAMESPACE_END diff --git a/projects/rocthrust/thrust/async/sort.h b/projects/rocthrust/thrust/async/sort.h index 62cf8fa06409..812615cbe322 100644 --- a/projects/rocthrust/thrust/async/sort.h +++ b/projects/rocthrust/thrust/async/sort.h @@ -22,24 +22,17 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #if THRUST_CPP_DIALECT >= 2017 # include # include -# include # include # include # include # include +# include THRUST_NAMESPACE_BEGIN @@ -52,16 +45,14 @@ namespace async namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST event +THRUST_HOST event async_stable_sort(thrust::execution_policy&, ForwardIt, Sentinel, StrictWeakOrdering) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -73,13 +64,11 @@ using thrust::async::unimplemented::async_stable_sort; // clang-format off struct stable_sort_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template < typename DerivedPolicy , typename ForwardIt, typename Sentinel, typename StrictWeakOrdering > THRUST_HOST - static auto call( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last @@ -93,15 +82,12 @@ struct stable_sort_fn final , THRUST_FWD(comp) ) ) - THRUST_SUPPRESS_DEPRECATED_POP -THRUST_SUPPRESS_DEPRECATED_PUSH template < typename DerivedPolicy , typename ForwardIt, typename Sentinel > THRUST_HOST - static auto call( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last @@ -112,11 +98,10 @@ THRUST_SUPPRESS_DEPRECATED_PUSH thrust::detail::derived_cast(thrust::detail::strip_const(exec)) , THRUST_FWD(first), THRUST_FWD(last) , thrust::less< - typename iterator_traits<::internal::remove_cvref_t>::value_type + typename iterator_traits>::value_type >{} ) ) - THRUST_SUPPRESS_DEPRECATED_POP template THRUST_HOST @@ -124,7 +109,7 @@ THRUST_SUPPRESS_DEPRECATED_PUSH THRUST_RETURNS( stable_sort_fn::call( thrust::detail::select_system( - typename iterator_system<::internal::remove_cvref_t>::type{} + typename iterator_system>::type{} ) , THRUST_FWD(first), THRUST_FWD(last) , THRUST_FWD(comp) @@ -138,17 +123,14 @@ THRUST_SUPPRESS_DEPRECATED_PUSH stable_sort_fn::call( THRUST_FWD(first), THRUST_FWD(last) , thrust::less< - typename iterator_traits<::internal::remove_cvref_t>::value_type + typename iterator_traits>::value_type >{} ) ) template - #if !(defined(__CUDA__) && THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG) - // clang in CUDA mode can only handle one attribute THRUST_NODISCARD THRUST_HOST - #endif - THRUST_DEPRECATED auto operator()(Args&&... args) const + auto operator()(Args&&... args) const THRUST_RETURNS( call(THRUST_FWD(args)...) ) @@ -157,22 +139,17 @@ THRUST_SUPPRESS_DEPRECATED_PUSH } // namespace stable_sort_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT stable_sort_detail::stable_sort_fn stable_sort{}; namespace fallback { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST event +THRUST_HOST event async_sort(thrust::execution_policy& exec, ForwardIt&& first, Sentinel&& last, StrictWeakOrdering&& comp) { return async_stable_sort(thrust::detail::derived_cast(exec), THRUST_FWD(first), THRUST_FWD(last), THRUST_FWD(comp)); } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace fallback @@ -184,7 +161,6 @@ using thrust::async::fallback::async_sort; // clang-format off struct sort_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template < typename DerivedPolicy , typename ForwardIt, typename Sentinel, typename StrictWeakOrdering @@ -203,7 +179,6 @@ struct sort_fn final , THRUST_FWD(comp) ) ) - THRUST_SUPPRESS_DEPRECATED_POP template < typename DerivedPolicy @@ -220,7 +195,7 @@ struct sort_fn final exec , THRUST_FWD(first), THRUST_FWD(last) , thrust::less< - typename iterator_traits<::internal::remove_cvref_t>::value_type + typename iterator_traits>::value_type >{} ) ) @@ -233,7 +208,7 @@ struct sort_fn final THRUST_RETURNS( sort_fn::call( thrust::detail::select_system( - typename iterator_system<::internal::remove_cvref_t>::type{} + typename iterator_system>::type{} ) , THRUST_FWD(first), THRUST_FWD(last) , THRUST_FWD(comp) @@ -248,7 +223,7 @@ struct sort_fn final static auto call(T1&& t1, T2&& t2, T3&& t3) THRUST_RETURNS( sort_fn::call3(THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), - thrust::is_execution_policy<::internal::remove_cvref_t>{}) + thrust::is_execution_policy>{}) ) template @@ -257,21 +232,18 @@ struct sort_fn final THRUST_RETURNS( sort_fn::call( thrust::detail::select_system( - typename iterator_system<::internal::remove_cvref_t>::type{} + typename iterator_system>::type{} ) , THRUST_FWD(first), THRUST_FWD(last) , thrust::less< - typename iterator_traits<::internal::remove_cvref_t>::value_type + typename iterator_traits>::value_type >{} ) ) template - #if !(defined(__CUDA__) && THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG) - // clang in CUDA mode can only handle one attribute THRUST_NODISCARD THRUST_HOST - #endif - THRUST_DEPRECATED auto operator()(Args&&... args) const + auto operator()(Args&&... args) const THRUST_RETURNS( call(THRUST_FWD(args)...) ) @@ -280,9 +252,6 @@ struct sort_fn final } // namespace sort_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT sort_detail::sort_fn sort{}; /*! \endcond diff --git a/projects/rocthrust/thrust/async/transform.h b/projects/rocthrust/thrust/async/transform.h index bd5c5c86dd0c..58608e39343a 100644 --- a/projects/rocthrust/thrust/async/transform.h +++ b/projects/rocthrust/thrust/async/transform.h @@ -22,22 +22,15 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #if THRUST_CPP_DIALECT >= 2017 # include # include -# include # include # include +# include THRUST_NAMESPACE_BEGIN @@ -50,20 +43,14 @@ namespace async namespace unimplemented { -THRUST_SUPPRESS_DEPRECATED_PUSH template -THRUST_DEPRECATED THRUST_HOST event async_transform( - thrust::execution_policy& /*exec*/, - ForwardIt /*first*/, - Sentinel /*last*/, - OutputIt /*output*/, - UnaryOperation /*op*/) +THRUST_HOST event +async_transform(thrust::execution_policy&, ForwardIt, Sentinel, OutputIt, UnaryOperation) { THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation::value), "this algorithm is not implemented for the specified system"); return {}; } -THRUST_SUPPRESS_DEPRECATED_POP } // namespace unimplemented @@ -75,7 +62,6 @@ using thrust::async::unimplemented::async_transform; // clang-format off struct transform_fn final { - THRUST_SUPPRESS_DEPRECATED_PUSH template < typename DerivedPolicy , typename ForwardIt, typename Sentinel, typename OutputIt @@ -98,7 +84,6 @@ struct transform_fn final , THRUST_FWD(op) ) ) - THRUST_SUPPRESS_DEPRECATED_POP template < typename ForwardIt, typename Sentinel, typename OutputIt @@ -113,8 +98,8 @@ struct transform_fn final THRUST_RETURNS( transform_fn::call( thrust::detail::select_system( - typename iterator_system<::internal::remove_cvref_t>::type{} - , typename iterator_system<::internal::remove_cvref_t>::type{} + typename iterator_system>::type{} + , typename iterator_system>::type{} ) , THRUST_FWD(first), THRUST_FWD(last) , THRUST_FWD(output) @@ -123,8 +108,8 @@ struct transform_fn final ) template - THRUST_NODISCARD THRUST_DEPRECATED THRUST_HOST - auto operator()(Args&&... args) const + THRUST_NODISCARD THRUST_HOST + auto operator()(Args&&... args) const THRUST_RETURNS( call(THRUST_FWD(args)...) ) @@ -133,9 +118,6 @@ struct transform_fn final } // namespace transform_detail -// note: cannot add a THRUST_DEPRECATED here because the global variable is emitted into cudafe1.stub.c and we cannot -// suppress the warning there -//! deprecated [Since 2.8.0] THRUST_INLINE_CONSTANT transform_detail::transform_fn transform{}; /*! \endcond diff --git a/projects/rocthrust/thrust/detail/alignment.h b/projects/rocthrust/thrust/detail/alignment.h index ddcbd4bf0ece..dc162e4f5869 100644 --- a/projects/rocthrust/thrust/detail/alignment.h +++ b/projects/rocthrust/thrust/detail/alignment.h @@ -29,7 +29,6 @@ # pragma system_header #endif // no system header -#include _THRUST_STD_INCLUDE(cstddef) // For `std::size_t` and `std::max_align_t`. #include _THRUST_STD_INCLUDE(type_traits) // For `std::alignment_of`. #if _THRUST_HAS_DEVICE_SYSTEM_STD @@ -38,6 +37,8 @@ # include #endif +#include // For `std::size_t` and `std::max_align_t`. + THRUST_NAMESPACE_BEGIN namespace detail { @@ -53,7 +54,7 @@ using alignment_of = _THRUST_STD::alignment_of; /// type whose alignment requirement is a divisor of `Align`. /// /// The behavior is undefined if `Align` is not a power of 2. -template <_THRUST_STD::size_t Align> +template struct aligned_type { struct alignas(Align) type @@ -78,7 +79,7 @@ THRUST_HOST_DEVICE T aligned_reinterpret_cast(U u) return reinterpret_cast(reinterpret_cast(u)); } -THRUST_HOST_DEVICE inline _THRUST_STD::size_t aligned_storage_size(_THRUST_STD::size_t n, _THRUST_STD::size_t align) +THRUST_HOST_DEVICE inline std::size_t aligned_storage_size(std::size_t n, std::size_t align) { #if _THRUST_HAS_DEVICE_SYSTEM_STD return _THRUST_LIBCXX::ceil_div(n, align) * align; diff --git a/projects/rocthrust/thrust/detail/allocator_aware_execution_policy.h b/projects/rocthrust/thrust/detail/allocator_aware_execution_policy.h index ee1c25a6c6bf..a69147496573 100644 --- a/projects/rocthrust/thrust/detail/allocator_aware_execution_policy.h +++ b/projects/rocthrust/thrust/detail/allocator_aware_execution_policy.h @@ -18,17 +18,10 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #include -#include _THRUST_STD_INCLUDE(type_traits) +#include THRUST_NAMESPACE_BEGIN @@ -59,24 +52,20 @@ struct allocator_aware_execution_policy using type = thrust::detail::execute_with_allocator; }; - THRUST_EXEC_CHECK_DISABLE template - THRUST_HOST_DEVICE typename execute_with_memory_resource_type::type - operator()(MemoryResource* mem_res) const + typename execute_with_memory_resource_type::type operator()(MemoryResource* mem_res) const { return typename execute_with_memory_resource_type::type(mem_res); } - THRUST_EXEC_CHECK_DISABLE template - THRUST_HOST_DEVICE typename execute_with_allocator_type::type operator()(Allocator& alloc) const + typename execute_with_allocator_type::type operator()(Allocator& alloc) const { return typename execute_with_allocator_type::type(alloc); } - THRUST_EXEC_CHECK_DISABLE template - THRUST_HOST_DEVICE typename execute_with_allocator_type::type operator()(const Allocator& alloc) const + typename execute_with_allocator_type::type operator()(const Allocator& alloc) const { return typename execute_with_allocator_type::type(alloc); } @@ -84,12 +73,10 @@ struct allocator_aware_execution_policy // just the rvalue overload // perfect forwarding doesn't help, because a const reference has to be turned // into a value by copying for the purpose of storing it in execute_with_allocator - THRUST_EXEC_CHECK_DISABLE - template ::value>::type* = nullptr> - THRUST_HOST_DEVICE typename execute_with_allocator_type::type operator()(Allocator&& alloc) const + template ::value>::type* = nullptr> + typename execute_with_allocator_type::type operator()(Allocator&& alloc) const { - return typename execute_with_allocator_type::type(_THRUST_STD::move(alloc)); + return typename execute_with_allocator_type::type(std::move(alloc)); } }; diff --git a/projects/rocthrust/thrust/detail/config/cpp_compatibility.h b/projects/rocthrust/thrust/detail/config/cpp_compatibility.h index ccd77729e009..19017ecb28a6 100644 --- a/projects/rocthrust/thrust/detail/config/cpp_compatibility.h +++ b/projects/rocthrust/thrust/detail/config/cpp_compatibility.h @@ -27,42 +27,60 @@ # pragma system_header #endif // no system header -#if !_THRUST_HAS_DEVICE_SYSTEM_STD -# include // IWYU pragma: export -# include // IWYU pragma: export +#include // IWYU pragma: export + +#include + +#ifdef __has_cpp_attribute +# define THRUST_HAS_CPP_ATTRIBUTE(__x) __has_cpp_attribute(__x) +#else // ^^^ __has_cpp_attribute ^^^ / vvv !__has_cpp_attribute vvv +# define THRUST_HAS_CPP_ATTRIBUTE(__x) 0 +#endif // !__has_cpp_attribute + +#if THRUST_HAS_CPP_ATTRIBUTE(nodiscard) \ + || ((THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && THRUST_CPP_DIALECT >= 2017) +# define THRUST_NODISCARD [[nodiscard]] +#else // ^^^ has nodiscard ^^^ / vvv no nodiscard vvv +# define THRUST_NODISCARD +#endif // no nodiscard + +// NVCC below 11.3 does not support nodiscard on friend operators +// It always fails with clang +#if (defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ <= 11 && __CUDACC_VER_MINOR__ < 3)) \ + || THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG +# define THRUST_NODISCARD_FRIEND friend +#else +# define THRUST_NODISCARD_FRIEND THRUST_NODISCARD friend #endif -// deprecated [Since 2.8.0] -#if _THRUST_HAS_DEVICE_SYSTEM_STD -# define THRUST_NODISCARD _CCCL_NODISCARD +#if THRUST_CPP_DIALECT >= 2017 && defined(__cpp_if_constexpr) +# define THRUST_IF_CONSTEXPR if constexpr +# define THRUST_ELSE_IF_CONSTEXPR else if constexpr +#else // ^^^ C++17 ^^^ / vvv C++14 vvv +# define THRUST_IF_CONSTEXPR if +# define THRUST_ELSE_IF_CONSTEXPR else if +#endif // THRUST_CPP_DIALECT <= 2014 + +// FIXME: Combine THRUST_INLINE_CONSTANT and +// THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT into one macro when NVCC properly +// supports `constexpr` globals in host and device code. +#if defined(__CUDA_ARCH__) || defined(_NVHPC_CUDA) +// FIXME: Add this when NVCC supports inline variables. +// # if THRUST_CPP_DIALECT >= 2017 +// # define THRUST_INLINE_CONSTANT inline constexpr +// # define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr +# define THRUST_INLINE_CONSTANT static const _CCCL_DEVICE +# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr + #else -# ifdef __has_cpp_attribute -# define THRUST_HAS_CPP_ATTRIBUTE(__x) __has_cpp_attribute(__x) -# else // ^^^ __has_cpp_attribute ^^^ / vvv !__has_cpp_attribute vvv -# define THRUST_HAS_CPP_ATTRIBUTE(__x) 0 -# endif // !__has_cpp_attribute -# if THRUST_HAS_CPP_ATTRIBUTE(nodiscard) \ - || ((THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && THRUST_CPP_DIALECT >= 2017) -# define THRUST_NODISCARD [[nodiscard]] -# else // ^^^ has nodiscard ^^^ / vvv no nodiscard vvv -# define THRUST_NODISCARD -# endif // no nodiscard -# undef THRUST_HAS_CPP_ATTRIBUTE +// FIXME: Add this when NVCC supports inline variables. +// # if THRUST_CPP_DIALECT >= 2017 +// # define THRUST_INLINE_CONSTANT inline constexpr +// # define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT inline constexpr +# define THRUST_INLINE_CONSTANT static constexpr +# define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr + #endif -// deprecated [Since 2.8.0] -#if defined(__CUDA_ARCH__) -# if defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ < 11 || (__CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ < 3)) -# define THRUST_INLINE_CONSTANT THRUST_DEVICE const -# else -# define THRUST_INLINE_CONSTANT THRUST_DEVICE constexpr -# endif -#elif defined(__HIP__) -# define THRUST_INLINE_CONSTANT THRUST_DEVICE constexpr -#else // ^^^ __CUDA_ARCH__ ^^^ / vvv !__CUDA_ARCH__ vvv -# define THRUST_INLINE_CONSTANT inline constexpr -#endif // __CUDA_ARCH__ -// deprecated [Since 2.8.0] -#define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_HIP // libcu++ still needs to be ported to HIP, so for HIP backend these definitions @@ -106,18 +124,3 @@ # endif # endif // THRUST_PROVIDE_LEGACY_ARCH_MACROS #endif - -// NVCC below 11.3 does not support nodiscard on friend operators -// It always fails with clang -#if (defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ < 11 || (__CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ < 3))) \ - || THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG -# define THRUST_NODISCARD_FRIEND friend -#else -# define THRUST_NODISCARD_FRIEND THRUST_NODISCARD friend -#endif - -#if THRUST_CPP_DIALECT <= 2014 || (defined(__cpp_if_constexpr) && __cpp_if_constexpr < 201606L) -# define THRUST_IF_CONSTEXPR if -#else // ^^^ C++14 ^^^ / vvv C++17 vvv -# define THRUST_IF_CONSTEXPR if constexpr -#endif // THRUST_CPP_DIALECT > 2014 diff --git a/projects/rocthrust/thrust/detail/config/cpp_dialect.h b/projects/rocthrust/thrust/detail/config/cpp_dialect.h index c3fc343b7d81..af5f8de24a3f 100644 --- a/projects/rocthrust/thrust/detail/config/cpp_dialect.h +++ b/projects/rocthrust/thrust/detail/config/cpp_dialect.h @@ -138,7 +138,7 @@ #endif // Define THRUST_COMPILER_DEPRECATION macro: -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC || THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_NVRTC +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC # define THRUST_COMP_DEPR_IMPL(msg) THRUST_PRAGMA(message(__FILE__ ":" THRUST_TO_STRING(__LINE__) ": warning: " #msg)) #else // clang / gcc: # define THRUST_COMP_DEPR_IMPL(msg) THRUST_PRAGMA(GCC warning #msg) diff --git a/projects/rocthrust/thrust/detail/dependencies_aware_execution_policy.h b/projects/rocthrust/thrust/detail/dependencies_aware_execution_policy.h index b1c26cf7e760..e56662a3f0b5 100644 --- a/projects/rocthrust/thrust/detail/dependencies_aware_execution_policy.h +++ b/projects/rocthrust/thrust/detail/dependencies_aware_execution_policy.h @@ -18,25 +18,17 @@ #include -#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) -# pragma GCC system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) -# pragma clang system_header -#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) -# pragma system_header -#endif // no system header #include #include -THRUST_SUPPRESS_DEPRECATED_PUSH THRUST_NAMESPACE_BEGIN namespace detail { template