MLIR 24.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> arch{
76 *this, "arch",
77 llvm::cl::desc(
78 "AMDGPU target architecture, as in Clang, with optional target-ID "
79 "modifiers (e.g. gfx942, gfx90a:xnack+, amdgpu9.42-amd-amdhsa, "
80 "amdgpu9.0a-amd-amdhsa--gfx90a:xnack-). Supersedes the separate "
81 "triple option this pipeline used to take. Required: AMDGCN "
82 "binaries are not forward-compatible across chip families.")};
83 PassOptions::Option<std::string> chip{
84 *this, "chip", llvm::cl::desc("Deprecated alias for 'arch'."),
85 llvm::cl::init("")};
86 PassOptions::Option<std::string> binaryFormat{
87 *this, "binary-format",
88 llvm::cl::desc("Final GPU binary emission format (e.g. fatbin, binary, "
89 "isa, llvm, offloading)."),
90 llvm::cl::init("fatbin")};
91 PassOptions::Option<std::string> abiVersion{
92 *this, "abi",
93 llvm::cl::desc("AMDHSA ABI version (e.g. \"500\", \"600\")."),
94 llvm::cl::init("600")};
95 PassOptions::Option<unsigned> waveSize{
96 *this, "wavesize",
97 llvm::cl::desc("Wavefront size (32 or 64) for targets that run at "
98 "either, or 0 to use the architecture's default."),
99 llvm::cl::init(0)};
100 PassOptions::Option<int> optLevel{
101 *this, "opt-level",
102 llvm::cl::desc("Optimization level for ROCDL/AMDGPU compilation."),
103 llvm::cl::init(2)};
104 PassOptions::Option<std::string> cmdOptions{
105 *this, "rocdl-cmd-options",
106 llvm::cl::desc(
107 "Command line options to pass to the downstream AMDGPU compiler."),
108 llvm::cl::init("")};
109 PassOptions::Option<bool> kernelUseBarePtrCallConv{
110 *this, "kernel-bare-ptr-calling-convention",
111 llvm::cl::desc("Use bareptr calling convention for device kernels."),
112 llvm::cl::init(false)};
113 PassOptions::Option<bool> hostUseBarePtrCallConv{
114 *this, "host-bare-ptr-calling-convention",
115 llvm::cl::desc("Use bareptr calling convention for the host."),
116 llvm::cl::init(false)};
117};
118
119// Options for the gpu to xevm pipeline.
121 : public PassPipelineOptions<GPUToXeVMPipelineOptions> {
122 PassOptions::Option<std::string> xegpuOpLevel{
123 *this, "xegpu-op-level",
124 llvm::cl::desc("Granularity of XeGPU operations to target: workgroup | "
125 "subgroup | lane"),
126 llvm::cl::init("workgroup")};
127 PassOptions::Option<bool> enableVectorToXeGPU{
128 *this, "enable-vector-to-xegpu",
129 llvm::cl::desc("Run convert-vector-to-xegpu so the pipeline can accept "
130 "vector dialect (one level above XeGPU) as entry IR"),
131 llvm::cl::init(false)};
132 // General lowering controls.
133 PassOptions::Option<bool> use64bitIndex{
134 *this, "use-64bit-index",
135 llvm::cl::desc("Bitwidth of the index type (host & device)"),
136 llvm::cl::init(true)};
137 PassOptions::Option<bool> kernelBarePtrCallConv{
138 *this, "kernel-bare-ptr-calling-convention",
139 llvm::cl::desc("Use bare pointer calling convention for device kernels"),
140 llvm::cl::init(false)};
141 PassOptions::Option<bool> hostBarePtrCallConv{
142 *this, "host-bare-ptr-calling-convention",
143 llvm::cl::desc("Use bare pointer calling convention for host launches"),
144 llvm::cl::init(false)};
145 PassOptions::Option<std::string> binaryFormat{
146 *this, "binary-format",
147 llvm::cl::desc("Final GPU binary emission format (e.g. fatbin). Valid "
148 "values are the set of values for the format argument of "
149 "-gpu-module-to-binary pass plus a special value: skip, "
150 "which skips invoking -gpu-module-to-binary pass."),
151 llvm::cl::init("fatbin")};
152 // Options mirroring xevm-attach-target (GpuXeVMAttachTarget).
153 PassOptions::Option<std::string> xevmModuleMatcher{
154 *this, "xevm-module-matcher",
155 llvm::cl::desc("Regex to match gpu.module names for XeVM target attach"),
156 llvm::cl::init("")};
157 PassOptions::Option<std::string> zebinTriple{
158 *this, "zebin-triple", llvm::cl::desc("Target triple for XeVM codegen"),
159 llvm::cl::init("spirv64-unknown-unknown")};
160 PassOptions::Option<std::string> zebinChip{
161 *this, "zebin-chip", llvm::cl::desc("Target chip (e.g. pvc, bmg)"),
162 llvm::cl::init("bmg")};
163 PassOptions::Option<unsigned> optLevel{
164 *this, "opt-level",
165 llvm::cl::desc("Optimization level for attached target/codegen"),
166 llvm::cl::init(2)};
167 PassOptions::Option<std::string> cmdOptions{
168 *this, "igc-cmd-options",
169 llvm::cl::desc("Additional downstream compiler command line options"),
170 llvm::cl::init("")};
171 // Options for MathExtendToSupportedTypes and ArithEmulateUnsupportedFloats,
172 // run on the host/device module before conversion to LLVM to legalize math
173 // and arith ops operating on floating-point types that the XeVM target
174 // cannot handle natively (e.g. bf16).
175 PassOptions::ListOption<std::string> unsupportedSourceTypes{
176 *this, "unsupported-source-types",
177 llvm::cl::desc("Floating-point source types without arithmetic/math "
178 "support on the target (e.g. bf16)"),
179 llvm::cl::list_init<std::string>(ArrayRef<std::string>{"bf16"})};
180 PassOptions::Option<std::string> supportedTargetTypes{
181 *this, "supported-target-types",
182 llvm::cl::desc(
183 "Floating-point target type used to emulate the unsupported "
184 "source types via extf/truncf pairs"),
185 llvm::cl::init("f32")};
186 // Additional types (beyond the implicit f32/f64) that math ops are allowed
187 // to run on directly. Maps to the `extra-types` option of
188 // math-extend-to-supported-types. Leave empty to extend every non-f32/f64
189 // math op to `supported-target-types`.
190 PassOptions::ListOption<std::string> mathExtendExtraTypes{
191 *this, "math-extend-extra-types",
192 llvm::cl::desc(
193 "Extra floating-point types with math op support on the target, "
194 "in addition to f32 and f64 (maps to math-extend-to-supported-"
195 "types `extra-types`)"),
196 llvm::cl::list_init<std::string>(ArrayRef<std::string>{"f16"})};
197};
198
199//===----------------------------------------------------------------------===//
200// Building and Registering.
201//===----------------------------------------------------------------------===//
202
203/// Adds the GPU to NVVM pipeline to the given pass manager. Transforms main
204/// dialects into NVVM targets. Begins with GPU code regions, then handles host
205/// code.
207 const GPUToNVVMPipelineOptions &options);
208
209/// Adds the GPU to ROCDL pipeline to the given pass manager. Transforms main
210/// dialects (arith, memref, scf, vector, gpu) into ROCDL/AMDGPU. Begins with
211/// GPU code regions, then handles host code.
213 const GPUToROCDLPipelineOptions &options);
214
215/// Adds the GPU to XeVM pipeline to the given pass manager. Transforms main
216/// dialects into XeVM targets. Begins with GPU code regions, then handles host
217/// code.
219 const GPUToXeVMPipelineOptions &options);
220
221/// Register all pipelines for the `gpu` dialect.
225
226} // namespace gpu
227} // namespace mlir
228
229#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:83
PassOptions::Option< unsigned > waveSize
Definition Passes.h:95
PassOptions::Option< std::string > cmdOptions
Definition Passes.h:104
PassOptions::Option< int64_t > indexBitWidth
Definition Passes.h:70
PassOptions::Option< std::string > abiVersion
Definition Passes.h:91
PassOptions::Option< bool > hostUseBarePtrCallConv
Definition Passes.h:113
PassOptions::Option< bool > kernelUseBarePtrCallConv
Definition Passes.h:109
PassOptions::Option< std::string > arch
Definition Passes.h:75
PassOptions::Option< std::string > binaryFormat
Definition Passes.h:86
PassOptions::Option< int > optLevel
Definition Passes.h:100
PassOptions::Option< bool > hostBarePtrCallConv
Definition Passes.h:141
PassOptions::ListOption< std::string > unsupportedSourceTypes
Definition Passes.h:175
PassOptions::Option< unsigned > optLevel
Definition Passes.h:163
PassOptions::ListOption< std::string > mathExtendExtraTypes
Definition Passes.h:190
PassOptions::Option< std::string > xegpuOpLevel
Definition Passes.h:122
PassOptions::Option< std::string > xevmModuleMatcher
Definition Passes.h:153
PassOptions::Option< std::string > zebinTriple
Definition Passes.h:157
PassOptions::Option< bool > kernelBarePtrCallConv
Definition Passes.h:137
PassOptions::Option< std::string > binaryFormat
Definition Passes.h:145
PassOptions::Option< std::string > supportedTargetTypes
Definition Passes.h:180
PassOptions::Option< bool > enableVectorToXeGPU
Definition Passes.h:127
PassOptions::Option< std::string > cmdOptions
Definition Passes.h:167
PassOptions::Option< bool > use64bitIndex
Definition Passes.h:133
PassOptions::Option< std::string > zebinChip
Definition Passes.h:160