Report synchronizations with the GPU in `CUDA.@timed` #3635
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 187 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 70%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.313
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3635"
general
weight: 0.35
maleadt
CUDA.@timednow returns the number of synchronizations with the GPU made while running the expression, in a new fieldgpu_syncstats(sync_count), next to the compilation statistics of #3625. This lets libraries test that a warm call never makes CUDA.jl wait for the GPU, e.g. when its memory moves to another stream or to a library through its pointer, without mirroring CUDA.jl's ownership logic:CUDA.@timedsynchronizes the GPU before running the expression, and CUDA.jl skips synchronizations whose work has already finished, so the second call is what checks for waits on running work.Every synchronization of a stream, event or context goes through
synchronize_object, which now does one atomic add. Explicitsynchronize/device_synchronizecalls always count; waits inside driver calls and libraries don't, and neither doCUDA.@timed's own.CUDA.@timedoesn't print the count. Like the other statistics, it's global across tasks.Synchronization cost is unchanged (RTX 5080, minimum per call, two alternating runs each):
| | main | PR |
|:--|--:|--:|
|
synchronize()| 165 / 166 ns | 157 / 160 ns ||
synchronize(blocking=true)| 138 / 135 ns | 127 / 140 ns ||
synchronize(event)| 174 / 181 ns | 177 / 171 ns ||
device_synchronize()| 701 / 679 ns | 680 / 670 ns |Closes #3590. Its destroyed-stream half was already fixed by eb2d739778.