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 class MLIRContext;
16 class Value;
17 class Operation;
18 class RewritePatternSet;
19 
20 namespace affine {
21 class AffineForOp;
22 } // namespace affine
23 
24 namespace scf {
25 class ForOp;
26 } // namespace scf
27 
28 /// Convert a perfect affine loop nest with the outermost loop identified by
29 /// `forOp` into a gpu::Launch operation. Map `numBlockDims` outer loops to
30 /// GPU blocks and `numThreadDims` to GPU threads. The bounds of the loops that
31 /// are mapped should be independent of the induction variables of the other
32 /// mapped loops.
33 ///
34 /// No check on the size of the block or grid, or on the validity of
35 /// parallelization is performed, it is under the responsibility of the caller
36 /// to strip-mine the loops and to perform the dependence analysis before
37 /// calling the conversion.
38 
39 // TODO: Consider removing this in favor of affine.for -> affine.parallel
40 // detection followed by an affine.parallel -> scf.parallel -> gpu.launch
41 // conversion
42 LogicalResult convertAffineLoopNestToGPULaunch(affine::AffineForOp forOp,
43  unsigned numBlockDims,
44  unsigned numThreadDims);
45 
46 /// Adds the conversion pattern from `scf.parallel` to `gpu.launch` to the
47 /// provided pattern list.
49 
50 /// Configures the rewrite target such that only `scf.parallel` operations that
51 /// are not rewritten by the provided patterns are legal.
53 
54 /// Clean up after applyPartialConversion/applyFullConversion call.
56 
57 } // namespace mlir
58 
59 #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