Skip to content

Commit fec0a64

Browse files
authored
[ROCDL] Added global/flag data prefetch ops (llvm#171449)
This PR brings data prefetch ops to ROCDL for gfx1250 architecture. Extended all necessary rocdl tests
1 parent 2acefcd commit fec0a64

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,31 @@ def ROCDL_RawBufferAtomicCmpSwap :
11731173
}];
11741174
}
11751175

1176+
//===---------------------------------------------------------------------===//
1177+
// Memory prefetch intrinsics
1178+
1179+
def ROCDL_GlobalPrefetchOp :
1180+
ROCDL_IntrOp<"global.prefetch", [], [], [], 0, 0, 0, 0, [1], ["scope"]>,
1181+
Arguments<(ins Arg<LLVM_PointerInAddressSpace<1>, "", []>:$ptr, I32Attr:$scope)> {
1182+
let description = [{
1183+
Prefetches 1 byte of data per lane from global memory into the WGP-cache or L2-cache.
1184+
Available on gfx1250+.
1185+
}];
1186+
let results = (outs);
1187+
let assemblyFormat = "$ptr `,` `scope` $scope attr-dict `:` qualified(type($ptr))";
1188+
}
1189+
1190+
def ROCDL_FlatPrefetchOp :
1191+
ROCDL_IntrOp<"flat.prefetch", [], [], [], 0, 0, 0, 0, [1], ["scope"]>,
1192+
Arguments<(ins Arg<LLVM_PointerInAddressSpace<0>, "", []>:$ptr, I32Attr:$scope)> {
1193+
let description = [{
1194+
Prefetches 1 byte of data per lane using flat-memory addresses into the WGP-cache or L2-cache.
1195+
Available on gfx1250+.
1196+
}];
1197+
let results = (outs);
1198+
let assemblyFormat = "$ptr `,` `scope` $scope attr-dict `:` qualified(type($ptr))";
1199+
}
1200+
11761201
//===---------------------------------------------------------------------===//
11771202
// MI-100 and MI-200 buffer atomic floating point add intrinsic
11781203

mlir/test/Dialect/LLVMIR/rocdl.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,20 @@ llvm.func @rocdl.raw.ptr.buffer.i32(%rsrc : !llvm.ptr<8>,
878878
llvm.return
879879
}
880880

881+
llvm.func @rocdl.global.prefetch(%ptr : !llvm.ptr<1>) {
882+
// CHECK-LABEL: rocdl.global.prefetch
883+
// CHECK: rocdl.global.prefetch %{{.*}}, scope 0 : !llvm.ptr<1>
884+
rocdl.global.prefetch %ptr, scope 0 : !llvm.ptr<1>
885+
llvm.return
886+
}
887+
888+
llvm.func @rocdl.flat.prefetch(%ptr : !llvm.ptr) {
889+
// CHECK-LABEL: rocdl.flat.prefetch
890+
// CHECK: rocdl.flat.prefetch %{{.*}}, scope 0 : !llvm.ptr
891+
rocdl.flat.prefetch %ptr, scope 0 : !llvm.ptr
892+
llvm.return
893+
}
894+
881895
// -----
882896

883897
llvm.func @rocdl.raw.buffer.f32(%rsrc : vector<4xi32>,

mlir/test/Target/LLVMIR/rocdl.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,20 @@ llvm.func @rocdl.raw.ptr.buffer.load.lds(%rsrc : !llvm.ptr<8>, %dstLds : !llvm.p
13411341
llvm.return
13421342
}
13431343

1344+
llvm.func @rocdl.global.prefetch(%ptr : !llvm.ptr<1>) {
1345+
// CHECK-LABEL: rocdl.global.prefetch
1346+
// CHECK: call void @llvm.amdgcn.global.prefetch(ptr addrspace(1) %{{.*}}, i32 0)
1347+
rocdl.global.prefetch %ptr, scope 0 : !llvm.ptr<1>
1348+
llvm.return
1349+
}
1350+
1351+
llvm.func @rocdl.flat.prefetch(%ptr : !llvm.ptr) {
1352+
// CHECK-LABEL: rocdl.flat.prefetch
1353+
// CHECK: call void @llvm.amdgcn.flat.prefetch(ptr %{{.*}}, i32 0)
1354+
rocdl.flat.prefetch %ptr, scope 0 : !llvm.ptr
1355+
llvm.return
1356+
}
1357+
13441358
llvm.func @rocdl.wmma.scale(%arg0: i32, %arg1: vector<4xf32>, %arg2: vector<8xi32>,
13451359
%arg3: vector<12xi32>, %arg5: vector<16xi32>,
13461360
%arg8: i64, %arg9: vector<8xf32>) -> vector<4xf32> {

0 commit comments

Comments
 (0)