Skip to content

[libcu++] Shared memory barrier wait with a time hint - #12264

Open
pciolkosz wants to merge 2 commits into
NVIDIA:mainfrom
pciolkosz:shared_memory_barrier_wait_hint
Open

pciolkosz wants to merge 2 commits into
NVIDIA:mainfrom
pciolkosz:shared_memory_barrier_wait_hint

Conversation

@pciolkosz

Copy link
Copy Markdown
Contributor

We currently have try_wait that will do a single wait for an unspecified amount of time and try_wait_for that takes a time limit and the API will keep calling try_wait in a loop until that time limit passes. We also have wait that will wait however long it takes in a loop.

try_wait PTX instruction actually does take a time limit hint, its not promised by the implementation, that's why try_wait_for has a loop. But we should expose another wait variant that can supply that hint without the extra cost of a loop.

This PR adds a new overload of try_wait. It is still documented to do a one-shot wait for unspecified amount of time like the current try_wait variant, but it takes an extra argument with the wait time hint.

@pciolkosz
pciolkosz requested a review from a team as a code owner October 26, 2026 21:00
@pciolkosz
pciolkosz requested a review from wmaxey October 26, 2026 21:00
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Oct 26, 2026
@pciolkosz
pciolkosz requested a review from pauleonix October 26, 2026 21:00
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 45abc22
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 6024cb34-9401-428f-aa54-126903495f18
Commits

Reviewing files that changed from the base of the PR and between 45abc22 and 8682dbc.

Files selected for processing: 2
  • libcudacxx/include/cuda/__barrier/shared_memory_barrier.h
  • libcudacxx/test/libcudacxx/cuda/barrier/shared_memory_barrier.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.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Added nanosecond-hinted wait options for shared-memory barriers, including waits using arrival tokens, primary phases, and conditional phases.
    • Choose whether a wait returns its completion status or ignores it. Nonpositive hints perform a single check; positive hints enable polling on supported hardware.

The shared-memory barrier now supports nanosecond-hint wait overloads for arrival tokens and phases. The tests cover negative, zero, short positive, and large positive hints, and check results before and after barrier completion.

Changes: Hinted barrier waits

Layer / File(s) Summary
Hint conversion and single-attempt behavior
libcudacxx/include/cuda/__barrier/shared_memory_barrier.h
Adds hint range checking and conversion. Nonpositive hints perform one test-wait check; positive hints use the SM 90 hinted wait path or report unsupported storage on unsupported targets.
Hinted wait overloads and tests
libcudacxx/include/cuda/__barrier/shared_memory_barrier.h, libcudacxx/test/libcudacxx/cuda/barrier/shared_memory_barrier.cu
Adds hinted overloads for arrival tokens, primary phases, and conditional phases. Tests check status and completion results for several hint values before and after barrier completion.

Possibly related PRs

  • NVIDIA/cccl#12131: Changes operation_status decoding used by the new status-returning hinted waits.

Suggested reviewers: fbusato, wmaxey, jacobfaib

Priority: Low

Change: Feature

Merge Risk: Minimal · up to 8682d

The hinted waits and their tests show no identified issue that should block merging after normal checks.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 59m: Pass: 100%/228 | Total: 4d 04h | Max: 1h 32m | Hits: 92%/687189

See results here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

1 participant