1 //===- SCFToGPUPass.h - Pass converting loops to GPU kernels ----*- 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_SCFTOGPU_SCFTOGPUPASS_H_
9 #define MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_
10 
11 #include "mlir/Support/LLVM.h"
12 
13 #include <memory>
14 
15 namespace mlir {
16 class FuncOp;
17 template <typename T>
18 class OperationPass;
19 class Pass;
20 
21 /// Create a pass that converts loop nests into GPU kernels.  It considers
22 /// top-level affine.for operations as roots of loop nests and converts them to
23 /// the gpu.launch operations if possible.
24 ///
25 /// No check on the size of the block or grid, or on the validity of
26 /// parallelization is performed, it is under the responsibility of the caller
27 /// to strip-mine the loops and to perform the dependence analysis before
28 /// calling the conversion.
29 std::unique_ptr<OperationPass<FuncOp>>
30 createAffineForToGPUPass(unsigned numBlockDims, unsigned numThreadDims);
31 std::unique_ptr<OperationPass<FuncOp>> createAffineForToGPUPass();
32 
33 /// Creates a pass that converts scf.parallel operations into a gpu.launch
34 /// operation. The mapping of loop dimensions to launch dimensions is derived
35 /// from mapping attributes. See ParallelToGpuLaunchLowering::matchAndRewrite
36 /// for a description of the used attributes.
37 std::unique_ptr<Pass> createParallelLoopToGpuPass();
38 
39 } // namespace mlir
40 
41 #endif // MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_
42