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>
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#include "mlir/Dialect/GPU/GPUDialect.h"
|
|
#include "mlir/IR/Dialect.h"
|
|
#include "mlir/Pass/Pass.h"
|
|
#include "triton/Analysis/Allocation.h"
|
|
#include "triton/Analysis/Membar.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace {
|
|
|
|
struct TestMembarPass
|
|
: public PassWrapper<TestMembarPass, OperationPass<FuncOp>> {
|
|
|
|
// LLVM15+
|
|
// MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMembarPass);
|
|
|
|
StringRef getArgument() const final { return "test-print-membar"; }
|
|
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);
|
|
MembarAnalysis membarPass(&allocation);
|
|
membarPass.run();
|
|
|
|
size_t operationId = 0;
|
|
operation->walk<WalkOrder::PreOrder>([&](Operation *op) {
|
|
if (isa<gpu::BarrierOp>(op)) {
|
|
os << "Membar " << operationId << "\n";
|
|
}
|
|
if (op->getNumRegions() == 0) {
|
|
// Don't count parent Operation to simplify the test.
|
|
operationId++;
|
|
}
|
|
return;
|
|
});
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
namespace mlir {
|
|
namespace test {
|
|
void registerTestMembarPass() { PassRegistration<TestMembarPass>(); }
|
|
} // namespace test
|
|
} // namespace mlir
|