Skip to content

libcu++: respect atomic scopes in pointer arithmetic operations. - #10809

Merged
griwes merged 1 commit into
NVIDIA:mainfrom
griwes:bug/atomic-pointer-arithmetic-scope
Aug 14, 2026
Merged

libcu++: respect atomic scopes in pointer arithmetic operations.#10809
griwes merged 1 commit into
NVIDIA:mainfrom
griwes:bug/atomic-pointer-arithmetic-scope

Conversation

@griwes

@griwes griwes commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Description

It seems that we've had pointer arithmetic go through the system scope. This PR fixes that.

Resolves #10808.

Checklist

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

@griwes
griwes requested a review from a team as a code owner August 13, 2026 23:54
@griwes
griwes requested a review from pciolkosz August 13, 2026 23:54
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Aug 13, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Fixed pointer atomic additions and subtractions so they honor the requested thread scope instead of always using system scope.
    • Improved correctness for block-, device-, and system-scoped operations.
  • Tests

    • Added coverage for non-volatile pointer atomic addition and subtraction across supported thread scopes.
    • Added verification that relaxed operations generate the appropriate scope-specific GPU instructions.

Walkthrough

Pointer atomic fetch_add and fetch_sub now forward the atomic scope to dispatch. New CUDA kernels and PTX checks validate block, device, and system scope code generation for non-volatile pointer operations.

Changes

Pointer atomic scope handling

Layer / File(s) Summary
Scope-aware pointer arithmetic dispatch
libcudacxx/include/cuda/std/__atomic/api/common.h
Pointer atomic addition and subtraction dispatch use _Sco instead of a fixed system-scope tag.
Scope-specific pointer atomic code generation
libcudacxx/test/atomic_codegen/atomic_add_non_volatile.cu, libcudacxx/test/atomic_codegen/atomic_sub_non_volatile.cu
New relaxed pointer arithmetic kernels and PTX checks cover CTA, GPU, and system scopes.

Assessment against linked issues

Objective Addressed Explanation
Pointer arithmetic atomics use the scope of the atomic instead of always using system scope [#10808]

Possibly related PRs

  • NVIDIA/cccl#10722: Adds related pointer atomic scope handling and code-generation test infrastructure.

Suggested reviewers: pciolkosz, wmaxey

Mergeability Score: ⚪ Minimal · up to d5304

The PR updates atomic pointer arithmetic to honor the intended atomic scope; the remaining test-only const-correctness cleanup does not affect runtime behavior. No actionable merge-blocking risk remains after normal checks.


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: bf464693-4e73-4a77-8eb8-dbc4b288cf2a

📥 Commits

Reviewing files that changed from the base of the PR and between 48c8219 and d530404.

📒 Files selected for processing (3)
  • libcudacxx/include/cuda/std/__atomic/api/common.h
  • libcudacxx/test/atomic_codegen/atomic_add_non_volatile.cu
  • libcudacxx/test/atomic_codegen/atomic_sub_non_volatile.cu

Comment thread libcudacxx/test/atomic_codegen/atomic_add_non_volatile.cu
@griwes
griwes enabled auto-merge (squash) August 14, 2026 00:03
@github-actions

Copy link
Copy Markdown
Contributor

⏱️ CCCL compile-time benchmark comparison: Public headers compile-time bench

Result: 0 regression row(s), 1 improvement row(s) above threshold.

Run Value
Config public-headers-gcc13
Baseline origin/main
Preset all-dev
Targets cub.headers.base, thrust.cpp.cuda.headers.base, libcudacxx.test.public_headers
GPU / launch args rtx2080 / --cuda 13.3 --host gcc13

Artifacts: reports and traces

Direct file processing

-f file-processing exclusive --sort total

🟢 Direct file processing — Improvements
Rank Improvement impact Selected Δ Baseline Current Event Matched traces
1 0.625751 -0.625751 5.407631 4.781880 Processing Header File: libcudacxx/include/cuda/std/__cccl/prologue.h 552

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 02m: Pass: 100%/117 | Total: 2d 18h | Max: 1h 29m | Hits: 59%/636436

See results here.

@griwes
griwes merged commit 3ae0e48 into NVIDIA:main Aug 14, 2026
149 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Aug 14, 2026
@griwes
griwes deleted the bug/atomic-pointer-arithmetic-scope branch August 14, 2026 17:01
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.

libcu++: pointer arithmetic atomics ignore the scope

2 participants