Skip to content

Commit 040805d

Browse files
committed
[mlir] Add bar.warp.sync to NVVM
It adds the missing `bar.warp.sync` to the nvvm dialect. It is a barrier to synchronize for threads in a warp. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D135253
1 parent 1b9a6e5 commit 040805d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ def NVVM_VoteBallotOp :
168168
let hasCustomAssemblyFormat = 1;
169169
}
170170

171+
def NVVM_SyncWarpOp :
172+
NVVM_Op<"bar.warp.sync">,
173+
Arguments<(ins LLVM_Type:$mask)> {
174+
string llvmBuilder = [{
175+
createIntrinsicCall(builder, llvm::Intrinsic::nvvm_bar_warp_sync, {$mask});
176+
}];
177+
let assemblyFormat = "$mask attr-dict `:` type($mask)";
178+
}
179+
171180

172181
def NVVM_CpAsyncOp : NVVM_Op<"cp.async.shared.global">,
173182
Arguments<(ins LLVM_i8Ptr_shared:$dst,

mlir/test/Dialect/LLVMIR/nvvm.mlir

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ func.func @nvvm_vote(%arg0 : i32, %arg1 : i1) -> i32 {
7878
llvm.return %0 : i32
7979
}
8080

81+
// CHECK-LABEL: @llvm_nvvm_bar_warp_sync
82+
func.func @llvm_nvvm_bar_warp_sync(%mask : i32) {
83+
// CHECK: nvvm.bar.warp.sync %{{.*}}
84+
nvvm.bar.warp.sync %mask : i32
85+
llvm.return
86+
}
87+
8188
// CHECK-LABEL: @nvvm_mma_m8n8k4_row_col_f32_f32
8289
func.func @nvvm_mma_m8n8k4_row_col_f32_f32(%a0 : vector<2xf16>, %a1 : vector<2xf16>,
8390
%b0 : vector<2xf16>, %b1 : vector<2xf16>,

0 commit comments

Comments
 (0)