Skip to content

Refactor C2H headers by responsibility - #11338

Merged
oleksandr-pavlyk merged 7 commits into
NVIDIA:mainfrom
oleksandr-pavlyk:c2h-header-refactor
Sep 11, 2026
Merged

oleksandr-pavlyk merged 7 commits into
NVIDIA:mainfrom
oleksandr-pavlyk:c2h-header-refactor

Conversation

@oleksandr-pavlyk

Copy link
Copy Markdown
Contributor

Description

This PR is the first in the sequence of more focused chunks comprising #10898

It splits c2h headers into parts to prepare ground for use of cuda::buffer with checked allocators analogous to what is used by c2h::device_vector and c2h::host_vector.

closes #11337

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@oleksandr-pavlyk
oleksandr-pavlyk requested a review from a team as a code owner September 10, 2026 19:18
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Sep 10, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c65ac715-8c3f-4e7b-8c0c-924de027322c

📥 Commits

Reviewing files that changed from the base of the PR and between 20c20f6 and e733d81.

📒 Files selected for processing (1)
  • c2h/include/c2h/detail/env.cuh
🚧 Files skipped from review as they are similar to previous changes (1)
  • c2h/include/c2h/detail/env.cuh

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added device-vector generators for custom and scalar values, cyclic sequences, uniform offsets, and key-segment initialization.
    • Added configurable checked CUDA memory handling with allocation limits and diagnostics.
    • Added cross-platform environment-variable support and NVTX tracing for tests.
  • Refactor

    • Reorganized generator, seed, tracing, and checked-allocation utilities into focused headers.
  • Breaking Changes

    • Generator and seed APIs were moved from their previous public headers to dedicated interfaces.

Walkthrough

The change splits C2H testing, memory, environment, and generator code into dedicated headers. Public generator APIs move to vector_generators.h, while shared types and declarations move to generator_common.h.

Changes

C2H header refactor

Layer / File(s) Summary
Extract detail utilities
c2h/include/c2h/detail/..., c2h/include/c2h/checked_allocator.cuh, c2h/include/c2h/catch2_test_helper.h
Environment lookup, checked-memory utilities, NVTX fixtures, and seed helpers move to detail headers. The allocator and Catch2 macros use the new implementations.
Split generator contracts and implementations
c2h/include/c2h/generator_common.h, c2h/include/c2h/vector_generators.h, c2h/include/c2h/generators.h, c2h/include/c2h/detail/generators.cuh
Generator wrapper types and declarations move to generator_common.h. Device-vector generator APIs move to vector_generators.h. Existing includes are rewired, and the old declarations are removed from generators.h.

Assessment against linked issues

Objective Addressed Explanation
Move and split existing C2H declarations and implementation headers, including detail-only utilities [#11337] ✅
Avoid behavior changes while preparing the header split [#11337] ❓ The checked-memory implementation changes free-memory clamping and subtraction behavior in c2h/include/c2h/detail/checked_memory.cuh:43-63. The generator APIs and Catch2 seed helpers also move while their declarations are reorganized.

Out-of-scope changes

Code Change Explanation
Changed free-memory clamping and subtraction behavior (c2h/include/c2h/detail/checked_memory.cuh) The linked objective requests a header-only refactor with no behavior changes.
Added conditional CUDA type support and new vector generator implementation structure (c2h/include/c2h/vector_generators.h) The linked objective explicitly excludes generator changes.

Suggested reviewers: bernhardmgruber, jacobfaib

Priority: ➖ Normal

Change: Refactor

Merge Risk: ⚪ Minimal · up to e733d

The header-only refactor has no identified merge-blocking risk.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 366d9dd1-bf1e-474a-b763-f7d44039f8eb

📥 Commits

Reviewing files that changed from the base of the PR and between 2d7377c and 2e69367.

📒 Files selected for processing (10)
  • c2h/include/c2h/catch2_test_helper.h
  • c2h/include/c2h/checked_allocator.cuh
  • c2h/include/c2h/detail/catch2_nvtx.h
  • c2h/include/c2h/detail/catch2_seed.h
  • c2h/include/c2h/detail/checked_memory.cuh
  • c2h/include/c2h/detail/env.cuh
  • c2h/include/c2h/detail/generators.cuh
  • c2h/include/c2h/generator_types.h
  • c2h/include/c2h/generators.h
  • c2h/include/c2h/vector_generators.h

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Comment thread c2h/include/c2h/detail/catch2_nvtx.h Resolved
Comment thread c2h/include/c2h/detail/catch2_seed.h Resolved
Comment thread c2h/include/c2h/generator_common.h Resolved
Comment thread c2h/include/c2h/detail/catch2_nvtx.h Resolved
 - Clamps the configured limit to physical memory.
 - Safely calculates unavailable memory.
 - Saturates adjusted free memory at zero.
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 22m: Pass: 100%/61 | Total: 1d 14h | Max: 2h 22m | Hits: 62%/104816

See results here.

@oleksandr-pavlyk
oleksandr-pavlyk merged commit e8fb68b into NVIDIA:main Sep 11, 2026
89 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Sep 11, 2026
@oleksandr-pavlyk
oleksandr-pavlyk deleted the c2h-header-refactor branch September 11, 2026 16:59
kaatish pushed a commit to kaatish/cccl that referenced this pull request Sep 11, 2026
* Refactor C2H headers by responsibility

* catch2_nvtx.h to use namespace c2h::detail namespace over namespace detail

* use const qualifier for override_str read-only variable

* Use saturating arithmetic for the overridden free-memory calculation

 - Clamps the configured limit to physical memory.
 - Safely calculates unavailable memory.
 - Saturates adjusted free memory at zero.

* generator_types.h -> generator_common.h
charan-003 pushed a commit to charan-003/cccl that referenced this pull request Sep 15, 2026
* Refactor C2H headers by responsibility

* catch2_nvtx.h to use namespace c2h::detail namespace over namespace detail

* use const qualifier for override_str read-only variable

* Use saturating arithmetic for the overridden free-memory calculation

 - Clamps the configured limit to physical memory.
 - Safely calculates unavailable memory.
 - Saturates adjusted free memory at zero.

* generator_types.h -> generator_common.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Task]: Split c2h headers to prepare for cuda::buffer

3 participants