MLIR  21.0.0git
GPUToROCDLPass.h
Go to the documentation of this file.
1 //===- GPUToROCDLPass.h - Convert GPU kernel to ROCDL dialect ---*- C++ -*-===//
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 #ifndef MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_
9 #define MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_
10 
13 #include <memory>
14 
15 namespace mlir {
16 class LLVMTypeConverter;
17 class ConversionTarget;
18 class RewritePatternSet;
19 
20 template <typename OpT>
21 class OperationPass;
22 
23 namespace amdgpu {
24 struct Chipset;
25 } // namespace amdgpu
26 
27 namespace gpu {
28 class GPUModuleOp;
29 } // namespace gpu
30 
31 #define GEN_PASS_DECL_CONVERTGPUOPSTOROCDLOPS
32 #include "mlir/Conversion/Passes.h.inc"
33 
34 /// Collect a set of patterns to convert from the GPU dialect to ROCDL.
35 /// If `runtime` is Unknown, gpu.printf will not be lowered
36 /// The resulting pattern set should be run over a gpu.module op
37 void populateGpuToROCDLConversionPatterns(const LLVMTypeConverter &converter,
38  RewritePatternSet &patterns,
39  gpu::amd::Runtime runtime,
40  amdgpu::Chipset chipset);
41 
42 /// Configure target to convert from the GPU dialect to ROCDL.
43 void configureGpuToROCDLConversionLegality(ConversionTarget &target);
44 
45 /// Creates a pass that lowers GPU dialect operations to ROCDL counterparts. The
46 /// index bitwidth used for the lowering of the device side index computations
47 /// is configurable.
48 std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
50  const std::string &chipset = "gfx900",
51  unsigned indexBitwidth = kDeriveIndexBitwidthFromDataLayout,
52  bool useBarePtrCallConv = false,
53  gpu::amd::Runtime runtime = gpu::amd::Runtime::Unknown);
54 
55 } // namespace mlir
56 
57 #endif // MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_
Runtime
Potential runtimes for AMD GPU kernels.
Definition: Runtimes.h:15
Include the generated interface declarations.
void populateGpuToROCDLConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, gpu::amd::Runtime runtime, amdgpu::Chipset chipset)
Collect a set of patterns to convert from the GPU dialect to ROCDL.
static constexpr unsigned kDeriveIndexBitwidthFromDataLayout
Value to pass as bitwidth for the index type when the converter is expected to derive the bitwidth fr...
void configureGpuToROCDLConversionLegality(ConversionTarget &target)
Configure target to convert from the GPU dialect to ROCDL.
std::unique_ptr< OperationPass< gpu::GPUModuleOp > > createLowerGpuOpsToROCDLOpsPass(const std::string &chipset="gfx900", unsigned indexBitwidth=kDeriveIndexBitwidthFromDataLayout, bool useBarePtrCallConv=false, gpu::amd::Runtime runtime=gpu::amd::Runtime::Unknown)
Creates a pass that lowers GPU dialect operations to ROCDL counterparts.
const FrozenRewritePatternSet & patterns
Represents the amdgpu gfx chipset version, e.g., gfx90a, gfx942, gfx1103.
Definition: Chipset.h:22