[FEA]: Input validation for CUB device API
- 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.
Currently, there is no mechanism to perform basic validation of user input of CUB device API. Implementing this feature would help users immediately understand misuse of the API and detect bugs. An example:
```
DeviceSegmentedRadixSort::SortKeys(
void* d_temp_storage,
size_t& temp_storage_bytes,
const KeyT* d_keys_in,
KeyT* d_keys_out,
int num_items,
int num_segments,
BeginOffsetIteratorT d_begin_offsets,
EndOffsetIteratorT d_end_offsets,
int begin_bit = 0,
int end_bit = sizeof(KeyT) * 8,
cudaStream_t stream = 0)
```
The following conditions could be verified:
- `d_keys_in/d_keys_out` must not be `nullptr` if `d_temp_storage!=nullptr`
- `d_keys_in/d_keys_out` must not overlap
- `num_items/num_segments` must be >= 0
- `BeginOffsetIteratorT/EndOffsetIteratorT/KeyT` should have some constrains that can be statically verified
- `begin_bit/end_bit` must be in `[0, sizeof(KeyT) * 8]`
- `begin_bit <= end_bit`
- `temp_storage_bytes` should be >= temporary buffer size if `d_temp_storage!=nullptr`
- `stream` must not be `nullptr` in graph capture mode
### Describe the solution you'd like
basic input validation for the main API at the top-level call
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.