Skip to content

Conversation

@IvanGrigorik
Copy link
Collaborator

@IvanGrigorik IvanGrigorik commented Dec 15, 2025

Add lower and upper bound using binary search
Tested for CUDA and OpenMP

API similar to standard thrust::upper_bound: https://nvidia.github.io/cccl/thrust/api/group__binary__search_1gac85cc9ea00f4bdd8f80ad25fff16741d.html

# Thrust:
thrust::upper_bound(ForwardIterator first, ForwardIterator last, const LessThanComparable &value ) # -> return iterator
thrust::lower_bound(ForwardIterator first, ForwardIterator last, const GreaterThanComparable &value ) # -> return iterator

# Ours:
pk.upper_bound(view: pk.View, lastIndex: int, lessThanValue: int) # -> return int
pk.lower_bound(view: pk.View, lastIndex: int, greaterThanValue: int) # -> return int

Same for lower_bound
One of the student asked to implement this in order to use it from pykokkos workunits, since they needed this operation in their research

@IvanGrigorik IvanGrigorik force-pushed the grigorik/upper_bound branch 2 times, most recently from 175373c to f3ac713 Compare December 15, 2025 04:00
@gliga
Copy link
Contributor

gliga commented Dec 17, 2025

Is this closing any PR? Why is this necessary? Are we matching any API?
This should all be documented in the description of the PR.

@IvanGrigorik
Copy link
Collaborator Author

IvanGrigorik commented Dec 17, 2025

Updated description

Copy link
Contributor

@gliga gliga left a comment

Choose a reason for hiding this comment

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

Is it sufficient to work only with ints?

@IvanGrigorik
Copy link
Collaborator Author

For some reason tests fails due unknown reason. I couldn't reproduce but on my local machine nor on our local server
@kennykos was able to reproduce issue, but I cant help him, since it's on the server that I can not access

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants