MLIR 22.0.0git
GPUToNVVMPipeline.cpp
Go to the documentation of this file.
1//===- GPUToNVVMPipeline.cpp - Test lowering to NVVM as a sink pass -------===//
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// This file implements a pass for testing the lowering to NVVM as a generally
10// usable sink pass.
11//
12//===----------------------------------------------------------------------===//
13
33
34using namespace mlir;
35
36namespace {
37
38//===----------------------------------------------------------------------===//
39// Common pipeline
40//===----------------------------------------------------------------------===//
41void buildCommonPassPipeline(
50
51 GpuNVVMAttachTargetOptions nvvmTargetOptions;
52 nvvmTargetOptions.triple = options.cubinTriple;
53 nvvmTargetOptions.chip = options.cubinChip;
54 nvvmTargetOptions.features = options.cubinFeatures;
55 nvvmTargetOptions.optLevel = options.optLevel;
56 nvvmTargetOptions.cmdOptions = options.cmdOptions;
57 pm.addPass(createGpuNVVMAttachTarget(nvvmTargetOptions));
60 ConvertIndexToLLVMPassOptions convertIndexToLLVMPassOpt;
61 convertIndexToLLVMPassOpt.indexBitwidth = options.indexBitWidth;
62 pm.addPass(createConvertIndexToLLVMPass(convertIndexToLLVMPassOpt));
65}
66
67//===----------------------------------------------------------------------===//
68// GPUModule-specific stuff.
69//===----------------------------------------------------------------------===//
70void buildGpuPassPipeline(OpPassManager &pm,
73 opt.useBarePtrCallConv = options.kernelUseBarePtrCallConv;
74 opt.indexBitwidth = options.indexBitWidth;
75 opt.allowPatternRollback = options.allowPatternRollback;
76 pm.addNestedPass<gpu::GPUModuleOp>(createConvertGpuOpsToNVVMOps(opt));
77 pm.addNestedPass<gpu::GPUModuleOp>(createCanonicalizerPass());
78 pm.addNestedPass<gpu::GPUModuleOp>(createCSEPass());
80}
81
82//===----------------------------------------------------------------------===//
83// Host Post-GPU pipeline
84//===----------------------------------------------------------------------===//
85void buildHostPostPipeline(OpPassManager &pm,
88 opt.hostBarePtrCallConv = options.hostUseBarePtrCallConv;
89 opt.kernelBarePtrCallConv = options.kernelUseBarePtrCallConv;
91
92 GpuModuleToBinaryPassOptions gpuModuleToBinaryPassOptions;
93 gpuModuleToBinaryPassOptions.compilationTarget = options.cubinFormat;
94 pm.addPass(createGpuModuleToBinaryPass(gpuModuleToBinaryPassOptions));
99}
100
101} // namespace
102
105 // Common pipelines
106 buildCommonPassPipeline(pm, options);
107
108 // GPUModule-specific stuff
109 buildGpuPassPipeline(pm, options);
110
111 // Host post-GPUModule-specific stuff
112 buildHostPostPipeline(pm, options);
113}
114
117 "gpu-lower-to-nvvm-pipeline",
118 "The default pipeline lowers main dialects (arith, memref, scf, "
119 "vector, gpu, and nvgpu) to NVVM. It starts by lowering GPU code to the "
120 "specified compilation target (default is fatbin) then lowers the host "
121 "code.",
123}
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 addPass(std::unique_ptr< Pass > pass)
Add the given pass to this pass manager.
Definition Pass.cpp:392
void addNestedPass(std::unique_ptr< Pass > pass)
Add the given pass to a nested pass manager for the given operation kind OpT.
void registerGPUToNVVMPipeline()
Register all pipelines for the gpu dialect.
void buildLowerToNVVMPassPipeline(OpPassManager &pm, const GPUToNVVMPipelineOptions &options)
Adds the GPU to NVVM pipeline to the given pass manager.
std::unique_ptr<::mlir::Pass > createExpandStridedMetadataPass()
Include the generated interface declarations.
std::unique_ptr< Pass > createCSEPass()
Creates a pass to perform common sub expression elimination.
Definition CSE.cpp:412
std::unique_ptr<::mlir::Pass > createSCFToControlFlowPass()
std::unique_ptr<::mlir::Pass > createConvertMathToLLVMPass()
std::unique_ptr<::mlir::Pass > createConvertFuncToLLVMPass()
std::unique_ptr<::mlir::Pass > createConvertIndexToLLVMPass()
std::unique_ptr<::mlir::Pass > createReconcileUnrealizedCastsPass()
std::unique_ptr<::mlir::Pass > createArithToLLVMConversionPass()
std::unique_ptr<::mlir::Pass > createConvertNVGPUToNVVMPass()
std::unique_ptr<::mlir::Pass > createGpuNVVMAttachTarget()
std::unique_ptr<::mlir::Pass > createConvertNVVMToLLVMPass()
std::unique_ptr<::mlir::Pass > createConvertGpuOpsToNVVMOps()
std::unique_ptr<::mlir::Pass > createLowerAffinePass()
std::unique_ptr< Pass > createCanonicalizerPass()
Creates an instance of the Canonicalizer pass, configured with default settings (which can be overrid...
std::unique_ptr<::mlir::Pass > createGpuToLLVMConversionPass()
std::unique_ptr<::mlir::Pass > createGpuModuleToBinaryPass()
std::unique_ptr< Pass > createConvertVectorToSCFPass(const VectorTransferToSCFOptions &options=VectorTransferToSCFOptions())
Create a pass to convert a subset of vector ops to SCF.
std::unique_ptr<::mlir::Pass > createGpuKernelOutliningPass()
PassPipelineRegistration provides a global initializer that registers a Pass pipeline builder routine...
Options for the gpu to nvvm pipeline.
Definition Passes.h:19