Skip to content

cub: change {Lower,Upper}Bound to accept iterator and number of elements.#7446

Open
griwes wants to merge 3 commits intoNVIDIA:mainfrom
griwes:bug/binary-search-num-items-not-last-iterator
Open

cub: change {Lower,Upper}Bound to accept iterator and number of elements.#7446
griwes wants to merge 3 commits intoNVIDIA:mainfrom
griwes:bug/binary-search-num-items-not-last-iterator

Conversation

@griwes
Copy link
Contributor

@griwes griwes commented Jan 30, 2026

Description

Change the interface of DeviceFind::{Lower,Upper}Bound from accepting pairs of iterators to accepting a begin iterator and item count, to be more consistent with most of the other interfaces in CUB.

Resolves #7445.

Checklist

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

@griwes griwes requested review from a team as code owners January 30, 2026 23:02
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 30, 2026
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Jan 30, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.


template <typename Mode, typename RangeIteratorT, typename CompareOpT>
_CCCL_HOST_DEVICE auto make_comp_wrapper(RangeIteratorT first, RangeIteratorT last, CompareOpT comp)
template <typename Mode, typename RangeIteratorT, typename RangeNumItemsT, typename CompareOpT>
Copy link
Contributor

Choose a reason for hiding this comment

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

Blasphemeous question, why not have both interfaces and store distance(first, last) in the iterator based entry point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We require RAI, so this is straightforward for the user to do with just last - first.

Comment on lines +201 to +204
::cuda::make_zip_iterator(d_values, d_output),
static_cast<ValuesOffsetT>(values_num_items),
detail::find::make_comp_wrapper<detail::find::lower_bound>(
d_range, static_cast<RangeOffsetT>(range_num_items), comp),
Copy link
Contributor

Choose a reason for hiding this comment

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

What if values_num_items is smaller than range_num_items?

Also we are using values_num_items in one place and range_num_items in the other

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, those are two separate ranges, we're doing for each over values, and letting each thread know about the whole range of input elements.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

🥳 CI Workflow Results

🟩 Finished in 10h 17m: Pass: 100%/104 | Total: 5d 13h | Max: 5h 54m | Hits: 57%/110171

See results here.

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

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

Change cub::DeviceFind::{Lower,Upper}Bound to use iterator + count instead of iterator pairs

3 participants