MLIR 22.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
13namespace mlir {
14class ConversionTarget;
15class MLIRContext;
16class Value;
17class Operation;
19
20namespace affine {
21class AffineForOp;
22} // namespace affine
23
24namespace scf {
25class 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
42LogicalResult 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_
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Include the generated interface declarations.
void finalizeParallelLoopToGPUConversion(Operation *op)
Clean up after applyPartialConversion/applyFullConversion call.
Definition SCFToGPU.cpp:768
void populateParallelLoopToGPUPatterns(RewritePatternSet &patterns)
Adds the conversion pattern from scf.parallel to gpu.launch to the provided pattern list.
Definition SCFToGPU.cpp:756
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...
const FrozenRewritePatternSet & patterns
void configureParallelLoopToGPULegality(ConversionTarget &target)
Configures the rewrite target such that only scf.parallel operations that are not rewritten by the pr...
Definition SCFToGPU.cpp:760