Skip to content

Gfx1250 tdm gather scatter#833

Open
coderfeli wants to merge 1 commit into
mainfrom
gfx1250_tdm_gather_scatter
Open

Gfx1250 tdm gather scatter#833
coderfeli wants to merge 1 commit into
mainfrom
gfx1250_tdm_gather_scatter

Conversation

@coderfeli

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

Re-add gfx1250 TDM gather/scatter, layered on the existing target-neutral
fx.gather / fx.scatter interface (examples/05-gather_scatter.py) instead of a
bespoke gather op. A whole-tile TDM gather atom now lowers to a single
rocdl.tensor.load.to.lds / store.from.lds.

- Shared copy path: add an optional `indices` memref operand to fly.copy_atom_call
  and fly.copy (AttrSizedOperandSegments; keyword-led assembly to stay
  unambiguous vs the bare optional `pred`). Thread Type/Value through both memref
  emitAtomCall interface overloads, CopyAtomType, every copy impl (universal,
  CDNA3, CDNA4, GFX1250), FlyToROCDL, and the LayoutLowering expand-copy
  (indices only on the whole-tile path). Non-gather atoms ignore it.
- CopyOpGFX1250TDM gains a `mode` enum {tiled, gather}. Gather emit derives the
  row-index width from the indices operand element type (i16/i32) and the row
  count from its static extent, packing them into the descriptor; base / extents /
  row stride come from atom state (verify: gather => rank 2).
- fx.gather / fx.scatter route on a new generic copy_atom.copy_rank (> 1 =>
  whole-tile): one copy_atom_call with the offset tensor as the indices operand,
  base_iter only supplying the global shape token. expr/ stays ROCDL-free.
- Python: make_tdm_gather_atom, TDM(mode=...), copy_rank; NOTICE credits Triton
  (MIT) for the ported TDM descriptor packing.

Tests: new tdm_gather_gfx1250.mlir FileCheck (i32 load/store, i16 pack) and a
mode=gather roundtrip; existing tdm type strings updated for the mode field.
Verified: build; 10/10 copy/tdm/gfx1250 FileCheck; unit + expr-optional; examples
01/02/05 and vec_add on gfx942 (the indices=None default path). A runnable
gfx1250 gather kernel is deferred (host is gfx942).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderfeli
coderfeli force-pushed the gfx1250_tdm_gather_scatter branch from da865a5 to 2ae7140 Compare July 12, 2026 13:07
Comment on lines +91 to +95
from flydsl._mlir.dialects import fly # noqa: F401
from flydsl._mlir.dialects import fly_rocdl # noqa: F401
from flydsl._mlir.dialects.fly import CopyAtomType
from flydsl.expr.rocdl import universal as U

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

Suggested change
from flydsl._mlir.dialects import fly # noqa: F401
from flydsl._mlir.dialects import fly_rocdl # noqa: F401
from flydsl._mlir.dialects.fly import CopyAtomType
from flydsl.expr.rocdl import universal as U
from flydsl._mlir.dialects import (
fly, # noqa: F401
fly_rocdl, # noqa: F401
)
from flydsl._mlir.dialects.fly import CopyAtomType
from flydsl.expr.rocdl import universal as U

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