Skip to content

Add MGATHER.CAS atomic compare-and-swap gather instruction#133

Open
Auyuir wants to merge 2 commits into
LinxISA:mainfrom
Auyuir:rename-mgathercas-to-mgather-cas
Open

Add MGATHER.CAS atomic compare-and-swap gather instruction#133
Auyuir wants to merge 2 commits into
LinxISA:mainfrom
Auyuir:rename-mgathercas-to-mgather-cas

Conversation

@Auyuir

@Auyuir Auyuir commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduce MGATHER.CAS, a new tileblock memory instruction that performs per-element atomic compare-and-swap from sparse memory (base + offset Tile) into a destination Tile, returning the pre-CAS memory value on every lane so callers can detect failure and retry.
  • Register TileOp slot 8 in tma_block/header.md and ship EN/ZH instruction docs covering assembly syntax, parameter table, BSTART.TMA / B.DIM / B.IOT / B.IOR encoding expansion, and C execution model.
  • Naming follows the existing MGATHER.MASK / MSCATTER.MASK dot-suffix convention, keeping the load shape (GATHER) and per-element op (CAS) visually separated and leaving room for future atomic RMW siblings (XCHG / ADD / MIN / MAX).

Test plan

  • Reviewer confirms TileOp slot 8 is free and the encoding expansion matches hardware behavior.
  • Reviewer confirms the C pseudo-code semantics — especially the failed-CAS old-value write and PadValue fill outside the valid region — match the intended atomic semantics.
  • Reviewer confirms links from tma_block/header.md (EN + ZH) to the new MGATHER.CAS.md resolve in the rendered docs site.

@Auyuir Auyuir requested a review from a team as a code owner June 22, 2026 09:45

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds documentation for the new MGATHER.CAS (Atomic Compare-and-Swap Gather from Memory to Tile) instruction in both English and Chinese, updating the TMA block headers and adding detailed specification files. The reviewer feedback suggests clarifying that the Row parameter is hardware-derived rather than a mandatory user-specified input in the parameter tables, and replacing the undefined type T with DataType in the execution model pseudo-code for both language versions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread docs/isa/header/tileblock/MGATHER.CAS.md Outdated
Comment thread docs/zh/isa/header/tileblock/MGATHER.CAS.md
Comment thread docs/isa/header/tileblock/MGATHER.CAS.md
Comment thread docs/zh/isa/header/tileblock/MGATHER.CAS.md
Introduce a new tileblock memory instruction that performs per-element
atomic compare-and-swap from sparse memory (base + offset Tile) into a
destination Tile, returning the pre-CAS memory value. Registers TileOp
slot 8 in tma_block/header.md and ships EN/ZH instruction docs.

Naming follows the MGATHER.MASK / MSCATTER.MASK dot-suffix convention
to keep load-shape (GATHER) and per-element op (CAS) visually separated
and leave room for future atomic RMW siblings.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Auyuir Auyuir force-pushed the rename-mgathercas-to-mgather-cas branch from 8e3067b to 56bd137 Compare June 23, 2026 01:48
@Auyuir

Auyuir commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist Thanks for the review! Here's the response to your feedback:

1. Row parameter Optional column — Fixed ✅
Changed the EN version from No to Hardware-derived to clarify that Row is not user-specified but derived from Size / (Col * sizeof(DataType)). This now matches the ZH version's explicit 否(硬件推导) notation.

2. Undefined type T in C pseudo-code — Not changing per team convention
The T in the pseudo-code is implicitly the DataType element type, and this follows the same convention as sibling instructions like MGATHER (which uses dst[i][j] = Memory[base + offset] without explicit type annotations). This is pseudocode for semantic clarity, not compilable C, so additional type annotations aren't necessary here.


Note on CI lint failure: The lint failure in docs/figs/isa/datatype/create_fp_svg.py is a pre-existing issue (f-string backslash escape syntax requires Python 3.12, but CI runs on Python 3.11). This exists on main as well and is unrelated to this PR's changes.

@gemini-code-assist

Copy link
Copy Markdown

Thanks for the updates and the clarification. The documentation changes look good and align well with the existing conventions. I understand the rationale regarding the pseudo-code style and the pre-existing CI lint issue. Everything seems in order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant