-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[MLIR][XeVM] Update XeVM prefetch ops. #166445
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
Conversation
Prefetch ops need pointer operand marked as MemWrite to avoid getting dead code eliminated. As a reference point, memref.prefetch is handled in a similar way.
|
@llvm/pr-subscribers-mlir-gpu @llvm/pr-subscribers-mlir-llvm Author: Sang Ik Lee (silee2) ChangesPrefetch ops need pointer operand marked as MemWrite to avoid getting dead code eliminated. As a reference point, memref.prefetch is handled in a similar way. Full diff: https://github.com/llvm/llvm-project/pull/166445.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Dialect/LLVMIR/XeVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/XeVMOps.td
index 2dd612139fa2d..91e46d68673ed 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/XeVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/XeVMOps.td
@@ -444,7 +444,8 @@ def XeVM_MemfenceOp
def XeVM_PrefetchOp
: XeVM_Op<"prefetch">,
Arguments<(ins Arg<AnyTypeOf<[LLVM_PointerInAddressSpace<1>,
- LLVM_PointerInAddressSpace<4>]>>:$ptr,
+ LLVM_PointerInAddressSpace<4>]>,
+ "", [MemWrite]>:$ptr,
OptionalAttr<XeVM_LoadCacheControlAttr>:$cache_control)> {
let summary = "Prefetch data into a cache subsystem.";
let description = [{
@@ -463,7 +464,7 @@ def XeVM_PrefetchOp
def XeVM_BlockPrefetch2dOp
: XeVM_Op<"blockprefetch2d">,
- Arguments<(ins Arg<LLVM_AnyPointer, "", [MemRead]>:$ptr, I32:$base_width,
+ Arguments<(ins Arg<LLVM_AnyPointer, "", [MemWrite]>:$ptr, I32:$base_width,
I32:$base_height, I32:$base_pitch, I32:$x, I32:$y,
I32Attr:$elem_size_in_bits, I32Attr:$tile_width, I32Attr:$tile_height,
I32Attr:$v_blocks,
|
|
Not wrong but doesn't seem strictly necessary. |
For example, Can you elaborate why it may not be strictly necessary? |
|
Thanks for the example, now I see the issue. I quickly checked on an example using only Could you add a small test case just to avoid regression in the future? |
Instead of adding new tests, updated XeGPU to XeVM conversion tests to call canonicalize pass. |
|
@adam-smnk Turns out you were right about conservative evaluation. |
|
@adam-smnk Updated PR to just remove previous MemRead side effect. |
|
LGTM |
charithaintc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xevm.blockprefetch2dop has pointer operand marked as MemRead.
And that causes the op got get folded away be canonicalize pass.
Remove the side effect mark and update XeGPU to XeVM prefetch op conversion test cases to use canonicalize pass.
does this mean prefetch was not active at all? :-D
charithaintc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| @@ -1,34 +1,29 @@ | |||
| // RUN: mlir-opt -convert-xegpu-to-xevm -split-input-file %s | FileCheck %s | |||
| // RUN: mlir-opt -convert-xegpu-to-xevm -canonicalize %s | FileCheck %s | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so canonicalize will fold it (before)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canonicalize folds constant values and simplifies index compute, hoist constant value definitions, and removes dead code in this case.
Yes, if canonicalize is called in later pass pipeline. |
`xevm.blockprefetch2d` op has pointer operand marked as MemRead. And that causes the op got get folded away be canonicalize pass. Remove the side effect mark and update XeGPU to XeVM prefetch op conversion test cases to use canonicalize pass.
xevm.blockprefetch2dop has pointer operand marked as MemRead.And that causes the op got get folded away be canonicalize pass.
Remove the side effect mark and update XeGPU to XeVM prefetch op conversion test cases to use canonicalize pass.