NVIDIA / NVIDIA/cccl

[REFACTOR] cuda.parallel: Don't require passing input/output arrays to `reduce_into` and similar algorithms

Open
#3,008 2 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

Currently, `reduce_into` usage looks like:

```python
# construct the reduer:
reducer = cudax.reduce_into(d_in, d_out, op, h_init)

# allocate temp storage
temp_storage_bytes = reducer.reduce_into(None, d_in, d_out, op, h_init)
d_temp = cuda.device_array(temp_storage_bytes)
result = reducer.reduce_into(d_temp, d_in, d_out, op, h_init)
```

Note that the initial construction of `reducer` shouldn't strictly need the arguments `d_in`, `d_out`, `h_init`. In fact, passing any placeholder arrays of the same data type will serve the same purpose.

We should refactor such that only the required information is passed into the constructor.

## Additional Context

https://github.com/NVIDIA/cccl/pull/3001/#discussion_r1866733390

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.