You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add synchronized host copies, scalar reads, buffer matchers, and a legacy
default-stream helper. Extend uniform offset generation to explicit streams
with validated sizes and consistent logical buffer sizes.
Initialize custom-type generator storage before whole-object copies and
expand tests for buffer utilities, generators, and stream handling.
Reviewing files that changed from the base of the PR and between c05158c and 94c8418.
Files selected for processing: 1
c2h/include/c2h/buffer_utils.cuh
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
Summary
Summary by CodeRabbit
New Features
Added stream-aware uniform offset generation, with utilities for creating device buffers or paired device and host buffers.
Added helpers to copy device data to the host, read a single device value, and compare device buffers with host ranges.
Added host-buffer creation with a specified fill value and access to a default stream reference.
Bug Fixes
Buffer comparisons now require matching sizes as well as matching values.
Invalid offset counts and undersized output buffers are rejected with an error.
Stream-aware operations reject streams associated with a different device.
C2H gains checked, stream-aware uniform-offset generation and buffer helpers. The changes also add device-to-host copy, single-value read, and device-buffer comparison APIs, with tests for their behavior.
Uniform-offset sizing checks negative and overflowing counts. Generation supports a cuda::stream_ref, and helper APIs create device-only or paired host/device offset buffers. The random-value helper definition is moved into the detail header.
Buffer construction and generation c2h/include/c2h/buffer_generators.cuh, c2h/include/c2h/checked_memory_resource.cuh, cub/test/catch2_test_c2h_buffers.cu
Buffer generators accept a configurable device-buffer type. Custom-type buffers are zeroed before initialization, and host-buffer creation gains a fill-value overload. Tests cover generated buffers and custom-type values.
Stream-aware copying and matching c2h/include/c2h/device_and_stream.h, c2h/include/c2h/buffer_utils.cuh, c2h/include/c2h/catch2_test_helper.h, cub/test/catch2_test_c2h_buffers.cu
New helpers copy device ranges to host, read one device value, and compare device buffers with host ranges. The vector matcher now also requires equal sizes.
Assessment against linked issues
Objective
Addressed
Explanation
Make DECLARE_LAUNCH_WRAPPER and DECLARE_TMPL_LAUNCH_WRAPPER callables accept stream-like objects, and provide launch(stream, action, ...) [#11346]
❌
No stream-aware launch wrappers or direct launch API are added.
Out-of-scope changes
Code Change
Explanation
Stream-aware uniform-offset generation and offset-buffer helpers (c2h/generators_uniform_offsets.cu:33-138, c2h/include/c2h/generator_common.h:6-50, c2h/include/c2h/buffer_generators.cuh:162-197)
These changes add generator and buffer APIs, not the launch wrappers or direct launch API requested by the linked issue.
Device-buffer copy, read, and comparison helpers (c2h/include/c2h/buffer_utils.cuh:26-145)
These utilities do not implement the linked issue’s launch-helper requirements.
Possibly related issues
NVIDIA/cccl#11990 — The PR adds C2H buffer copy, comparison, and offset-generation helpers related to the issue’s C2H helper functionality.
NVIDIA/cccl#9310 — The PR adds reusable C2H buffer comparison, copy, and offset-generation components.
Suggested reviewers:davebayer
Change: Feature
Merge Risk: Minimal · up to 94c84
The reviewed changes do not retain an established merge-blocking risk.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
suggestion: Remove the deduction guide and spell out the template arguments for check_device_offsets.
Line 210 initializes check_device_offsets through the deduction guide on Lines 191-192. The repository guideline forbids relying on deduction guides for initialization. Use explicit template arguments instead.
As per coding guidelines: "Do not rely on deduction guides for initialization; use explicit template arguments instead."
Also applies to: 210-210
Source: Coding guidelines
c2h/include/c2h/buffer_utils.cuh: 1
60-62: Trivial · Maintainability & Code Quality · Low value
suggestion: Document the new public helpers in the Doxygen format that the repository guideline requires.
copy_to_host and read_single use plain // comments. The same applies to default_stream_ref and gen_uniform_offsets_device_buffer. This PR also converts the existing @brief/@pre comments in checked_memory_resource.cuh and buffer_generators.cuh to plain comments. The guideline requires //! @brief, a //! @param[in/out/in,out] entry for every parameter, and //! @return for non-void functions. If plain comments are intentional for C2H test utilities, confirm that the guideline does not apply here.
As per coding guidelines: "Documented functions must include //! @brief, //! @param[in/out/in,out] for every parameter, and //! @return for non-void functions."
Reviewing files that changed from the base of the PR and between 2857325 and 3f3ed47.
Files selected for processing: 12
c2h/generators_gen_values.cu
c2h/generators_uniform_offsets.cu
c2h/include/c2h/buffer_generators.cuh
c2h/include/c2h/buffer_utils.cuh
c2h/include/c2h/catch2_test_helper.h
c2h/include/c2h/checked_memory_resource.cuh
c2h/include/c2h/detail/current_device.cuh
c2h/include/c2h/detail/generators.cuh
c2h/include/c2h/device_and_stream.h
c2h/include/c2h/generator_common.h
c2h/include/c2h/vector_generators.h
cub/test/catch2_test_c2h_buffers.cu
Files with no reviewable changes: 1
c2h/generators_gen_values.cu
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
suggestion: Specify the check_device_offsets template arguments.
This initialization relies on the deduction guide at Line 253. Use check_device_offsets<cuda::std::int32_t, 5> here. Remove the guide if it has no other uses. As per coding guidelines, “Do not rely on deduction guides for initialization; use explicit template arguments instead.”
Reviewing files that changed from the base of the PR and between 3f3ed47 and 479d013.
Files selected for processing: 2
c2h/include/c2h/catch2_test_helper.h
cub/test/catch2_test_c2h_buffers.cu
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
operator== checks only key and val. Both correct buffers have the same policy byte and zero padding because both are zero-filled, and gen writes only custom_type_state_t. A byte-level comparison is valid and detects missing generator-owned initialization.
Reviewing files that changed from the base of the PR and between a29d8c4 and c71f5a2.
Files selected for processing: 1
cub/test/catch2_test_c2h_buffers.cu
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
HostItems can be a std::vector or another host range without an associated stream. Even when it has one, that stream need not be the stream producing the device buffer’s contents. The explicit stream identifies which work the comparison must wait for before reading the device data.
Reverted comments change which litters the changeset per
review feedback. added tests for new signature of read_single.
New signature allows read_single to implement
`read_at(stream, buffer, index)` easily.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Major · important: Order the source read on the supplied stream. · buffer_utils.cuh:74
c2h/include/c2h/buffer_utils.cuh:74 Major · Functional Correctness · Quick win
important: Order the source read on the supplied stream.
The new read_single span overload reaches this copy. On CUDA 13, cuda::copy_bytes defaults to source_access_order::any, which permits a source read before earlier writes on stream. The later stream.sync() cannot correct a stale read. Set src_access_order to cuda::source_access_order::stream. (raw.githubusercontent.com)
Reviewing files that changed from the base of the PR and between 879e1b4 and ca77c57.
Files selected for processing: 4
c2h/include/c2h/buffer_generators.cuh
c2h/include/c2h/buffer_utils.cuh
c2h/include/c2h/checked_memory_resource.cuh
cub/test/catch2_test_c2h_buffers.cu
Files skipped from review as they are similar to previous changes: 2
c2h/include/c2h/checked_memory_resource.cuh
c2h/include/c2h/buffer_generators.cuh
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add synchronized host copies, scalar reads, buffer matchers, and a legacy default-stream helper. Extend uniform offset generation to explicit streams with validated sizes and consistent logical buffer sizes.
Initialize custom-type generator storage before whole-object copies and expand tests for buffer utilities, generators, and stream handling.
Description
This PR provides focused subset of changes from #11374 .
closes #11346
Checklist