Skip to content

Commit 5aebd5d

Browse files
committed
Add prefetch, updateOffsets, scatter load/store tests
1 parent 4034fd3 commit 5aebd5d

File tree

12 files changed

+588
-101
lines changed

12 files changed

+588
-101
lines changed

cmake/llvm-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7842374103b26933d71a8fe354cd4d8715d55b1c
1+
3ae0f3047b5a0de8ef98c167610f6018f615b7ea

include/gc/Dialect/LLVMIR/XeVMOps.td

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,41 @@ class XeVM_Op<string mnemonic, list<Trait> traits = []> :
4141

4242
def XeVM_ElemType : AnyTypeOf<[AnyI8, AnyI16, AnyI32, F32, F16, BF16]>;
4343

44-
class XeVM_LoadCacheControl<string cacheMnemonic> : I32EnumAttr<!strconcat(cacheMnemonic, "LoadCacheControl"), "XeVM load ops cache control",
44+
def XeVM_LoadCacheControl : I32EnumAttr<"LoadCacheControl", "XeVM load ops cache control",
4545
[
4646
I32EnumAttrCase<"DEFAULT", 0, "Default">,
47-
I32EnumAttrCase<"UC", 1, !strconcat(cacheMnemonic, "UC")>, // uncached
48-
I32EnumAttrCase<"C", 2, !strconcat(cacheMnemonic, "C")>, // cached
49-
I32EnumAttrCase<"S", 3, !strconcat(cacheMnemonic, "S")>, // streaming
50-
I32EnumAttrCase<"IAR", 4, !strconcat(cacheMnemonic, "IAR")>, // invalidate-after-read
47+
I32EnumAttrCase<"UC", 1, "UC">, // uncached
48+
I32EnumAttrCase<"C", 2, "C">, // cached
49+
I32EnumAttrCase<"S", 3, "S">, // streaming
50+
I32EnumAttrCase<"IAR", 4, "IAR">, // invalidate-after-read
5151
]> {
5252
let cppNamespace = "::mlir::xevm";
53+
let genSpecializedAttr = 0;
5354
}
5455

55-
def XeVM_L1LoadCacheControl : XeVM_LoadCacheControl<"L1">;
56-
def XeVM_L3LoadCacheControl : XeVM_LoadCacheControl<"L3">;
56+
def XeVM_LoadCacheControlAttr:
57+
EnumAttr<XeVM_Dialect, XeVM_LoadCacheControl, "load_cache_control"> {
58+
let summary = [{ }];
59+
let assemblyFormat = "$value";
60+
}
5761

58-
class XeVM_StoreCacheControl<string cacheMnemonic> : I32EnumAttr<!strconcat(cacheMnemonic, "StoreCacheControl"), "XeVM store ops cache control",
62+
def XeVM_StoreCacheControl : I32EnumAttr<"StoreCacheControl", "XeVM store ops cache control",
5963
[
6064
I32EnumAttrCase<"DEFAULT", 0, "Default">,
61-
I32EnumAttrCase<"UC", 1, !strconcat(cacheMnemonic, "UC")>, // uncached
62-
I32EnumAttrCase<"WT", 2, !strconcat(cacheMnemonic, "WT")>, // write-through
63-
I32EnumAttrCase<"S", 3, !strconcat(cacheMnemonic, "S")>, // streaming
64-
I32EnumAttrCase<"WB", 4, !strconcat(cacheMnemonic, "WB")>, // write back
65+
I32EnumAttrCase<"UC", 1, "UC">, // uncached
66+
I32EnumAttrCase<"WT", 2, "WT">, // write-through
67+
I32EnumAttrCase<"S", 3, "S">, // streaming
68+
I32EnumAttrCase<"WB", 4, "WB">, // write back
6569
]> {
6670
let cppNamespace = "::mlir::xevm";
71+
let genSpecializedAttr = 0;
6772
}
6873

69-
def XeVM_L1StoreCacheControl : XeVM_StoreCacheControl<"L1">;
70-
def XeVM_L3StoreCacheControl : XeVM_StoreCacheControl<"L3">;
74+
def XeVM_StoreCacheControlAttr:
75+
EnumAttr<XeVM_Dialect, XeVM_StoreCacheControl, "store_cache_control"> {
76+
let summary = [{ }];
77+
let assemblyFormat = "$value";
78+
}
7179

7280
def XeVM_BlockLoad2dOp : XeVM_Op<"blockload2d">,
7381
Results<(outs FixedVectorOfRankAndType<[1,2,3], [XeVM_ElemType]>:$res)>,
@@ -84,8 +92,8 @@ def XeVM_BlockLoad2dOp : XeVM_Op<"blockload2d">,
8492
I32Attr:$v_blocks,
8593
I1Attr:$transpose,
8694
I1Attr:$vnni_transform,
87-
DefaultValuedAttr<XeVM_L1LoadCacheControl, "::mlir::xevm::L1LoadCacheControl::DEFAULT">:$l1_cache_control,
88-
DefaultValuedAttr<XeVM_L3LoadCacheControl, "::mlir::xevm::L3LoadCacheControl::DEFAULT">:$l3_cache_control
95+
DefaultValuedAttr<XeVM_LoadCacheControlAttr, "::mlir::xevm::LoadCacheControl::DEFAULT">:$l1_cache_control,
96+
DefaultValuedAttr<XeVM_LoadCacheControlAttr, "::mlir::xevm::LoadCacheControl::DEFAULT">:$l3_cache_control
8997
)> {
9098

9199
let summary = "2D block load";
@@ -138,8 +146,8 @@ def XeVM_BlockStore2dOp : XeVM_Op<"blockstore2d">,
138146
I32Attr:$tile_height,
139147
I32Attr:$v_blocks,
140148
FixedVectorOfRankAndType<[1, 2, 3], [XeVM_ElemType]>:$stored_val,
141-
DefaultValuedAttr<XeVM_L1StoreCacheControl, "::mlir::xevm::L1StoreCacheControl::DEFAULT">:$l1_cache_control,
142-
DefaultValuedAttr<XeVM_L3StoreCacheControl, "::mlir::xevm::L3StoreCacheControl::DEFAULT">:$l3_cache_control
149+
DefaultValuedAttr<XeVM_StoreCacheControlAttr, "::mlir::xevm::StoreCacheControl::DEFAULT">:$l1_cache_control,
150+
DefaultValuedAttr<XeVM_StoreCacheControlAttr, "::mlir::xevm::StoreCacheControl::DEFAULT">:$l3_cache_control
143151
)> {
144152

145153
let summary = "2D block store";
@@ -195,7 +203,7 @@ def XeVM_MemoryScopeAttr:
195203
let assemblyFormat = "$value";
196204
}
197205

