xref: /llvm-project/mlir/include/mlir/Dialect/Async/Transforms.h (revision 8b68da2c7d97ef0e2dde4d9eb867020bde2f5fe2)
1 //===- Transforms.h - Async dialect transformation utilities ----*- 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 transformations on Async operations.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_ASYNC_TRANSFORMS_H_
14 #define MLIR_DIALECT_ASYNC_TRANSFORMS_H_
15 
16 #include "mlir/Dialect/SCF/IR/SCF.h"
17 #include "mlir/IR/ImplicitLocOpBuilder.h"
18 
19 namespace mlir {
20 namespace async {
21 
22 /// Emit the IR to compute the minimum number of iterations of scf.parallel body
23 /// that would be viable for a single parallel task. Allows the user to avoid
24 /// incurring the overheads of spawning costly parallel tasks in absence of
25 /// sufficient amount of parallelizable work.
26 ///
27 /// Must return an index type.
28 using AsyncMinTaskSizeComputationFunction =
29     std::function<Value(ImplicitLocOpBuilder, scf::ParallelOp)>;
30 
31 /// Add a pattern to the given pattern list to lower scf.parallel to async
32 /// operations.
33 void populateAsyncParallelForPatterns(
34     RewritePatternSet &patterns, bool asyncDispatch, int32_t numWorkerThreads,
35     const AsyncMinTaskSizeComputationFunction &computeMinTaskSize);
36 
37 } // namespace async
38 } // namespace mlir
39 
40 #endif // MLIR_DIALECT_ASYNC_TRANSFORMS_H_
41