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