MLIR 24.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
34
35using namespace mlir;
36
37namespace {
38
39//===----------------------------------------------------------------------===//
40// Common pipeline
41//===----------------------------------------------------------------------===//
42void buildCommonPassPipeline(
51
52 GpuNVVMAttachTargetOptions nvvmTargetOptions;
53 nvvmTargetOptions.triple = options.cubinTriple;
54 nvvmTargetOptions.chip = options.cubinChip;
55 nvvmTargetOptions.features = options.cubinFeatures;
56 nvvmTargetOptions.optLevel = options.optLevel;
57 nvvmTargetOptions.cmdOptions = options.cmdOptions;
58 pm.addPass(createGpuNVVMAttachTarget(nvvmTargetOptions));
61 ConvertIndexToLLVMPassOptions convertIndexToLLVMPassOpt;
62 convertIndexToLLVMPassOpt.indexBitwidth = options.indexBitWidth;
63 pm.addPass(createConvertIndexToLLVMPass(convertIndexToLLVMPassOpt));
66}
67
68//===----------------------------------------------------------------------===//
69// GPUModule-specific stuff.
70//===----------------------------------------------------------------------===//
71void buildGpuPassPipeline(OpPassManager &pm,
74 opt.useBarePtrCallConv = options.kernelUseBarePtrCallConv;
75 opt.indexBitwidth = options.indexBitWidth;
76 opt.allowPatternRollback = options.allowPatternRollback;
77 pm.addNestedPass<gpu::GPUModuleOp>(createConvertGpuOpsToNVVMOps(opt));
78 pm.addNestedPass<gpu::GPUModuleOp>(createCanonicalizerPass());
79 pm.addNestedPass<gpu::GPUModuleOp>(createCSEPass());
81}
82
83//===----------------------------------------------------------------------===//
84// Host Post-GPU pipeline
85//===----------------------------------------------------------------------===//
86void buildHostPostPipeline(OpPassManager &pm,
89 opt.hostBarePtrCallConv = options.hostUseBarePtrCallConv;
90 opt.kernelBarePtrCallConv = options.kernelUseBarePtrCallConv;
92
93 GpuModuleToBinaryPassOptions gpuModuleToBinaryPassOptions;
94 gpuModuleToBinaryPassOptions.compilationTarget = options.cubinFormat;
95 pm.addPass(createGpuModuleToBinaryPass(gpuModuleToBinaryPassOptions));
100}
101
102} // namespace
103
106 // Common pipelines
107 buildCommonPassPipeline(pm, options);
108
109 // GPUModule-specific stuff
110 buildGpuPassPipeline(pm, options);
111
112 // Host post-GPUModule-specific stuff
113 buildHostPostPipeline(pm, options);
114}
115
118 "gpu-lower-to-nvvm-pipeline",
119 "The default pipeline lowers main dialects (arith, memref, scf, "
120 "vector, gpu, and nvgpu) to NVVM. It starts by lowering GPU code to the "
121 "specified compilation target (default is fatbin) then lowers the host "
122 "code.",
124}
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:393
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<::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 > createCanonicalizerPass()
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<::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 > createCSEPass()
Definition CSE.cpp:177
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