Skip to content

Commit 747620d

Browse files
authored
[mlir] [XeGPU] Add XeGPU workgroup to subgroup pass (#139477)
This PR adds the XeGPU workgroup (wg) to subgroup (sg) pass. The wg to sg pass transforms the xegpu wg level operations to subgroup operations based on the sg_layout and sg_data attribute. The PR adds transformation patterns for following Ops 1. CreateNdDesc 2. LoadNd 3. StoreNd 4. PrefetchNd 4. UpdateNdOffset 5. Dpas
1 parent 5999988 commit 747620d

File tree

6 files changed

+676
-12
lines changed

6 files changed

+676
-12
lines changed

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
109
#ifndef MLIR_DIALECT_XEGPU_TRANSFORMS_PASSES_TD
1110
#define MLIR_DIALECT_XEGPU_TRANSFORMS_PASSES_TD
1211

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

2623
def XeGPUSubgroupDistribute : Pass<"xegpu-subgroup-distribute"> {
2724
let summary = "Distribute XeGPU ops to work items";
2825
let description = [{
2926
The pass distributes subgroup level (SIMD) XeGPU ops to work items.
3027
}];
31-
let dependentDialects = [
32-
"memref::MemRefDialect", "xegpu::XeGPUDialect", "vector::VectorDialect"
33-
];
34-
let options = [
35-
Option<"printOnly", "print-analysis-only", "bool",
36-
/*default=*/"false",
37-
"Print the result of the subgroup map propagation analysis and exit.">
38-
];
28+
let dependentDialects = ["memref::MemRefDialect", "xegpu::XeGPUDialect",
29+
"vector::VectorDialect"];
30+
let options = [Option<
31+
"printOnly", "print-analysis-only", "bool",
32+
/*default=*/"false",
33+
"Print the result of the subgroup map propagation analysis and exit.">];
34+
}
35+
36+
def XeGPUWgToSgDistribute : Pass<"xegpu-wg-to-sg-distribute"> {
37+
let summary = "Transform WorkGroup level XeGPU code to SubGroup level";
38+
let description = [{
39+
This transform pass distributes the workgroup level computation to
40+
multiple subgroups based on the sg_layout and sg_data attributes.
41+
}];
42+
43+
let dependentDialects = ["memref::MemRefDialect", "xegpu::XeGPUDialect",
44+
"vector::VectorDialect", "arith::ArithDialect",
45+
"gpu::GPUDialect", "index::IndexDialect"];
3946
}
4047

4148
#endif // MLIR_DIALECT_XEGPU_TRANSFORMS_PASSES_TD

mlir/include/mlir/Dialect/XeGPU/Transforms/Transforms.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void populateXeGPUFoldAliasOpsPatterns(RewritePatternSet &patterns);
6262

6363
/// Appends patterns for XeGPU SIMT distribution into `patterns`.
6464
void populateXeGPUSubgroupDistributePatterns(RewritePatternSet &patterns);
65+
void populateXeGPUWgToSgDistributePatterns(RewritePatternSet &patterns);
6566

6667
/// Collect a set of patterns to unroll xegpu operations to a smaller shapes.
6768
/// Users can control whether an operation to be unrolled or not, as well as

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ add_mlir_dialect_library(MLIRXeGPUTransforms
22
XeGPUFoldAliasOps.cpp
33
XeGPUSubgroupDistribute.cpp
44
XeGPUUnroll.cpp
5+
XeGPUWgToSgDistribute.cpp
56

67
ADDITIONAL_HEADER_DIRS
78
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/XeGPU

0 commit comments

Comments
 (0)