Skip to content

[EASY][STF] host_launch_scope, parallel_for_scope: timing events are released under a policy, not an abort - #11773

Merged
andralex merged 1 commit into
NVIDIA:mainfrom
andralex:stf-cuda-try-scope-events
Sep 30, 2026
Merged

andralex merged 1 commit into
NVIDIA:mainfrom
andralex:stf-cuda-try-scope-events

Conversation

@andralex

Copy link
Copy Markdown
Contributor

[EASY]

Description

Same change as #11770 (stream_task) and the event part of #11748 (launch), applied to the two remaining copies of the pattern: the SCOPE(exit) in host_launch_scope.cuh and in parallel_for_scope.cuh that destroys the two timing events of an operator->*.

Each cuda_safe_call(cudaEventDestroy(...)) becomes cuda_try<cudaEventDestroy> under ON_THROW(notify), one guard per release. A failing destroy leaks that event and is reported to stderr; the guard is noexcept, so it cannot become a second exception; a leaked event is not worth ending the program over, which is what abort() did; and one policy per release means a failure on the first destroy does not skip the second.

The SCOPE(success) timing blocks in both files are left to #11652, which replaces them with task_statistics::record_task_timing.

With this, all five copies of the timing-event release guard carry the same explicit policy; folding them into one RAII holder is the follow-up once #11652 lands.

Checklist

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

🤖 Generated with Claude Code

…ed under a policy, not an abort

The SCOPE(exit) that destroys the two timing events in each operator->*
becomes cuda_try under ON_THROW(notify), one guard per release, as in
launch (NVIDIA#11748) and stream_task (NVIDIA#11770): a failing destroy leaks that event
and is reported, the guard is noexcept so it cannot become a second
exception, and a leaked event is not worth ending the program over.

The timing blocks in SCOPE(success) are left to NVIDIA#11652.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@andralex
andralex requested a review from a team as a code owner September 30, 2026 20:16
@andralex
andralex requested a review from caugonnet September 30, 2026 20:16
@copy-pr-bot

copy-pr-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@andralex

Copy link
Copy Markdown
Contributor Author

/ok to test a0cd585

@andralex
andralex enabled auto-merge (squash) September 30, 2026 20:16
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved cleanup reliability for CUDA timing events. If cleanup of one event fails, cleanup attempts for other related events still proceed, reducing the chance of resources being left behind.
    • Cleanup failures continue to be reported, while no longer preventing the remaining cleanup attempts.

Walkthrough

The host launch and parallel-for scope cleanup guards now destroy each non-null timing event with a separate cuda_try call and ON_THROW(notify) policy. A failure during one event’s destruction does not prevent the other destruction attempt.

Changes

Timing event cleanup

Layer / File(s) Summary
Independent timing event destruction
cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh, cudax/include/cuda/experimental/__stf/internal/parallel_for_scope.cuh
Both cleanup guards replace cuda_safe_call with separate cuda_try calls under ON_THROW(notify) for each non-null event.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: 🔵 Low · up to a0cd5

The PR is mergeable with a small follow-up: qualify the event-cleanup calls as required by the project guidelines. No runtime impact is established.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

@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.

🧹 Nitpick comments (1)
cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh (1)

237-237: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fully qualify the new event-release calls.

Use ::cuda::experimental::stf::cuda_try<::cudaEventDestroy> at each site.

  • cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh#L237-L237: qualify this call and the matching call at Line 244.
  • cudax/include/cuda/experimental/__stf/internal/parallel_for_scope.cuh#L705-L705: qualify this call and the matching call at Line 712.

As per path instructions, “free-function calls must be fully qualified to avoid ADL.”

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA/cccl/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f92f8b54-7482-43e4-9c8e-6a79d6c11fae

📥 Commits

Reviewing files that changed from the base of the PR and between db5d871 and a0cd585.

📒 Files selected for processing (2)
  • cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh
  • cudax/include/cuda/experimental/__stf/internal/parallel_for_scope.cuh

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 20m: Pass: 100%/72 | Total: 2d 11h | Max: 1h 19m | Hits: 9%/446354

See results here.

@andralex
andralex merged commit e9b87f0 into NVIDIA:main Sep 30, 2026
194 of 198 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants