This PR merges the `triton-mlir` branch, in which we have been quietly rewriting the Triton backend from scratch to increase maintainability, stability and ultimately performance. Changes to the runtime are minimal, and this new version aims to remain backward-compatible with the previous commit. The legacy backend is now officially deprecated, but can still be accessed via the `legacy-backend` tag. Co-authored-by: Keren Zhou <kerenzhou@openai.com> Co-authored-by: Yan Chunwei <yanchunwei@outlook.com> Co-authored-by: goostavz <109190422+goostavz@users.noreply.github.com> Co-authored-by: Shintaro Iwasaki <siwasaki@fb.com> Co-authored-by: Yan Da <dyanab@connect.ust.hk> Co-authored-by: Jun Yang <yangjunpro@gmail.com> Co-authored-by: Ian Bearman <ianb@microsoft.com> Co-authored-by: Jason Ansel <jansel@jansel.net> Co-authored-by: Qingyi Liu <qingyil@nvidia.com> Co-authored-by: ben-zhang-609 <110140741+ben-zhang-609@users.noreply.github.com> Co-authored-by: Chenggang Zhao <lyricz@yeah.net> Co-authored-by: ben-zhang-609 <benzh609@gmail.com> Co-authored-by: dongdongl <dongdongl@nvidia.com>
55 lines
1.8 KiB
C++
55 lines
1.8 KiB
C++
#include "mlir/Pass/Pass.h"
|
|
#include "triton/Analysis/Allocation.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace {
|
|
|
|
struct TestAllocationPass
|
|
: public PassWrapper<TestAllocationPass, OperationPass<FuncOp>> {
|
|
|
|
// LLVM15+
|
|
// MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAllocationPass);
|
|
|
|
StringRef getArgument() const final { return "test-print-allocation"; }
|
|
StringRef getDescription() const final {
|
|
return "print the result of the allocation pass";
|
|
}
|
|
|
|
void runOnOperation() override {
|
|
Operation *operation = getOperation();
|
|
auto &os = llvm::errs();
|
|
// Convert to std::string can remove quotes from op_name
|
|
auto op_name = SymbolTable::getSymbolName(operation).getValue().str();
|
|
os << op_name << "\n";
|
|
Allocation allocation(operation);
|
|
operation->walk([&](Operation *op) {
|
|
auto scratchBufferId = allocation.getBufferId(op);
|
|
if (scratchBufferId != Allocation::InvalidBufferId) {
|
|
size_t offset = allocation.getOffset(scratchBufferId);
|
|
size_t size = allocation.getAllocatedSize(scratchBufferId);
|
|
os << "scratch offset = " << offset << ", size = " << size << "\n";
|
|
}
|
|
if (op->getNumResults() < 1)
|
|
return;
|
|
for (Value result : op->getResults()) {
|
|
auto bufferId = allocation.getBufferId(result);
|
|
if (bufferId != Allocation::InvalidBufferId) {
|
|
size_t offset = allocation.getOffset(bufferId);
|
|
size_t size = allocation.getAllocatedSize(bufferId);
|
|
os << "offset = " << offset << ", size = " << size << "\n";
|
|
}
|
|
}
|
|
});
|
|
os << "size = " << allocation.getSharedMemorySize() << "\n";
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
namespace mlir {
|
|
namespace test {
|
|
void registerTestAllocationPass() { PassRegistration<TestAllocationPass>(); }
|
|
} // namespace test
|
|
} // namespace mlir
|