Skip to content

[Codegen][Map] Add PackLayout distribution pattern for transfer_gather#23809

Open
Groverkss wants to merge 1 commit intoiree-org:mainfrom
Groverkss:map-distribute-memory-ops
Open

[Codegen][Map] Add PackLayout distribution pattern for transfer_gather#23809
Groverkss wants to merge 1 commit intoiree-org:mainfrom
Groverkss:map-distribute-memory-ops

Conversation

@Groverkss
Copy link
Copy Markdown
Contributor

Add MapDistributeTransferGather which distributes transfer_gather ops under PackLayoutAttr.

Eventually, transfer_read would pre-process to transfer_gather before distribution and distribute as transfer_gather. They eventually canonicalize to an equivalent form after unrolling.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Add MapDistributeTransferGather which distributes transfer_gather ops
under PackLayoutAttr.

Eventually, transfer_read would pre-process to transfer_gather before
distribution and distribute as transfer_gather. They eventually
canonicalize to an equivalent form after unrolling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines +82 to +83
/// %s1 = vector.step : vector<32xindex> // redistributed → [tid_off + 0, 8,
/// 16, 24] transfer_gather %mem[%off0, %off1] [%s0, %s1], %pad
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.

Nit: The line break here is a bit unfortunate, probably needs manual formatting.

Comment on lines +164 to +168
if (origDimToSymbol[origDim] >= 0) {
newSourceResults.push_back(
getAffineSymbolExpr(origDimToSymbol[origDim], ctx));
continue;
}
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.

Can you add a comment what this bit is for?

SmallVector<Attribute> allMapAttrs;
allMapAttrs.push_back(AffineMapAttr::get(
AffineMap::get(distRank, totalSymbols, newSourceResults, ctx)));
for (auto &mapResults : newIndexVecMapResults) {
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.

Nit: type

// Layout (2, 3, 4, 2):(12, 0, 3, 0) has interleaved thread/value leaves:
// Thread: (2, stride=12), (4, stride=3) → 8 threads
// Value: (3, dataStride=8), (2, dataStride=1) → distributed shape [3, 2]
// The two value leaves don't coalesce (3*1 ≠ 8).
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.

Why do we multiply with 3 here?

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.

I think the new indexing maps calculated by distribution are quite important, so I think the test should check them.

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.

2 participants