198-
def XeVM_FenceAddrSpace : I32EnumAttr<"FenceAddrSpace", "Address space for MemfenceOp",
206+
def XeVM_AddrSpace : I32EnumAttr<"AddrSpace", "Address spaces",
199207
[
200208
I32EnumAttrCase<"SHARED", 0, "shared">,
201209
I32EnumAttrCase<"GLOBAL", 1, "global">,
@@ -205,8 +213,8 @@ def XeVM_FenceAddrSpace : I32EnumAttr<"FenceAddrSpace", "Address space for Memfe
205213
let genSpecializedAttr = 0;
206214
}
207215

208-
def XeVM_FenceAddrSpaceAttr:
209-
EnumAttr<XeVM_Dialect, XeVM_FenceAddrSpace, "fence_addrspace"> {
216+
def XeVM_AddrSpaceAttr:
217+
EnumAttr<XeVM_Dialect, XeVM_AddrSpace, "fence_addrspace"> {
210218
let summary = [{Specifies the address space for memory operations affected by a fence:
211219
"shared" - workgroup (SLM).
212220
"global" - GPU.
@@ -217,7 +225,7 @@ def XeVM_FenceAddrSpaceAttr:
217225
def XeVM_MemfenceOp : XeVM_Op<"memfence">,
218226
Arguments<(ins
219227
XeVM_MemoryScopeAttr:$scope,
220-
DefaultValuedAttr<XeVM_FenceAddrSpaceAttr, "mlir::xevm::FenceAddrSpace::GENERIC"> :$addrspace
228+
DefaultValuedAttr<XeVM_AddrSpaceAttr, "mlir::xevm::AddrSpace::GENERIC"> :$addrspace
221229
)> {
222230
let summary = "Work-item's memory fence.";
223231
let description = [{
@@ -232,6 +240,28 @@ def XeVM_MemfenceOp : XeVM_Op<"memfence">,
232240
let assemblyFormat = [{`addrspace` `=` `` $addrspace `,` `scope` `=` `` $scope attr-dict}];
233241
}
234242

243+
def XeVM_PrefetchOp : XeVM_Op<"prefetch">,
244+
Arguments<(ins
245+
Arg<LLVM_AnyPointer, "", [MemRead]>:$ptr,
246+
XeVM_AddrSpaceAttr:$addrspace,
247+
DefaultValuedAttr<XeVM_LoadCacheControlAttr, "::mlir::xevm::LoadCacheControl::DEFAULT">:$l1_cache_control,
248+
DefaultValuedAttr<XeVM_LoadCacheControlAttr, "::mlir::xevm::LoadCacheControl::DEFAULT">:$l3_cache_control
249+
)> {
250+
let summary = "Prefetch data into a cache subsystem.";
251+
let description = [{
252+
Work-item issues a prefetch from global memory to L1/L3 cache:
253+
$ptr - memory pointer.
254+
$addrspace - address space of a pointer, must be generic or global.
255+
$cache_control - specify caching options (e.g., L1c, L3uc).
256+
}];
257+
let assemblyFormat = [{
258+
operands ` ` `{` `addrspace` `=` $addrspace `,` `l1_cc` `=` $l1_cache_control `,` `l3_cc` `=` $l3_cache_control `}`
259+
attr-dict `:` `(` type(operands) `)`
260+
}];
261+
262+
// let hasVerifier = 1;
263+
}
264+
235265
def XeVM_BlockPrefetch2dOp : XeVM_Op<"blockprefetch2d">,
236266
Arguments<(ins
237267
Arg<LLVM_AnyPointer, "", [MemRead]>:$ptr,
@@ -244,8 +274,8 @@ def XeVM_BlockPrefetch2dOp : XeVM_Op<"blockprefetch2d">,
244274
I32Attr:$tile_width,
245275
I32Attr:$tile_height,
246276
I32Attr:$v_blocks,
247-
DefaultValuedAttr<XeVM_L1LoadCacheControl, "::mlir::xevm::L1LoadCacheControl::DEFAULT">:$l1_cache_control,
248-
DefaultValuedAttr<XeVM_L3LoadCacheControl, "::mlir::xevm::L3LoadCacheControl::DEFAULT">:$l3_cache_control
277+
DefaultValuedAttr<XeVM_LoadCacheControlAttr, "::mlir::xevm::LoadCacheControl::DEFAULT">:$l1_cache_control,
278+
DefaultValuedAttr<XeVM_LoadCacheControlAttr, "::mlir::xevm::LoadCacheControl::DEFAULT">:$l3_cache_control
249279
)> {
250280

251281
let summary = "2D block prefetch";

0 commit comments

Comments
 (0)