← Back to Pull requests

[STF] Fix two races in tests and examples: fence() timing events and threads_multiple_graphs #12178

Closed
unknown closed this pull request without merging on Oct 24, 2026 12:18 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 18:09 UTC
Author

Description

closes #12175

Two races in CUDASTF tests and examples. Neither is in the library itself.

1. Timing with fence() events (17 files). These tests and examples record their stop event in a stream returned by ctx.fence(), then call ctx.finalize() and cudaEventElapsedTime(). finalize() waits for the context's own work, not for work recorded in a fence() stream, so the stop event may not have completed yet, and cudaEventElapsedTime() returns cudaErrorNotReady. Code that checks the result aborts, for example 09-nbody-blocked at line 279 when the GPU is shared. The jacobi* and heat_mgpu examples ignore it and print an uninitialized time. This PR synchronizes the stop event first, as examples/stf/mandelbrot.cu already does.

2. threads_multiple_graphs. Each worker thread gets views of frozen data in its own stream and runs a graph context on it. The main thread then unfreezes the data in a different stream that does not depend on the worker's stream. docs/cudax/stf.rst says that "the stream passed to unfreeze must depend on the completion of the work in the streams used for any preceding freeze and get calls". This PR waits for the worker stream before the thread returns.

Testing

RTX 5070 Ti (sm_120), WSL2, nvcc 13.4.59, gcc 16.2.1, cudax preset with examples. "Contention" means 6 processes running the same binary at the same time.

| test | contention before | contention after (6 processes × 6 runs) |
|---|---|---|
| stf.examples.09-nbody-blocked | 24/30 runs abort with cudaErrorNotReady (6 processes × 5 runs) | 0/36 |
| stf.stress.launch_vs_parallelfor | 36/36 runs abort | 0/36 |
| stf.local_stf.threads_multiple_graphs | 8/36 runs fail (wrong results) | 0/36 |
| stf.utility.timing_with_fences | not measured | 0/36 |

Run alone, all four tests and the examples heat_mgpu, jacobi, jacobi_pfor, jacobi_stackable, jacobi_stackable_raii, launch_histogram, launch_scan and scan pass.

Not built locally: examples/stf/linear_algebra/{06-pdgemm,06-pdgemm-stackable,07-cholesky,07-potri}.cu, test/stf/examples/07-cholesky-redux.cu and test/stf/gnu/07-cholesky.cpp, because my toolkit has no cuBLAS/cuSOLVER. They get the same one-line cudaEventSynchronize() before the existing cudaEventElapsedTime() call, on the same event variable.

Checklist


  • New or existing tests cover these changes. (Test and example changes only.)

  • The documentation is up to date with these changes. (No user-visible change.)
  • Diff: 316 lines (+237 / -79) across 3 files Reviewer: caugonnet Review duration: 2529m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 316 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #12178"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.0% · Safe to merge
    16.0%
    Repository