Skip to content

Commit aa5b677

Browse files
committed
Add xevm blockload and blockstore op definition.
1 parent 8da3ab1 commit aa5b677

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/XeVMOps.td

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,78 @@ def XeVM_StoreCacheControlAttr
187187
let assemblyFormat = "`<` $value `>`";
188188
}
189189

190+
def XeVM_BlockLoadOp
191+
: XeVM_Op<"blockload">,
192+
Results<(outs FixedVectorOfRankAndType<[1], [XeVM_ElemType]>:$res)>,
193+
Arguments<(ins Arg<LLVM_AnyPointer, "", [MemRead]>:$ptr,
194+
OptionalAttr<XeVM_LoadCacheControlAttr>:$cache_control)> {
195+
let summary = "subgroup block load";
196+
let description = [{
197+
Reads one or more components of Result data for each invocation
198+
in the subgroup from the specified `ptr` as a block operation.
199+
The data is read strided, so the first value read is:
200+
```
201+
ptr[ SubgroupLocalInvocationId ]
202+
```
203+
and the second value read is:
204+
```
205+
ptr[ SubgroupLocalInvocationId + SubgroupMaxSize ]
206+
```
207+
Result type may be a scalar or vector type of scalar element type.
208+
209+
The parameters are:
210+
* `ptr` - the base address to load from
211+
* `cache_control` - an enumerator that sets the cache behaviour
212+
213+
Example:
214+
```mlir
215+
%loaded_a = xevm.blockload %src,
216+
<{cache_control=#xevm.load_cache_control<L1uc_L2uc_L3uc>}>
217+
: (!llvm.ptr<1>) -> vector<4xi16>
218+
```
219+
}];
220+
let assemblyFormat = [{
221+
operands prop-dict attr-dict `:` functional-type(operands, results)
222+
}];
223+
}
224+
225+
def XeVM_BlockStoreOp
226+
: XeVM_Op<"blockstore">,
227+
Arguments<(ins Arg<LLVM_AnyPointer, "", [MemWrite]>:$ptr,
228+
FixedVectorOfRankAndType<[1], [XeVM_ElemType]>:$val,
229+
OptionalAttr<XeVM_StoreCacheControlAttr>:$cache_control)> {
230+
let summary = "subgroup block store";
231+
let description = [{
232+
Writes one or more components of `val` for each invocation
233+
in the subgroup to the specified `ptr` as a block operation.
234+
The data is written strided, so the first value is written to:
235+
```
236+
ptr[ SubgroupLocalInvocationId ]
237+
```
238+
and the second value is written to:
239+
```
240+
ptr[ SubgroupLocalInvocationId + SubgroupMaxSize ]
241+
```
242+
`val` type may be a scalar or vector type of scalar element type.
243+
244+
The parameters are:
245+
* `ptr` - the base address to store to
246+
* `val` - the value to store
247+
* `cache_control` - an enumerator that sets the cache behaviour
248+
249+
Example:
250+
```mlir
251+
xevm.blockstore %ptr, %val
252+
<{cache_control=#xevm.store_cache_control<L1uc_L2uc_L3uc>}>
253+
: (!llvm.ptr<1>, vector<4xi16>)
254+
```
255+
}];
256+
257+
let assemblyFormat = [{
258+
operands prop-dict attr-dict `:` `(` type(operands) `)`
259+
}];
260+
}
261+
190262
def XeVM_BlockLoad2dOp
191263
: XeVM_Op<"blockload2d">,
192264
Results<(outs FixedVectorOfRankAndType<[1], [XeVM_ElemType]>:$res)>,

mlir/test/Dialect/LLVMIR/xevm.mlir

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ func.func @blockprefetch2d(%ptr: !llvm.ptr<1>, %base_width: i32, %base_height: i
5858
return
5959
}
6060

61+
// -----
62+
// CHECK-LABEL: func.func @blockload(
63+
// CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr<1>)
64+
func.func @blockload(%ptr: !llvm.ptr<1>) -> vector<4xi16> {
65+
// CHECK: %[[VAR0:.*]] = xevm.blockload %[[ARG0]]
66+
// CHECK-SAME: cache_control = #xevm.load_cache_control<L1uc_L2uc_L3uc>
67+
// CHECK-SAME: (!llvm.ptr<1>) -> vector<4xi16>
68+
%loaded = xevm.blockload %ptr <{cache_control=#xevm.load_cache_control<L1uc_L2uc_L3uc>}>
69+
: (!llvm.ptr<1>) -> vector<4xi16>
70+
return %loaded : vector<4xi16>
71+
}
72+
73+
// -----
74+
// CHECK-LABEL: func.func @blockstore(
75+
// CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr<1>,
76+
// CHECK-SAME: %[[ARG1:.*]]: vector<4xi32>)
77+
func.func @blockstore(%ptr: !llvm.ptr<1>, %value: vector<4xi32>) {
78+
// CHECK: xevm.blockstore %[[ARG0]], %[[ARG1]]
79+
// CHECK-SAME: (!llvm.ptr<1>, vector<4xi32>)
80+
xevm.blockstore %ptr, %value : (!llvm.ptr<1>, vector<4xi32>)
81+
return
82+
}
83+
6184
// -----
6285
// CHECK-LABEL: func.func @mma(
6386
// CHECK-SAME: %[[ARG0:.*]]: vector<8xf32>, %[[ARG1:.*]]: vector<8xi16>, %[[ARG2:.*]]: vector<8xi32>)

0 commit comments

Comments
 (0)