Skip to content

Commit

Permalink
Refactor Thrust iterators 1/n (#3839)
Browse files Browse the repository at this point in the history
* Refactor constant_iterator
* Refactor counting_iterator
  • Loading branch information
bernhardmgruber authored Feb 19, 2025
1 parent 297447e commit fd86263
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 538 deletions.
17 changes: 16 additions & 1 deletion thrust/testing/copy.cu
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,30 @@ template <>
struct is_non_const_reference<only_set_when_expected_it> : thrust::true_type
{};
} // end namespace detail
THRUST_NAMESPACE_END

namespace std
{
template <>
struct iterator_traits<only_set_when_expected_it>
{
using value_type = long long;
using reference = only_set_when_expected_it;
using iterator_category = thrust::random_access_device_iterator_tag;
using difference_type = ::cuda::std::ptrdiff_t;
};
THRUST_NAMESPACE_END
} // namespace std

_LIBCUDACXX_BEGIN_NAMESPACE_STD
template <>
struct iterator_traits<only_set_when_expected_it>
{
using value_type = long long;
using reference = only_set_when_expected_it;
using iterator_category = thrust::random_access_device_iterator_tag;
using difference_type = ::cuda::std::ptrdiff_t;
};
_LIBCUDACXX_END_NAMESPACE_STD

void TestCopyWithBigIndexesHelper(int magnitude)
{
Expand Down
21 changes: 12 additions & 9 deletions thrust/testing/scan.cu
Original file line number Diff line number Diff line change
Expand Up @@ -565,24 +565,27 @@ struct only_set_when_expected_it
}
};

THRUST_NAMESPACE_BEGIN
namespace std
{
template <>
struct iterator_traits<only_set_when_expected_it>
{
using value_type = long long;
using reference = only_set_when_expected_it;
using value_type = long long;
using reference = only_set_when_expected_it;
using difference_type = ::cuda::std::ptrdiff_t;
};
THRUST_NAMESPACE_END
} // namespace std

namespace std
{
_LIBCUDACXX_BEGIN_NAMESPACE_STD
template <>
struct iterator_traits<only_set_when_expected_it>
{
using value_type = long long;
using reference = only_set_when_expected_it;
using value_type = long long;
using reference = only_set_when_expected_it;
using iterator_category = thrust::random_access_device_iterator_tag;
using difference_type = ::cuda::std::ptrdiff_t;
};
} // namespace std
_LIBCUDACXX_END_NAMESPACE_STD

void TestInclusiveScanWithBigIndexesHelper(int magnitude)
{
Expand Down
Loading

0 comments on commit fd86263

Please sign in to comment.