Skip to content

Commit 4de7cab

Browse files
committed
add option to print layout results
1 parent 0111b9f commit 4de7cab

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

mlir/include/mlir/Dialect/XeGPU/Transforms/Passes.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def XeGPUSubgroupDistribute : Pass<"xegpu-subgroup-distribute"> {
2929
"vector::VectorDialect"];
3030
}
3131

32-
def XeGPULayoutPropagate : Pass<"xegpu-propagate-layout"> {
32+
def XeGPUPropagateLayout : Pass<"xegpu-propagate-layout"> {
3333
let summary = "Propagate and assign XeGPU layout information";
3434
let description = [{
3535
This pass propagates the XeGPU layout information accross ops. Starting
@@ -40,6 +40,10 @@ def XeGPULayoutPropagate : Pass<"xegpu-propagate-layout"> {
4040
}];
4141
let dependentDialects = ["memref::MemRefDialect", "xegpu::XeGPUDialect",
4242
"vector::VectorDialect"];
43+
let options = [Option<
44+
"printOnly", "print-analysis-only", "bool",
45+
/*default=*/"false",
46+
"Print the result of layout propagation analysis and exit.">];
4347
}
4448

4549
def XeGPUWgToSgDistribute : Pass<"xegpu-wg-to-sg-distribute"> {

mlir/lib/Dialect/XeGPU/Transforms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ add_mlir_dialect_library(MLIRXeGPUTransforms
44
XeGPUSubgroupDistribute.cpp
55
XeGPUUnroll.cpp
66
XeGPUWgToSgDistribute.cpp
7-
XeGPULayoutPropagate.cpp
7+
XeGPUPropagateLayout.cpp
88

99
ADDITIONAL_HEADER_DIRS
1010
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/XeGPU

mlir/lib/Dialect/XeGPU/Transforms/XeGPULayoutPropagate.cpp renamed to mlir/lib/Dialect/XeGPU/Transforms/XeGPUPropagateLayout.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- XeGPULayoutPropagate.cpp - XeGPU Layout Propagation ------*- C++ -*-===//
1+
//===- XeGPUPropagateLayout.cpp - XeGPU Layout Propagation ------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -38,7 +38,7 @@
3838

3939
namespace mlir {
4040
namespace xegpu {
41-
#define GEN_PASS_DEF_XEGPULAYOUTPROPAGATE
41+
#define GEN_PASS_DEF_XEGPUPROPAGATELAYOUT
4242
#include "mlir/Dialect/XeGPU/Transforms/Passes.h.inc"
4343
} // namespace xegpu
4444
} // namespace mlir
@@ -622,8 +622,7 @@ LayoutInfo RunLayoutInfoPropagation::getLayoutInfo(Value val) {
622622
}
623623

624624
// Print the analysis result for debugging purposes.
625-
[[maybe_unused]] void
626-
RunLayoutInfoPropagation::printAnalysisResult(llvm::raw_ostream &os) {
625+
void RunLayoutInfoPropagation::printAnalysisResult(llvm::raw_ostream &os) {
627626
auto printFunctionResult = [&](FunctionOpInterface funcOp) {
628627
os << "function: " << funcOp.getName() << ":\n";
629628
// Function arguments
@@ -828,15 +827,25 @@ static LogicalResult updateFunctionOpInterface(mlir::OpBuilder &builder,
828827
}
829828

830829
namespace {
831-
struct XeGPULayoutPropagatePass final
832-
: public xegpu::impl::XeGPULayoutPropagateBase<XeGPULayoutPropagatePass> {
830+
struct XeGPUPropagateLayoutPass final
831+
: public xegpu::impl::XeGPUPropagateLayoutBase<XeGPUPropagateLayoutPass> {
832+
XeGPUPropagateLayoutPass() = default;
833+
XeGPUPropagateLayoutPass(const XeGPUPropagateLayoutPass &other) = default;
834+
XeGPUPropagateLayoutPass(xegpu::XeGPUPropagateLayoutOptions options)
835+
: XeGPUPropagateLayoutBase(options) {}
833836
void runOnOperation() override;
834837
};
835838

836839
} // namespace
837840

838-
void XeGPULayoutPropagatePass::runOnOperation() {
841+
void XeGPUPropagateLayoutPass::runOnOperation() {
839842
auto &analysis = getAnalysis<RunLayoutInfoPropagation>();
843+
// Print the analysis result and exit. (for debugging purposes)
844+
if (printOnly) {
845+
auto &os = llvm::outs();
846+
analysis.printAnalysisResult(os);
847+
return;
848+
}
840849
// Helper to convert LayoutInfo to xegpu::LayoutAttr.
841850
auto getXeGPULayoutForValue = [&](Value val) -> xegpu::LayoutAttr {
842851
LayoutInfo layout = analysis.getLayoutInfo(val);

0 commit comments

Comments
 (0)