MLIR 24.0.0git
Passes.h
Go to the documentation of this file.
1//===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This header file defines prototypes that expose pass constructors.
10//
11//===----------------------------------------------------------------------===//
13#ifndef MLIR_DIALECT_GPU_TRANSFORMS_PASSES_H_
14#define MLIR_DIALECT_GPU_TRANSFORMS_PASSES_H_
15
19#include "mlir/Pass/Pass.h"
20
21namespace llvm {
22class TargetMachine;
23class LLVMContext;
24class Module;
25} // namespace llvm
26
27namespace mlir {
28class TypeConverter;
29class ConversionTarget;
30namespace func {
31class FuncOp;
32} // namespace func
33
34#define GEN_PASS_DECL
35#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
36
37/// Collect a set of patterns to rewrite GlobalIdOp op within the GPU dialect.
38void populateGpuGlobalIdPatterns(RewritePatternSet &patterns);
39
40/// Collect a set of patterns to rewrite SubgroupIdOp op within the GPU
41/// dialect.
42void populateGpuSubgroupIdPatterns(RewritePatternSet &patterns);
43
44/// Collect a set of patterns to rewrite shuffle ops within the GPU dialect.
45void populateGpuShufflePatterns(RewritePatternSet &patterns);
46
47/// Collect a set of patterns to rewrite all-reduce ops within the GPU dialect.
48void populateGpuAllReducePatterns(RewritePatternSet &patterns);
49
50/// Collect a set of patterns to break down subgroup_reduce ops into smaller
51/// ones supported by the target of `size <= maxShuffleBitwidth`, where `size`
52/// is the subgroup_reduce value bitwidth.
54 RewritePatternSet &patterns, unsigned maxShuffleBitwidth = 32,
55 PatternBenefit benefit = 1);
56
57/// Collect a set of patterns to lower `gpu.subgroup_reduce` into `gpu.shuffle`
58/// ops over `shuffleBitwidth` scalar types. Assumes that the subgroup has
59/// `subgroupSize` lanes. Uses the butterfly shuffle algorithm.
60///
61/// The patterns populated by this function will ignore ops with the
62/// `cluster_size` attribute.
63/// `populateGpuLowerClusteredSubgroupReduceToShufflePatterns` is the opposite.
65 RewritePatternSet &patterns, unsigned subgroupSize,
66 unsigned shuffleBitwidth = 32, PatternBenefit benefit = 1);
67
68/// Disjoint counterpart of `populateGpuLowerSubgroupReduceToShufflePatterns`
69/// that only matches `gpu.subgroup_reduce` ops with a `cluster_size`.
71 RewritePatternSet &patterns, unsigned subgroupSize,
72 unsigned shuffleBitwidth = 32, PatternBenefit benefit = 1);
73
74/// Collect all patterns to rewrite ops within the GPU dialect.
80
81namespace gpu {
82/// Searches for all GPU modules in `op` and transforms them into GPU binary
83/// operations. The resulting `gpu.binary` has `handler` as its offloading
84/// handler attribute.
86 Operation *op, OffloadingLLVMTranslationAttrInterface handler = nullptr,
87 const gpu::TargetOptions &options = {});
88} // namespace gpu
89
90//===----------------------------------------------------------------------===//
91// Registration
92//===----------------------------------------------------------------------===//
93
94/// Collect a set of patterns to decompose memrefs ops.
96
97/// Erase barriers that do not enforce conflicting memory side effects.
99
100/// Generate the code for registering passes.
101#define GEN_PASS_REGISTRATION
102#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
103
104} // namespace mlir
105
106#endif // MLIR_DIALECT_GPU_TRANSFORMS_PASSES_H_
static llvm::ManagedStatic< PassManagerOptions > options
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:227
LogicalResult transformGpuModulesToBinaries(Operation *op, OffloadingLLVMTranslationAttrInterface handler=nullptr, const gpu::TargetOptions &options={})
Searches for all GPU modules in op and transforms them into GPU binary operations.
Include the generated interface declarations.
void populateGpuShufflePatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite shuffle ops within the GPU dialect.
void populateGpuGlobalIdPatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite GlobalIdOp op within the GPU dialect.
void populateGpuRewritePatterns(RewritePatternSet &patterns)
Collect all patterns to rewrite ops within the GPU dialect.
Definition Passes.h:75
void populateGpuLowerSubgroupReduceToShufflePatterns(RewritePatternSet &patterns, unsigned subgroupSize, unsigned shuffleBitwidth=32, PatternBenefit benefit=1)
Collect a set of patterns to lower gpu.subgroup_reduce into gpu.shuffle ops over shuffleBitwidth scal...
void populateGpuLowerClusteredSubgroupReduceToShufflePatterns(RewritePatternSet &patterns, unsigned subgroupSize, unsigned shuffleBitwidth=32, PatternBenefit benefit=1)
Disjoint counterpart of populateGpuLowerSubgroupReduceToShufflePatterns that only matches gpu....
void populateGpuAllReducePatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite all-reduce ops within the GPU dialect.
void populateGpuBreakDownSubgroupReducePatterns(RewritePatternSet &patterns, unsigned maxShuffleBitwidth=32, PatternBenefit benefit=1)
Collect a set of patterns to break down subgroup_reduce ops into smaller ones supported by the target...
void populateGpuDecomposeMemrefsPatterns(RewritePatternSet &patterns)
Collect a set of patterns to decompose memrefs ops.
void populateGpuSubgroupIdPatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite SubgroupIdOp op within the GPU dialect.
void populateGpuEliminateBarriersPatterns(RewritePatternSet &patterns)
Erase barriers that do not enforce conflicting memory side effects.