Skip to content

Replace thrust::discard_iterator with cuda::discard_iterator#8276

Draft
Jacobfaib wants to merge 20 commits intoNVIDIA:mainfrom
Jacobfaib:jacobf/2026-04-02/drop-thrust-discard-iterator
Draft

Replace thrust::discard_iterator with cuda::discard_iterator#8276
Jacobfaib wants to merge 20 commits intoNVIDIA:mainfrom
Jacobfaib:jacobf/2026-04-02/drop-thrust-discard-iterator

Conversation

@Jacobfaib
Copy link
Copy Markdown
Contributor

Description

Replaces thrust::discard_iterator with cuda::discard_iterator

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@Jacobfaib Jacobfaib self-assigned this Apr 2, 2026
@github-project-automation github-project-automation bot moved this to Todo in CCCL Apr 2, 2026
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Apr 2, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Progress in CCCL Apr 2, 2026
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

1 similar comment
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

3 similar comments
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@Jacobfaib Jacobfaib force-pushed the jacobf/2026-04-02/drop-thrust-discard-iterator branch from 2102745 to 3e05e79 Compare April 2, 2026 20:19
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

1 similar comment
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

1 similar comment
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib Jacobfaib force-pushed the jacobf/2026-04-02/drop-thrust-discard-iterator branch from f39b18b to f391578 Compare April 8, 2026 14:11
@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

This comment has been minimized.

@Jacobfaib
Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

😬 CI Workflow Results

🟥 Finished in 2h 48m: Pass: 96%/375 | Total: 13d 09h | Max: 2h 44m | Hits: 80%/526850

See results here.

static_assert(::cuda::std::is_invocable_v<Generator>, "The passed generator must be a nullary function object");
static_assert(
::cuda::std::is_assignable_v<detail::it_reference_t<RandomAccessIteratorOut>,
::cuda::std::is_assignable_v<::cuda::std::iter_reference_t<RandomAccessIteratorOut>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: This is a change in semantics, why is this necessary?

See:

// the following iterator helpers are not named iter_value_t etc, like the C++20 facilities, because they are defined in
// terms of C++17 iterator_traits and not the new C++20 indirectly_readable trait etc. This allows them to detect nested
// value_type, difference_type and reference aliases, which the new C+20 traits do not consider (they only consider
// specializations of iterator_traits). Also, a value_type of void remains supported (needed by some output iterators).
template <typename It>
using it_value_t = typename ::cuda::std::iterator_traits<It>::value_type;
template <typename It>
using it_reference_t = typename ::cuda::std::iterator_traits<It>::reference;
template <typename It>
using it_difference_t = typename ::cuda::std::iterator_traits<It>::difference_type;
template <typename It>
using it_pointer_t = typename ::cuda::std::iterator_traits<It>::pointer;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the other comment. There is a change in value_type between the iterators which is not handled by CUB.

#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/discard_iterator.h>
#include <cuda/iterator>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: Please revert. We want to continue to test the old iterator with NVRTC.

Comment on lines +939 to +940
using InputT = non_void_value_t<InputIteratorT, it_value_t<OutputIteratorT>>;
using OutputT = non_void_value_t<OutputIteratorT, it_value_t<InputIteratorT>>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: This is probably wrong, since we cannot just take the traits of the input type in case we have no output type.

Why is this necessary? Which test is failing?

Copy link
Copy Markdown
Contributor Author

@Jacobfaib Jacobfaib Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cuda::discard_iterator::value_type is void, while thrust::discard_iterator::value_type is not. Many CUB algorithms seemingly don't handle this properly and/or had special handling for thrust::discard_iterator (or other proxy iterators) and so failed to compile with the new discard iterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants