Skip to content

[MLIR][XeGPU] Add lowering from transfer_read/transfer_write to load_gather/store_scatter #152429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Aug 14, 2025

Conversation

Jianhui-Li
Copy link
Contributor

Lowering transfer_read/transfer_write to load_gather/store_scatter in case the target uArch doesn't support load_nd/store_nd. The high level steps:

  1. compute Strides;
  2. compute Offsets;
  3. collapseMemrefTo1D;
  4. create Load gather or store_scatter op

@Jianhui-Li
Copy link
Contributor Author

@adam-smnk

Copy link

github-actions bot commented Aug 7, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@charithaintc charithaintc self-requested a review August 11, 2025 21:39
Copy link
Contributor

@adam-smnk adam-smnk left a comment

Choose a reason for hiding this comment

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

Overall looks good
A few minor comments

@charithaintc charithaintc self-requested a review August 13, 2025 19:31
Copy link
Contributor

@charithaintc charithaintc left a comment

Choose a reason for hiding this comment

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

LGTM % all other pending comments.

Comment on lines 291 to 295
for (int64_t dim : vectorShape) {
auto stepType = VectorType::get({dim}, rewriter.getIndexType());
auto stepOp = vector::StepOp::create(rewriter, loc, stepType);
stepVectors.push_back(stepOp);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

consider using llvm::map_to_vector

Copy link
Contributor Author

@Jianhui-Li Jianhui-Li Aug 13, 2025

Choose a reason for hiding this comment

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

changed. Not sure this is better? The lamba function has lots of side-effects like IR creation and writing to setpVectors, not a pure function.

Copy link
Contributor

@chencha3 chencha3 left a comment

Choose a reason for hiding this comment

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

LGTM

Value localOffsets = broadcasted[0];
for (size_t i = 1; i < broadcasted.size(); ++i) {
localOffsets =
arith::AddIOp::create(rewriter, loc, localOffsets, broadcasted[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: braces are not necessary.

Copy link
Contributor

@adam-smnk adam-smnk left a comment

Choose a reason for hiding this comment

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

A few final touches and it should be good to go
Otherwise, looks good 👍 Thanks for all the tweaks

@Jianhui-Li Jianhui-Li merged commit 98728d9 into llvm:main Aug 14, 2025
9 checks passed
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.

6 participants