Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ For detailed instructions on how to debug Triton's frontend, please refer to thi
kernels. Use `MLIR_ENABLE_DUMP=kernelName` to dump for a specific kernel only.
- Triton cache can interfere with the dump. In cases where `MLIR_ENABLE_DUMP=1` does not work, try cleaning your triton cache: `rm -r ~/.triton/cache/*`
- `LLVM_IR_ENABLE_DUMP=1` dumps the IR before every pass run over the LLVM IR.
- `TRITON_REPRODUCER_PATH=<reproducer_path>` will generate an MLIR reproducer file
at `<reproducer_path>` before each MLIR compiler stage. If any of the stages fail,
`<reproducer_path>` will be a local MLIR reproducer captured right before the failing pass.
- `TRITON_INTERPRET=1` uses the Triton interpreter instead of running on the
GPU. You can insert Python breakpoints in your kernel code!
- `TRITON_ENABLE_LLVM_DEBUG=1` passes `-debug` to LLVM, printing a lot of
Expand Down
13 changes: 13 additions & 0 deletions python/src/ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,14 @@ void init_triton_ir(py::module &&m) {
auto anchorName = self.getOpAnchorName();
auto passes = self.getPasses();
Operation *op = mod.getOperation();
// Save a reproducer for the current pass manager invocation
// immediately.
makeReproducer(anchorName, passes, op, reproducerPath);
// But if the pass manager crashes, attempt to generate a local
// reproducer instead.
mod.getContext()->disableMultithreading();
self.enableCrashReproducerGeneration(reproducerPath,
/*genLocalReproducer=*/true);
}

if (triton::tools::getBoolEnv("TRITON_ENABLE_LLVM_DEBUG")) {
Expand Down Expand Up @@ -1740,6 +1747,12 @@ void init_triton_ir(py::module &&m) {
self.enableTiming();
}

// Run the pass manager under a source manager diagnostic handler, which
// enables emitted MLIR diagnostics to directly reference Python source
// code.
llvm::SourceMgr sourceMgr;
SourceMgrDiagnosticHandler diagHandler(sourceMgr, mod.getContext(),
llvm::errs());
if (failed(self.run(mod.getOperation())))
throw std::runtime_error("PassManager::run failed");
});
Expand Down