Skip to content

Commit 80aaf7b

Browse files
committed
Rever to original polygeist passes inc
1 parent f4e0f98 commit 80aaf7b

File tree

3 files changed

+332
-197
lines changed

3 files changed

+332
-197
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(LLVM_TARGET_DEFINITIONS Passes.td)
22
mlir_tablegen(Passes.h.inc -gen-pass-decls -name Polygeist)
33
add_public_tablegen_target(MLIRPolygeistPassIncGen)
4-
add_dependencies(mlir-headers MLIRPolygeistPassIncGen)
4+
5+
add_mlir_doc(Passes PolygeistPasses ./ -gen-pass-doc)
Lines changed: 117 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,135 @@
1-
//===- Passes.h - Transform Pass Construction and Registration --*- C++ -*-===//
2-
//
3-
// This file is licensed 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-
#ifndef MLIR_DIALECT_POLYGEIST_TRANSFORMS_PASSES_H
10-
#define MLIR_DIALECT_POLYGEIST_TRANSFORMS_PASSES_H
1+
#ifndef POLYGEIST_DIALECT_POLYGEIST_PASSES_H
2+
#define POLYGEIST_DIALECT_POLYGEIST_PASSES_H
113

4+
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
5+
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
6+
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
127
#include "mlir/Pass/Pass.h"
13-
8+
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
9+
#include "polygeist/Dialect.h"
1410
#include <memory>
1511

12+
enum PolygeistAlternativesMode { PAM_Static, PAM_PGO_Profile, PAM_PGO_Opt };
13+
enum PolygeistGPUStructureMode {
14+
PGSM_Discard,
15+
PGSM_BlockThreadWrappers,
16+
PGSM_ThreadNoop,
17+
PGSM_BlockThreadNoops
18+
};
19+
1620
namespace mlir {
1721
class PatternRewriter;
22+
class RewritePatternSet;
1823
class DominanceInfo;
19-
class LLVMTypeConverter;
2024
namespace polygeist {
21-
//===----------------------------------------------------------------------===//
22-
// Patterns
23-
//===----------------------------------------------------------------------===//
24-
25-
/// Collect a set of patterns to convert memory-related operations from the
26-
/// MemRef dialect to the LLVM dialect forcing a "bare pointer" calling
27-
/// convention.
28-
void populateBareMemRefToLLVMConversionPatterns(LLVMTypeConverter &converter,
29-
RewritePatternSet &patterns);
30-
31-
#define GEN_PASS_DECL
32-
#include "mlir/Dialect/Polygeist/Transforms/Passes.h.inc"
33-
34-
std::unique_ptr<Pass> createArgumentPromotionPass();
35-
std::unique_ptr<Pass> createBarrierRemovalContinuation();
36-
std::unique_ptr<Pass> createCPUifyPass();
37-
std::unique_ptr<Pass> createCPUifyPass(const SCFCPUifyOptions &options);
38-
std::unique_ptr<Pass> createCanonicalizeForPass();
39-
std::unique_ptr<Pass> createDetectReductionPass();
40-
std::unique_ptr<Pass>
41-
createDetectReductionPass(const DetectReductionOptions &options);
42-
std::unique_ptr<Pass> createInnerSerializationPass();
43-
std::unique_ptr<Pass> createKernelDisjointSpecializationPass();
44-
std::unique_ptr<Pass> createKernelDisjointSpecializationPass(
45-
const KernelDisjointSpecializationOptions &options);
46-
std::unique_ptr<Pass> createLICMPass();
47-
std::unique_ptr<Pass> createLICMPass(const LICMOptions &options);
48-
std::unique_ptr<Pass> createLegalizeForSPIRVPass();
49-
std::unique_ptr<Pass> createLoopInternalizationPass();
50-
std::unique_ptr<Pass>
51-
createLoopInternalizationPass(const LoopInternalizationOptions &options);
25+
std::unique_ptr<Pass> createParallelLICMPass();
26+
std::unique_ptr<Pass> createPolygeistMem2RegPass();
5227
std::unique_ptr<Pass> createLoopRestructurePass();
53-
std::unique_ptr<Pass> createMem2RegPass();
28+
std::unique_ptr<Pass> createInnerSerializationPass();
29+
std::unique_ptr<Pass> createSerializationPass();
30+
std::unique_ptr<Pass> replaceAffineCFGPass();
5431
std::unique_ptr<Pass> createOpenMPOptPass();
55-
std::unique_ptr<Pass> createParallelLowerPass();
32+
std::unique_ptr<Pass> createCanonicalizeForPass();
5633
std::unique_ptr<Pass> createRaiseSCFToAffinePass();
34+
std::unique_ptr<Pass> createCPUifyPass(StringRef method = "");
35+
std::unique_ptr<Pass> createBarrierRemovalContinuation();
36+
std::unique_ptr<Pass> detectReductionPass();
5737
std::unique_ptr<Pass> createRemoveTrivialUsePass();
58-
std::unique_ptr<Pass> createReplaceAffineCFGPass();
59-
std::unique_ptr<Pass> createSYCLHostRaisingPass();
38+
std::unique_ptr<Pass> createParallelLowerPass(
39+
bool wrapParallelOps = false,
40+
PolygeistGPUStructureMode gpuKernelStructureMode = PGSM_Discard);
41+
std::unique_ptr<Pass> createConvertCudaRTtoCPUPass();
42+
std::unique_ptr<Pass> createConvertCudaRTtoGPUPass();
43+
std::unique_ptr<Pass> createConvertCudaRTtoHipRTPass();
44+
std::unique_ptr<Pass> createFixGPUFuncPass();
45+
std::unique_ptr<Pass> createSCFParallelLoopUnrollPass(int unrollFactor = 2);
46+
std::unique_ptr<Pass>
47+
createConvertPolygeistToLLVMPass(const LowerToLLVMOptions &options,
48+
bool useCStyleMemRef, bool onlyGpuModules,
49+
std::string gpuTarget);
50+
std::unique_ptr<Pass> createConvertPolygeistToLLVMPass();
51+
std::unique_ptr<Pass> createForBreakToWhilePass();
6052
std::unique_ptr<Pass>
61-
createSYCLHostRaisingPass(const SYCLRaiseHostConstructsOptions &options);
53+
createConvertParallelToGPUPass1(std::string arch = "sm_60");
54+
std::unique_ptr<Pass>
55+
createConvertParallelToGPUPass2(bool emitGPUKernelLaunchBounds = true);
56+
std::unique_ptr<Pass> createMergeGPUModulesPass();
57+
std::unique_ptr<Pass> createConvertToOpaquePtrPass();
58+
std::unique_ptr<Pass> createLowerAlternativesPass();
59+
std::unique_ptr<Pass> createCollectKernelStatisticsPass();
60+
std::unique_ptr<Pass> createPolygeistCanonicalizePass();
61+
std::unique_ptr<Pass>
62+
createPolygeistCanonicalizePass(const GreedyRewriteConfig &config,
63+
ArrayRef<std::string> disabledPatterns,
64+
ArrayRef<std::string> enabledPatterns);
65+
std::unique_ptr<Pass> createGpuSerializeToCubinPass(
66+
StringRef arch, StringRef features, int llvmOptLevel, int ptxasOptLevel,
67+
std::string ptxasPath, std::string libDevicePath, bool outputIntermediate);
68+
std::unique_ptr<Pass>
69+
createGpuSerializeToHsacoPass(StringRef arch, StringRef features,
70+
int llvmOptLevel, int hsaOptLevel,
71+
std::string rocmPath, bool outputIntermediate);
6272

63-
//===----------------------------------------------------------------------===//
64-
// Registration
65-
//===----------------------------------------------------------------------===//
66-
67-
#define GEN_PASS_REGISTRATION
68-
#include "mlir/Dialect/Polygeist/Transforms/Passes.h.inc"
73+
void registerGpuSerializeToCubinPass();
74+
void registerGpuSerializeToHsacoPass();
6975

76+
void populateForBreakToWhilePatterns(RewritePatternSet &patterns);
7077
} // namespace polygeist
7178
} // namespace mlir
7279

