NVIDIA / NVIDIA/cccl

cuda.parallel: Should `stream` be a required parameter?

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

Description

In https://github.com/NVIDIA/cccl/pull/3348#discussion_r1912058809, it came up that we may want to consider making `stream` a required argument wherever a CUDA stream can be passed.

At the moment, `stream` is not a required parameter and defaults to `None` (translating to nullptr or "default stream" at the C++ layer). This aligns with underlying C++ APIs which also use `stream=0` as a default ([example](https://nvidia.github.io/cccl/cub/api/structcub_1_1DeviceReduce.html?highlight=devicereduce)).

However, as pointed out in the discussion above, users can forget to pass a stream in situations like the following:

```python
with stream as s:
arr = cp.random.random(...)

reduce_into(..., d_in=arr, ...) # forgot to pass s here for whatever reason
```

This is seemingly a broader problem in the ecosystem (any API from any library accepting a CUDA stream has the same problem). So it would be good to hear perspectives from e.g., @vyasr as I know cuDF is also considering exposing streams in their APIs.

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.