MLIR  16.0.0git
SCFToGPU.h
Go to the documentation of this file.
1 //===- SCFToGPU.h - Convert loop nests 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_SCFTOGPU_H_
9 #define MLIR_CONVERSION_SCFTOGPU_SCFTOGPU_H_
10 
11 #include "mlir/Support/LLVM.h"
12 
13 namespace mlir {
14 class AffineForOp;
15 class ConversionTarget;
16 struct LogicalResult;
17 class MLIRContext;
18 class Value;
19 class Operation;
20 class RewritePatternSet;
21 
22 namespace scf {
23 class ForOp;
24 } // namespace scf
25 
26 /// Convert a perfect affine loop nest with the outermost loop identified by
27 /// `forOp` into a gpu::Launch operation. Map `numBlockDims` outer loops to
28 /// GPU blocks and `numThreadDims` to GPU threads. The bounds of the loops that
29 /// are mapped should be independent of the induction variables of the other
30 /// mapped loops.
31 ///
32 /// No check on the size of the block or grid, or on the validity of
33 /// parallelization is performed, it is under the responsibility of the caller
34 /// to strip-mine the loops and to perform the dependence analysis before
35 /// calling the conversion.
36 
37 // TODO: Consider removing this in favor of affine.for -> affine.parallel
38 // detection followed by an affine.parallel -> scf.parallel -> gpu.launch
39 // conversion
41  unsigned numBlockDims,
42  unsigned numThreadDims);
43 
44 /// Adds the conversion pattern from `scf.parallel` to `gpu.launch` to the
45 /// provided pattern list.
47 
48 /// Configures the rewrite target such that only `scf.parallel` operations that
49 /// are not rewritten by the provided patterns are legal.
51 
52 /// Clean up after applyPartialConversion/applyFullConversion call.
54 
55 } // namespace mlir
56 
57 #endif // MLIR_CONVERSION_SCFTOGPU_SCFTOGPU_H_
Include the generated interface declarations.
Operation is a basic unit of execution within MLIR.
Definition: Operation.h:28
void populateParallelLoopToGPUPatterns(RewritePatternSet &patterns)
Adds the conversion pattern from scf.parallel to gpu.launch to the provided pattern list...
Definition: SCFToGPU.cpp:677
void finalizeParallelLoopToGPUConversion(Operation *op)
Clean up after applyPartialConversion/applyFullConversion call.
Definition: SCFToGPU.cpp:689
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26
LogicalResult convertAffineLoopNestToGPULaunch(AffineForOp forOp, unsigned numBlockDims, unsigned numThreadDims)
Convert a perfect affine loop nest with the outermost loop identified by forOp into a gpu::Launch ope...
Definition: SCFToGPU.cpp:299
void configureParallelLoopToGPULegality(ConversionTarget &target)
Configures the rewrite target such that only scf.parallel operations that are not rewritten by the pr...
Definition: SCFToGPU.cpp:681
This class describes a specific conversion target.