MLIR  22.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 
12 #include "mlir/Pass/PassOptions.h"
13 
14 namespace mlir {
15 namespace 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_50")};
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("+ptx60")};
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 };
62 
63 // Options for the gpu to xevm pipeline.
65  : public PassPipelineOptions<GPUToXeVMPipelineOptions> {
66  PassOptions::Option<std::string> xegpuOpLevel{
67  *this, "xegpu-op-level",
68  llvm::cl::desc("Granularity of XeGPU operations to target: workgroup | "
69  "subgroup | lane"),
70  llvm::cl::init("workgroup")};
71  // General lowering controls.
72  PassOptions::Option<bool> use64bitIndex{
73  *this, "use-64bit-index",
74  llvm::cl::desc("Bitwidth of the index type (host & device)"),
75  llvm::cl::init(true)};
76  PassOptions::Option<bool> kernelBarePtrCallConv{
77  *this, "kernel-bare-ptr-calling-convention",
78  llvm::cl::desc("Use bare pointer calling convention for device kernels"),
79  llvm::cl::init(false)};
80  PassOptions::Option<bool> hostBarePtrCallConv{
81  *this, "host-bare-ptr-calling-convention",
82  llvm::cl::desc("Use bare pointer calling convention for host launches"),
83  llvm::cl::init(false)};
84  PassOptions::Option<std::string> binaryFormat{
85  *this, "binary-format",
86  llvm::cl::desc("Final GPU binary emission format (e.g. fatbin)"),
87  llvm::cl::init("fatbin")};
88  // Options mirroring xevm-attach-target (GpuXeVMAttachTarget).
89  PassOptions::Option<std::string> xevmModuleMatcher{
90  *this, "xevm-module-matcher",
91  llvm::cl::desc("Regex to match gpu.module names for XeVM target attach"),
92  llvm::cl::init("")};
93  PassOptions::Option<std::string> zebinTriple{
94  *this, "zebin-triple", llvm::cl::desc("Target triple for XeVM codegen"),
95  llvm::cl::init("spirv64-unknown-unknown")};
96  PassOptions::Option<std::string> zebinChip{
97  *this, "zebin-chip", llvm::cl::desc("Target chip (e.g. pvc, bmg)"),
98  llvm::cl::init("bmg")};
99  PassOptions::Option<unsigned> optLevel{
100  *this, "opt-level",
101  llvm::cl::desc("Optimization level for attached target/codegen"),
102  llvm::cl::init(2)};
103  PassOptions::Option<std::string> cmdOptions{
104  *this, "igc-cmd-options",
105  llvm::cl::desc("Additional downstream compiler command line options"),
106  llvm::cl::init("")};
107 };
108 
109 //===----------------------------------------------------------------------===//
110 // Building and Registering.
111 //===----------------------------------------------------------------------===//
112 
113 /// Adds the GPU to NVVM pipeline to the given pass manager. Transforms main
114 /// dialects into NVVM targets. Begins with GPU code regions, then handles host
115 /// code.
117  const GPUToNVVMPipelineOptions &options);
118 
119 /// Adds the GPU to XeVM pipeline to the given pass manager. Transforms main
120 /// dialects into XeVM targets. Begins with GPU code regions, then handles host
121 /// code.
123  const GPUToXeVMPipelineOptions &options);
124 
125 /// Register all pipelines for the `gpu` dialect.
128 
129 } // namespace gpu
130 } // namespace mlir
131 
132 #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
Subclasses of PassPipelineOptions provide a set of options that can be used to initialize a pass pipe...
Definition: PassOptions.h:380
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 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 > 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
PassOptions::Option< bool > hostBarePtrCallConv
Definition: Passes.h:80
PassOptions::Option< unsigned > optLevel
Definition: Passes.h:99
PassOptions::Option< std::string > xegpuOpLevel
Definition: Passes.h:66
PassOptions::Option< std::string > xevmModuleMatcher
Definition: Passes.h:89
PassOptions::Option< std::string > zebinTriple
Definition: Passes.h:93
PassOptions::Option< bool > kernelBarePtrCallConv
Definition: Passes.h:76
PassOptions::Option< std::string > binaryFormat
Definition: Passes.h:84
PassOptions::Option< std::string > cmdOptions
Definition: Passes.h:103
PassOptions::Option< bool > use64bitIndex
Definition: Passes.h:72
PassOptions::Option< std::string > zebinChip
Definition: Passes.h:96