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