Skip to content

[mlir] [XeGPU] Add XeGPU workgroup to subgroup pass #139477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 19 additions & 12 deletions mlir/include/mlir/Dialect/XeGPU/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//


#ifndef MLIR_DIALECT_XEGPU_TRANSFORMS_PASSES_TD
#define MLIR_DIALECT_XEGPU_TRANSFORMS_PASSES_TD

Expand All @@ -18,24 +17,32 @@ def XeGPUFoldAliasOps : Pass<"xegpu-fold-alias-ops"> {
The pass folds aliasing ops into XeGPU ops that they operate on the original
source references.
}];
let dependentDialects = [
"memref::MemRefDialect", "xegpu::XeGPUDialect"
];
let dependentDialects = ["memref::MemRefDialect", "xegpu::XeGPUDialect"];
}

def XeGPUSubgroupDistribute : Pass<"xegpu-subgroup-distribute"> {
let summary = "Distribute XeGPU ops to work items";
let description = [{
The pass distributes subgroup level (SIMD) XeGPU ops to work items.
}];
let dependentDialects = [
"memref::MemRefDialect", "xegpu::XeGPUDialect", "vector::VectorDialect"
];
let options = [
Option<"printOnly", "print-analysis-only", "bool",
/*default=*/"false",
"Print the result of the subgroup map propagation analysis and exit.">
];
let dependentDialects = ["memref::MemRefDialect", "xegpu::XeGPUDialect",
"vector::VectorDialect"];
let options = [Option<
"printOnly", "print-analysis-only", "bool",
/*default=*/"false",
"Print the result of the subgroup map propagation analysis and exit.">];
}

def XeGPUWgToSg : Pass<"xegpu-wg-to-sg", "::mlir::gpu::GPUModuleOp"> {
let summary = "Transform WorkGroup level XeGPU code to SubGroup level";
let description = [{
This transform pass distributes the workgroup level computation to
multiple subgroups based on the sg_layout and sg_data attributes.
}];

let dependentDialects = ["memref::MemRefDialect", "xegpu::XeGPUDialect",
"vector::VectorDialect", "arith::ArithDialect",
"gpu::GPUDialect", "index::IndexDialect"];
}

#endif // MLIR_DIALECT_XEGPU_TRANSFORMS_PASSES_TD
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/XeGPU/Transforms/Transforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void populateXeGPUFoldAliasOpsPatterns(RewritePatternSet &patterns);

/// Appends patterns for XeGPU SIMT distribution into `patterns`.
void populateXeGPUSubgroupDistributePatterns(RewritePatternSet &patterns);
void populateXeGPUWgToSgPatterns(RewritePatternSet &patterns);

/// Collect a set of patterns to unroll xegpu operations to a smaller shapes.
/// Users can control whether an operation to be unrolled or not, as well as
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/XeGPU/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_mlir_dialect_library(MLIRXeGPUTransforms
XeGPUFoldAliasOps.cpp
XeGPUSubgroupDistribute.cpp
XeGPUUnroll.cpp
XeGPUWgToSg.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/XeGPU
Expand Down
Loading