Sparse-checkout from NVIDIA/cccl main branch to complete cccl_upstream: Added: - python/cuda_cccl/ (226 files) — Python bindings for device-level algorithms Critical for muh toolchain: cuda.compute.reduce_into, scan, radix_sort, etc. Includes 204 .py files with full test coverage for all 27 algorithms - ci/ (163 files) — Build/test infrastructure build_cub.sh, test_cub.sh, build_and_test_targets.sh, matrix.yaml Directly maps to our [INFRA-CI] and [INFRA-BUILD] items - .agent/skills/ (7 files) — NVIDIA's own agent skills for CCCL cccl-style/SKILL.md, cccl-test/SKILL.md, sass-diff/SKILL.md - docs/ (491 files) — Official CCCL documentation CI references, CMake guides, Python compute docs, libcudacxx PTX docs - test/ (12 files) — Top-level integration tests (cuda_smoke, stdpar) - Root configs: .clang-format, .clang-tidy, CONTRIBUTING.md, pyproject.toml - CLAUDE.md symlink → AGENTS.md (NVIDIA's standard) cccl_upstream now mirrors full NVIDIA/cccl structure: Before: 42M (cub + thrust + libcudacxx + cudax + c + examples + benchmarks) After: 53M (+python +ci +docs +.agent +test +configs) This completes the CCCL base needed for: - [muh-bench] items: ci/util/build_and_test_targets.sh for targeted builds - [CCCL-verify] items: python/cuda_cccl/tests/ as reference implementations - [CCCL-test] items: ci/test_cub.sh, ci/test_thrust.sh - Agent workflow: .agent/skills/ for consistent style and test patterns
71 lines
2.3 KiB
ReStructuredText
71 lines
2.3 KiB
ReStructuredText
.. _cccl-runtime-stream:
|
|
|
|
Streams
|
|
========
|
|
|
|
Stream is conceptually a queue of operations for a specific device. It is passed as an argument to all asynchronous operations like kernel launch, memory copy and allocations.
|
|
|
|
:cpp:class:`cuda::stream_ref`
|
|
-------------------------------
|
|
.. _cccl-runtime-stream-stream-ref:
|
|
|
|
:cpp:class:`cuda::stream_ref` is a non-owning wrapper around a ``cudaStream_t``. It prevents unsafe implicit constructions from
|
|
``nullptr`` or integer literals and provides convenient helpers for:
|
|
|
|
- ``sync()``: wait for the recorded work to complete
|
|
- ``is_done()``: non-blocking completion query
|
|
- comparison operators against other :cpp:class:`cuda::stream_ref` or ``cudaStream_t``
|
|
|
|
Availability: CCCL 2.2.0 / CUDA 12.3
|
|
|
|
Example:
|
|
|
|
.. code:: cpp
|
|
|
|
#include <cuda/stream>
|
|
|
|
cudaStream_t stream;
|
|
cudaStreamCreate(&stream);
|
|
cuda::stream_ref ref{stream};
|
|
|
|
ref.sync(); // synchronizes the stream via cudaStreamSynchronize
|
|
assert(ref.is_done()); // verifies that the stream has finished all operations via cudaStreamQuery
|
|
|
|
// compare against other stream_ref or cudaStream_t
|
|
assert(ref == stream);
|
|
assert(ref != cuda::invalid_stream);
|
|
|
|
cudaStreamDestroy(stream);
|
|
|
|
:cpp:struct:`cuda::stream`
|
|
---------------------------
|
|
.. _cccl-runtime-stream-stream:
|
|
|
|
:cpp:struct:`cuda::stream` is an owning wrapper around a ``cudaStream_t`` that manages the lifetime of the underlying CUDA
|
|
stream.
|
|
It derives from :cpp:class:`cuda::stream_ref`, provides all of its functionality, and can be used anywhere a
|
|
:cpp:class:`cuda::stream_ref` is expected.
|
|
It can be constructed for a specific :cpp:class:`cuda::device_ref`, moved (but not copied), and converted from or to a
|
|
``cudaStream_t`` via ``from_native_handle``/``release()``.
|
|
Constructing a new :cpp:struct:`cuda::stream` always creates a non-blocking stream; see
|
|
:ref:`non-blocking stream creation <cccl-runtime-cudart-non-blocking-streams>` for CUDA Runtime interop details.
|
|
|
|
Availability: CCCL 3.1.0 / CUDA 13.1
|
|
|
|
.. code:: cpp
|
|
|
|
#include <cuda/stream>
|
|
#include <cuda/devices>
|
|
|
|
int main() {
|
|
{
|
|
// Create a stream on a specific device
|
|
cuda::stream s{cuda::devices[0]};
|
|
|
|
// Pass to a stream-ordered API
|
|
|
|
// Synchronize the stream
|
|
s.sync();
|
|
} // Stream is automatically destroyed here
|
|
}
|