MLIR 23.0.0git
Passes.h
Go to the documentation of this file.
1//===- Passes.h - GPU pipeline entry points--------------------------------===//
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#ifndef MLIR_DIALECT_GPU_PIPELINES_PASSES_H_
10#define MLIR_DIALECT_GPU_PIPELINES_PASSES_H_
11
13
14namespace mlir {
15namespace gpu {
16
17/// Options for the gpu to nvvm pipeline.
19 : public PassPipelineOptions<GPUToNVVMPipelineOptions> {
20 PassOptions::Option<int64_t> indexBitWidth{
21 *this, "index-bitwidth",
22 llvm::cl::desc("Bitwidth of the index type for the host (warning this "
23 "should be 64 until the GPU layering is fixed)"),
24 llvm::cl::init(64)};
25 PassOptions::Option<std::string> cubinTriple{
26 *this, "cubin-triple",
27 llvm::cl::desc("Triple to use to serialize to cubin."),
28 llvm::cl::init("nvptx64-nvidia-cuda")};
29 PassOptions::Option<std::string> cubinChip{
30 *this, "cubin-chip", llvm::cl::desc("Chip to use to serialize to cubin."),
31 llvm::cl::init("sm_75")};
32 PassOptions::Option<std::string> cubinFeatures{
33 *this, "cubin-features",
34 llvm::cl::desc("Features to use to serialize to cubin."),
35 llvm::cl::init("")};
36 PassOptions::Option<std::string> cubinFormat{
37 *this, "cubin-format",
38 llvm::cl::desc("Compilation format to use to serialize to cubin."),
39 llvm::cl::init("fatbin")};
40 PassOptions::Option<std::string> cmdOptions{
41 *this, "ptxas-cmd-options",
42 llvm::cl::desc(
43 "Command line options to pass to the downstream compiler."),
44 llvm::cl::init("")};
45 PassOptions::Option<int> optLevel{
46 *this, "opt-level",
47 llvm::cl::desc("Optimization level for NVVM compilation"),
48 llvm::cl::init(2)};
49 PassOptions::Option<bool> kernelUseBarePtrCallConv{
50 *this, "kernel-bare-ptr-calling-convention",
51 llvm::cl::desc(
52 "Whether to use the bareptr calling convention on the kernel "
53 "(warning this should be false until the GPU layering is fixed)"),
54 llvm::cl::init(false)};
55 PassOptions::Option<bool> hostUseBarePtrCallConv{
56 *this, "host-bare-ptr-calling-convention",
57 llvm::cl::desc(
58 "Whether to use the bareptr calling convention on the host (warning "
59 "this should be false until the GPU layering is fixed)"),
60 llvm::cl::init(false)};
61 PassOptions::Option<bool> allowPatternRollback{
62 *this, "allow-pattern-rollback",
63 llvm::cl::desc("Allow pattern rollback during dialect conversion"),
64 llvm::cl::init(true)};
65};
66
67/// Options for the gpu to rocdl pipeline.
69 : public PassPipelineOptions<GPUToROCDLPipelineOptions> {
70 PassOptions::Option<int64_t> indexBitWidth{
71 *this, "index-bitwidth",
72 llvm::cl::desc("Bitwidth of the index type for the host (warning this "
73 "should be 64 until the GPU layering is fixed)"),
74 llvm::cl::init(64)};
75 PassOptions::Option<std::string> triple{
76 *this, "triple",
77 llvm::cl::desc("AMDGPU target triple (e.g. amdgcn-amd-amdhsa)."),
78 llvm::cl::init("amdgcn-amd-amdhsa")};
79 PassOptions::Option<std::string> chip{
80 *this, "chip",
81 llvm::cl::desc(
82 "AMDGPU target chip (e.g. gfx90a, gfx942, gfx1100). Required: "
83 "AMDGCN binaries are not forward-compatible across chip families.")};
84 PassOptions::Option<std::string> features{
85 *this, "features", llvm::cl::desc("AMDGPU target features."),
86 llvm::cl::init("")};
87 PassOptions::Option<std::string> binaryFormat{
88 *this, "binary-format",
89 llvm::cl::desc("Final GPU binary emission format (e.g. fatbin, binary, "
90 "isa, llvm, offloading)."),
91 llvm::cl::init("fatbin")};
92 PassOptions::Option<std::string> abiVersion{
93 *this, "abi",
94 llvm::cl::desc("AMDHSA ABI version (e.g. \"500\", \"600\")."),
95 llvm::cl::init("600")};
96 PassOptions::Option<bool> wave64{
97 *this, "wave64",
98 llvm::cl::desc("Use Wave64 mode (default true; wave32 if false, "
99 "appropriate for RDNA / gfx10+ where supported)."),
100 llvm::cl::init(true)};
101 PassOptions::Option<int> optLevel{
102 *this, "opt-level",
103 llvm::cl::desc("Optimization level for ROCDL/AMDGPU compilation."),
104 llvm::cl::init(2)};
105 PassOptions::Option<std::string> cmdOptions{
106 *this, "rocdl-cmd-options",
107 llvm::cl::desc(
108 "Command line options to pass to the downstream AMDGPU compiler."),
109 llvm::cl::init("")};
110 PassOptions::Option<bool> kernelUseBarePtrCallConv{
111 *this, "kernel-bare-ptr-calling-convention",
112 llvm::cl::desc("Use bareptr calling convention for device kernels."),
113 llvm::cl::init(false)};
114 PassOptions::Option<bool> hostUseBarePtrCallConv{
115 *this, "host-bare-ptr-calling-convention",
116 llvm::cl::desc("Use bareptr calling convention for the host."),
117 llvm::cl::init(false)};
118};
119
120// Options for the gpu to xevm pipeline.
122 : public PassPipelineOptions<GPUToXeVMPipelineOptions> {
123 PassOptions::Option<std::string> xegpuOpLevel{
124 *this, "xegpu-op-level",
125 llvm::cl::desc("Granularity of XeGPU operations to target: workgroup | "
126 "subgroup | lane"),
127 llvm::cl::init("workgroup")};
128 // General lowering controls.
129 PassOptions::Option<bool> use64bitIndex{
130 *this, "use-64bit-index",
131 llvm::cl::desc("Bitwidth of the index type (host & device)"),
132 llvm::cl::init(true)};
133 PassOptions::Option<bool> kernelBarePtrCallConv{
134 *this, "kernel-bare-ptr-calling-convention",
135 llvm::cl::desc("Use bare pointer calling convention for device kernels"),
136 llvm::cl::init(false)};
137 PassOptions::Option<bool> hostBarePtrCallConv{
138 *this, "host-bare-ptr-calling-convention",
139 llvm::cl::desc("Use bare pointer calling convention for host launches"),
140 llvm::cl::init(false)};
141 PassOptions::Option<std::string> binaryFormat{
142 *this, "binary-format",
143 llvm::cl::desc("Final GPU binary emission format (e.g. fatbin)"),
144 llvm::cl::init("fatbin")};
145 // Options mirroring xevm-attach-target (GpuXeVMAttachTarget).
146 PassOptions::Option<std::string> xevmModuleMatcher{
147 *this, "xevm-module-matcher",
148 llvm::cl::desc("Regex to match gpu.module names for XeVM target attach"),
149 llvm::cl::init("")};
150 PassOptions::Option<std::string> zebinTriple{
151 *this, "zebin-triple", llvm::cl::desc("Target triple for XeVM codegen"),
152 llvm::cl::init("spirv64-unknown-unknown")};
153 PassOptions::Option<std::string> zebinChip{
154 *this, "zebin-chip", llvm::cl::desc("Target chip (e.g. pvc, bmg)"),
155 llvm::cl::init("bmg")};
156 PassOptions::Option<unsigned> optLevel{
157 *this, "opt-level",
158 llvm::cl::desc("Optimization level for attached target/codegen"),
159 llvm::cl::init(2)};
160 PassOptions::Option<std::string> cmdOptions{
161 *this, "igc-cmd-options",
162 llvm::cl::desc("Additional downstream compiler command line options"),
163 llvm::cl::init("")};
164};
165
166//===----------------------------------------------------------------------===//
167// Building and Registering.
168//===----------------------------------------------------------------------===//
169
170/// Adds the GPU to NVVM pipeline to the given pass manager. Transforms main
171/// dialects into NVVM targets. Begins with GPU code regions, then handles host
172/// code.
174 const GPUToNVVMPipelineOptions &options);
175
176/// Adds the GPU to ROCDL pipeline to the given pass manager. Transforms main
177/// dialects (arith, memref, scf, vector, gpu) into ROCDL/AMDGPU. Begins with
178/// GPU code regions, then handles host code.
180 const GPUToROCDLPipelineOptions &options);
181
182/// Adds the GPU to XeVM pipeline to the given pass manager. Transforms main
183/// dialects into XeVM targets. Begins with GPU code regions, then handles host
184/// code.
186 const GPUToXeVMPipelineOptions &options);
187
188/// Register all pipelines for the `gpu` dialect.
192
193} // namespace gpu
194} // namespace mlir
195
196#endif
static llvm::ManagedStatic< PassManagerOptions > options
This class represents a pass manager that runs passes on either a specific operation type,...
Definition PassManager.h:46
void registerGPUToNVVMPipeline()
Register all pipelines for the gpu dialect.
void registerGPUToXeVMPipeline()
void buildLowerToXeVMPassPipeline(OpPassManager &pm, const GPUToXeVMPipelineOptions &options)
Adds the GPU to XeVM pipeline to the given pass manager.
void registerGPUToROCDLPipeline()
void buildLowerToROCDLPassPipeline(OpPassManager &pm, const GPUToROCDLPipelineOptions &options)
Adds the GPU to ROCDL pipeline to the given pass manager.
void buildLowerToNVVMPassPipeline(OpPassManager &pm, const GPUToNVVMPipelineOptions &options)
Adds the GPU to NVVM pipeline to the given pass manager.
Include the generated interface declarations.
Options for the gpu to nvvm pipeline.
Definition Passes.h:19
PassOptions::Option< std::string > cubinChip
Definition Passes.h:29
PassOptions::Option< int > optLevel
Definition Passes.h:45
PassOptions::Option< bool > allowPatternRollback
Definition Passes.h:61
PassOptions::Option< bool > hostUseBarePtrCallConv
Definition Passes.h:55
PassOptions::Option< std::string > cmdOptions
Definition Passes.h:40
PassOptions::Option< std::string > cubinFeatures
Definition Passes.h:32
PassOptions::Option< std::string > cubinFormat
Definition Passes.h:36
PassOptions::Option< int64_t > indexBitWidth
Definition Passes.h:20
PassOptions::Option< std::string > cubinTriple
Definition Passes.h:25
PassOptions::Option< bool > kernelUseBarePtrCallConv
Definition Passes.h:49
Options for the gpu to rocdl pipeline.
Definition Passes.h:69
PassOptions::Option< std::string > chip
Definition Passes.h:79
PassOptions::Option< std::string > cmdOptions
Definition Passes.h:105
PassOptions::Option< int64_t > indexBitWidth
Definition Passes.h:70
PassOptions::Option< std::string > triple
Definition Passes.h:75
PassOptions::Option< std::string > abiVersion
Definition Passes.h:92
PassOptions::Option< bool > hostUseBarePtrCallConv
Definition Passes.h:114
PassOptions::Option< bool > wave64
Definition Passes.h:96
PassOptions::Option< bool > kernelUseBarePtrCallConv
Definition Passes.h:110
PassOptions::Option< std::string > binaryFormat
Definition Passes.h:87
PassOptions::Option< int > optLevel
Definition Passes.h:101
PassOptions::Option< std::string > features
Definition Passes.h:84
PassOptions::Option< bool > hostBarePtrCallConv
Definition Passes.h:137
PassOptions::Option< unsigned > optLevel
Definition Passes.h:156
PassOptions::Option< std::string > xegpuOpLevel
Definition Passes.h:123
PassOptions::Option< std::string > xevmModuleMatcher
Definition Passes.h:146
PassOptions::Option< std::string > zebinTriple
Definition Passes.h:150
PassOptions::Option< bool > kernelBarePtrCallConv
Definition Passes.h:133
PassOptions::Option< std::string > binaryFormat
Definition Passes.h:141
PassOptions::Option< std::string > cmdOptions
Definition Passes.h:160
PassOptions::Option< bool > use64bitIndex
Definition Passes.h:129
PassOptions::Option< std::string > zebinChip
Definition Passes.h:153