Skip to content

Commit

Permalink
[FRONTEND] Add possibility for user to force a GPU threadsync barrier (
Browse files Browse the repository at this point in the history
…#976)

compiler still has pitfalls even in master branch
  • Loading branch information
ptillet authored Dec 12, 2022
1 parent 52accd4 commit e552219
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion python/src/triton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void init_triton_ir(py::module &&m) {
// some placeholders
self.getOrLoadDialect<mlir::triton::TritonDialect>();
self.getOrLoadDialect<mlir::LLVM::LLVMDialect>();
self.getOrLoadDialect<mlir::gpu::GPUDialect>();
});
// .def(py::init([](){
// mlir::MLIRContext context;
Expand Down Expand Up @@ -1265,7 +1266,13 @@ void init_triton_ir(py::module &&m) {
[](mlir::OpBuilder &self, mlir::Type &type) -> mlir::Value {
auto loc = self.getUnknownLoc();
return self.create<::mlir::LLVM::UndefOp>(loc, type);
});
})
// Force GPU barrier
.def("create_barrier",
[](mlir::OpBuilder &self) {
auto loc = self.getUnknownLoc();
self.create<mlir::gpu::BarrierOp>(loc);
});

py::class_<mlir::PassManager>(m, "pass_manager")
.def(py::init<mlir::MLIRContext *>())
Expand Down
2 changes: 1 addition & 1 deletion python/triton/language/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ def max_contiguous(x: tl.tensor, values: List[int]) -> tl.tensor:


def debug_barrier(builder: ir.builder) -> tl.tensor:
return tl.tensor(builder.create_barrier(''), tl.void)
return tl.tensor(builder.create_barrier(), tl.void)


def printf(prefix: str, args: List[tl.tensor], builder: ir.builder) -> tl.tensor:
Expand Down

0 comments on commit e552219

Please sign in to comment.