Let a custom mapping define the linear index of its work-items #848
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 · 306 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
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.343
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #848"
general
weight: 0.35
giordano
For a custom
NDRangemapping,@index(Global, Linear)islinear_index(__ndrange(ctx), expand(iterspace, group, item)): the position of the expanded index within the context'sndrange. That doesn't fit a mapping whose linear index isn't a function of the expanded index alone. The motivating case is Oceananigans launching kernels over a list of active cells (CliMA/Oceananigans.jl#5799), where the linear index of a work-item is its position in the list. A cell can't be mapped back to that position without a reverse lookup, so that PR overrides the internal__index_Global_Linearfor its context type instead. #781 documents that as something not to do, and it only works as long as@indexlowers through that function.This adds a hook on the iteration space:
It defaults to the previous definition,
linear_index(ndrange, expand(iterspace, groupidx, idx)), andglobal_linearcalls it for iteration spaces other than KernelAbstractions' own. A mapping specializes it on itsNDRangetype, e.g. for Oceananigans:KernelAbstractions' built-in iteration spaces (identity and offsets) still take the direct path, so their code doesn't change.
Open points
expandandcartesian. I've left #781 alone.Testing
@index(Global, Linear)is the position in the list. Without the hook the kernel doesn't compile (linear_index(::ListedIndices, ::CartesianIndex)has no method); with it the test passes on the CPU backend. The GPU back-ends will run it through the shared testsuite.IndexMaplaunch from CliMA/Oceananigans.jl@6852216 passes with the hook in place of the__index_Global_Linearoverride.🤖 Generated with Claude Code