|
| 1 | +#include <thrust/device_vector.h> |
| 2 | +#include <thrust/iterator/counting_iterator.h> |
| 3 | +#include <thrust/iterator/iterator_traits.h> |
| 4 | +#include <thrust/iterator/transform_iterator.h> |
| 5 | +#include <thrust/iterator/zip_iterator.h> |
| 6 | + |
| 7 | +#include "catch2_test_helper.h" |
| 8 | + |
| 9 | +TEST_CASE("iterator system propagation - any system", "[iterators]") |
| 10 | +{ |
| 11 | + [[maybe_unused]] auto counting_it = thrust::make_counting_iterator(0); |
| 12 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(counting_it)>, thrust::any_system_tag>); |
| 13 | + |
| 14 | + [[maybe_unused]] auto transform_it = thrust::make_transform_iterator(counting_it, thrust::square<>{}); |
| 15 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(transform_it)>, thrust::any_system_tag>); |
| 16 | + |
| 17 | + [[maybe_unused]] auto zip_it = thrust::make_zip_iterator(counting_it, transform_it); |
| 18 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(zip_it)>, thrust::any_system_tag>); |
| 19 | +} |
| 20 | + |
| 21 | +TEST_CASE("iterator system propagation - device system", "[iterators]") |
| 22 | +{ |
| 23 | + [[maybe_unused]] auto d_vec = thrust::device_vector<int>{}; |
| 24 | + [[maybe_unused]] auto d_vec_it = d_vec.begin(); |
| 25 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(d_vec_it)>, thrust::device_system_tag>); |
| 26 | + |
| 27 | + [[maybe_unused]] auto transform_it = thrust::make_transform_iterator(d_vec_it, thrust::square<>{}); |
| 28 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(transform_it)>, thrust::device_system_tag>); |
| 29 | + |
| 30 | + [[maybe_unused]] auto zip_it = thrust::make_zip_iterator(d_vec_it, transform_it); |
| 31 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(zip_it)>, thrust::device_system_tag>); |
| 32 | +} |
| 33 | + |
| 34 | +TEST_CASE("iterator system propagation - any and device system", "[iterators]") |
| 35 | +{ |
| 36 | + [[maybe_unused]] auto d_vec = thrust::device_vector<int>{}; |
| 37 | + [[maybe_unused]] auto d_vec_it = d_vec.begin(); |
| 38 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(d_vec_it)>, thrust::device_system_tag>); |
| 39 | + |
| 40 | + [[maybe_unused]] auto counting_it = thrust::make_counting_iterator(0); |
| 41 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(counting_it)>, thrust::any_system_tag>); |
| 42 | + |
| 43 | + [[maybe_unused]] auto zip_it = thrust::make_zip_iterator(d_vec_it, counting_it); |
| 44 | + STATIC_REQUIRE(cuda::std::is_same_v<thrust::iterator_system_t<decltype(zip_it)>, thrust::device_system_tag>); |
| 45 | +} |
0 commit comments