MLIR  19.0.0git
Utils.h
Go to the documentation of this file.
1 //===- Passes.h - Pass Entrypoints ------------------------------*- 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 //
9 // This header file defines utility functions exposed by the GPU dialect
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_GPU_TRANSFORMS_UTILS_H_
14 #define MLIR_DIALECT_GPU_TRANSFORMS_UTILS_H_
15 
18 #include "mlir/Support/LLVM.h"
19 
20 #include <string>
21 
22 namespace mlir {
23 struct LogicalResult;
24 class Operation;
25 class Value;
26 
27 namespace gpu {
28 class GPUFuncOp;
29 class LaunchOp;
30 
31 /// Returns the default annotation name for GPU binary blobs.
32 std::string getDefaultGpuBinaryAnnotation();
33 
34 /// Returns the matching vector combining kind.
35 vector::CombiningKind convertReductionKind(gpu::AllReduceOperation mode);
36 } // namespace gpu
37 
38 /// Get a gpu.func created from outlining the region of a gpu.launch op with the
39 /// given `kernelFnName`. The region of the `launchOp` can use values from
40 /// above. These need to be captured and passed as arguments to the generated
41 /// gpu.func. The generated function has arguments
42 /// - corresponding to the values passed in as `operands`, in that order.
43 /// - any additional values that might be used within the region of the
44 /// `launchOp` and defined above it. These captured values are appended to the
45 /// `operands` list.
46 gpu::GPUFuncOp outlineKernelFunc(gpu::LaunchOp launchOp, StringRef kernelFnName,
47  SmallVectorImpl<Value> &operands);
48 
49 /// Sink operations into the `launchOp` to reduce the number of values that are
50 /// used within the region of the operation, but defined outside of the
51 /// region.
52 LogicalResult sinkOperationsIntoLaunchOp(
53  gpu::LaunchOp launchOp,
54  llvm::function_ref<bool(Operation *)> isSinkingBeneficiary);
55 
56 } // namespace mlir
57 #endif // MLIR_DIALECT_GPU_TRANSFORMS_UTILS_H_
std::string getDefaultGpuBinaryAnnotation()
Returns the default annotation name for GPU binary blobs.
vector::CombiningKind convertReductionKind(gpu::AllReduceOperation mode)
Returns the matching vector combining kind.
Definition: Utils.cpp:18
Include the generated interface declarations.
LogicalResult sinkOperationsIntoLaunchOp(gpu::LaunchOp launchOp, llvm::function_ref< bool(Operation *)> isSinkingBeneficiary)
Sink operations into the launchOp to reduce the number of values that are used within the region of t...
gpu::GPUFuncOp outlineKernelFunc(gpu::LaunchOp launchOp, StringRef kernelFnName, SmallVectorImpl< Value > &operands)
Get a gpu.func created from outlining the region of a gpu.launch op with the given kernelFnName.