Add view-based atomic reductions and ct.@atomic#283
Open
maleadt wants to merge 12 commits into
Open
Conversation
View-based atomic reduction, new in Tile IR 13.3: it reduces a tile into a view without returning the old value. Wire format mirrors cuTile Python's encode_AtomicRedViewTkoOp; gated on bytecode >= 13.3 like MakeStridedViewOp. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
atomic_max/atomic_min always emitted the signed MAX/MIN modes, so Unsigned element types compared incorrectly across the sign boundary. Factor a select_rmw_mode helper mirroring Python's _select_rmw_mode (float add -> ADDF, unsigned max/min -> UMAX/UMIN) and route emit_atomic_rmw! through it. Fix the docstrings that unconditionally said "signed". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
atomic_and/or/xor inherited the implicit TileOrScalar->T conversion from the shared overload, silently widening a mismatched update. cuTile Python's _cast_rmw_update_dtype forbids this for bitwise ops (the bit pattern, not the numeric value, is what's combined). Reject mismatches with a clear error; add/max/min/xchg keep converting. Updates the atomic_xor Int test, which passed an Int32 bid into an Int64 array. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Tile-granular atomic reductions that do not return the old value (issue #50). Six atomic_red_view_* intrinsics share emit_atomic_red_view! (view + index + value, single token result, relaxed/device), classified as plain stores in effects.jl — never eligible for the parallel-store optimization, so overlapping reductions stay token-ordered like store_strided_view. The language functions atomic_store_add/max/min/or/and/xor mirror store's TileArray and TiledView method families, reusing make_tile_view so partition/strided (eachtile) selection and broadcasting work unchanged. Bitwise variants require an exact update dtype; add/max/min convert. A friendly >= 13.3 check runs ahead of the encoder's hard error; bf16 ADDF is gated for both the rmw and view-reduction paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Statement forms (`A[i] += v`, `A[i] = op(A[i], v)`) return nothing; value forms (`A[i] + v`, `max(A[i], v)`) follow Base and return `old => new`. The macro only parses syntax and picks the ordering literally; the choice between a view reduction and a fetching atomic is left to type dispatch, so no ordering value is compared inside the kernel. Statement forms default to Relaxed (so a tile or view target uses atomic_red_view_tko), value forms to AcqRel. :sequentially_consistent is rejected (no Tile IR equivalent). Adds unary negation for tiles, needed to lower `-=` (add of the negated value). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
maleadt
marked this pull request as ready for review
July 24, 2026 07:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add tile-level atomic reductions backed by Tile IR 13.3's
atomic_red_view_tko, includingatomic_store_add,atomic_store_max,atomic_store_min, and the bitwise variants.Add a Base-style
ct.@atomicinterface for statement and value forms, with explicit memory-order support. Statement forms use the no-return reduction path when possible, while value forms returnold => new.This also aligns the existing atomic operations with Tile IR for unsigned min/max, bitwise update types, and BFloat16 support.
Closes #50