NVIDIA / NVIDIA/cccl

[FEA]: DeviceReduce argument version with user-defined reduction

Open
#1,609 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [X] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Area

CUB

### Is your feature request related to a problem? Please describe.

I encountered this problem:
Given an unsigned integer array, find if there's any "1" bits, and if so, find the first location.
I can use DeviceReduce::Max to check if there's any "1"s, but I'm not sure how to do the other.
One way is to create a new array and copy the values as 0 if it's 0 and 1 if it's non-zero, then do an ArgMax to find the index, then copy that element in the original array to the host and find the bit, but it's kind of awkward. Or just copy the entire array to host and do it on CPU.

### Describe the solution you'd like

If there is an argument reduction with user-defined reduction, this would be much easier.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.