73-
#endif // MLIR_DIALECT_POLYGEIST_TRANSFORMS_PASSES_H
80+
void fully2ComposeAffineMapAndOperands(
81+
mlir::PatternRewriter &rewriter, mlir::AffineMap *map,
82+
llvm::SmallVectorImpl<mlir::Value> *operands, mlir::DominanceInfo &DI);
83+
bool isValidIndex(mlir::Value val);
84+
85+
namespace mlir {
86+
// Forward declaration from Dialect.h
87+
template <typename ConcreteDialect>
88+
void registerDialect(DialectRegistry &registry);
89+
90+
namespace arith {
91+
class ArithDialect;
92+
} // end namespace arith
93+
94+
namespace omp {
95+
class OpenMPDialect;
96+
} // end namespace omp
97+
98+
namespace polygeist {
99+
class PolygeistDialect;
100+
} // end namespace polygeist
101+
102+
namespace scf {
103+
class SCFDialect;
104+
} // end namespace scf
105+
106+
namespace cf {
107+
class ControlFlowDialect;
108+
} // end namespace cf
109+
110+
namespace math {
111+
class MathDialect;
112+
} // end namespace math
113+
114+
namespace memref {
115+
class MemRefDialect;
116+
} // end namespace memref
117+
118+
namespace func {
119+
class FuncDialect;
120+
}
121+
122+
namespace affine {
123+
class AffineDialect;
124+
}
125+
126+
namespace LLVM {
127+
class LLVMDialect;
128+
}
129+
130+
#define GEN_PASS_REGISTRATION
131+
#include "polygeist/Passes/Passes.h.inc"
132+
133+
} // end namespace mlir
134+
135+
#endif // POLYGEIST_DIALECT_POLYGEIST_PASSES_H

0 commit comments

Comments
 (0)