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
82 lines
2.6 KiB
ReStructuredText
82 lines
2.6 KiB
ReStructuredText
.. _cccl-runtime-event:
|
|
|
|
Events
|
|
======
|
|
|
|
Event is a snapshot of execution state of a stream. It can be used to synchronize work submitted to a stream up to a certain point, establish dependency between streams or measure time passed between two events.
|
|
|
|
:cpp:class:`cuda::event_ref`
|
|
--------------------------------------------------
|
|
.. _cccl-runtime-event-event-ref:
|
|
|
|
:cpp:class:`cuda::event_ref` is a non-owning wrapper around a ``cudaEvent_t``. It prevents unsafe implicit constructions from
|
|
``nullptr`` or integer literals and provides convenient helpers:
|
|
|
|
- ``record(cuda::stream_ref)``: record the event on a stream
|
|
- ``sync()``: wait for the recorded work to complete
|
|
- ``is_done()``: non-blocking completion query
|
|
- comparison operators against other :cpp:class:`cuda::event_ref` or ``cudaEvent_t``
|
|
|
|
Availability: CCCL 3.1.0 / CUDA 13.1
|
|
|
|
Example:
|
|
|
|
.. code:: cpp
|
|
|
|
#include <cuda/stream>
|
|
|
|
void record_on_stream(cuda::stream_ref stream, cudaEvent_t raw_handle) {
|
|
cuda::event_ref e{raw_handle};
|
|
e.record(stream);
|
|
}
|
|
|
|
:cpp:class:`cuda::event`
|
|
--------------------------------------------
|
|
.. _cccl-runtime-event-event:
|
|
|
|
:cpp:class:`cuda::event` is an owning wrapper around a ``cudaEvent_t`` (with timing disabled). It inherits from
|
|
:cpp:class:`cuda::event_ref` and provides all of its functionality. It also creates and destroys the native event, can be moved (but
|
|
not copied), and can release ownership via ``release()``. Construction can target a specific :cpp:class:`cuda::device_ref`
|
|
or record immediately on a :cpp:class:`cuda::stream_ref`.
|
|
|
|
Availability: CCCL 3.1.0 / CUDA 13.1
|
|
|
|
.. code:: cpp
|
|
|
|
#include <cuda/stream>
|
|
#include <cuda/devices>
|
|
#include <cuda/std/optional>
|
|
|
|
cuda::std::optional<cuda::event> query_and_record_on_stream(cuda::stream_ref stream) {
|
|
if (stream.is_done()) {
|
|
return cuda::std::nullopt;
|
|
} else {
|
|
return cuda::event{stream};
|
|
}
|
|
}
|
|
|
|
.. _cccl-runtime-event-timed-event:
|
|
|
|
:cpp:class:`cuda::timed_event`
|
|
-----------------------------------------------------
|
|
|
|
:cpp:class:`cuda::timed_event` is an owning wrapper for a timed ``cudaEvent_t``. It inherits from :cpp:class:`cuda::event` and provides
|
|
all of its functionality.
|
|
It also supports elapsed-time queries between two events via ``operator-``, returning
|
|
:cpp:class:`cuda::std::chrono::nanoseconds`.
|
|
|
|
Availability: CCCL 3.1.0 / CUDA 13.1
|
|
|
|
.. code:: cpp
|
|
|
|
#include <cuda/stream>
|
|
#include <cuda/std/chrono>
|
|
|
|
template <typename F>
|
|
cuda::std::chrono::nanoseconds measure_execution_time(cuda::stream_ref stream, F&& f) {
|
|
cuda::timed_event start{stream};
|
|
f(stream);
|
|
cuda::timed_event end{stream};
|
|
return end - start;
|
|
}
|