MLIR 23.0.0git
Passes.h
Go to the documentation of this file.
1//===- Passes.h - OpenACC Passes Construction and Registration ------------===//
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//===----------------------------------------------------------------------===//
9#ifndef MLIR_DIALECT_OPENACC_TRANSFORMS_PASSES_H
10#define MLIR_DIALECT_OPENACC_TRANSFORMS_PASSES_H
17#include "llvm/ADT/SetVector.h"
19namespace mlir {
21namespace func {
22class FuncOp;
23} // namespace func
25namespace acc {
26
27class OpenACCSupport;
28
29#define GEN_PASS_DECL
30#include "mlir/Dialect/OpenACC/Transforms/Passes.h.inc"
31
32/// Holds information for which integers represent a device type in the runtime.
33using TypesForDevice = llvm::SmallSetVector<int64_t, 3>;
34
35//===----------------------------------------------------------------------===//
36// ACCSpecializeForDevice patterns
37//===----------------------------------------------------------------------===//
38
39/// Populates all patterns for device specialization.
40/// In specialized device code (such as specialized acc routine), many ACC
41/// operations do not make sense because they are host-side constructs. This
42/// function adds patterns to remove or transform them.
43/// `theDeviceTypes` hold the device types for which `acc_on_device` should
44/// return true.
46 RewritePatternSet &patterns, const TypesForDevice &theDeviceTypes);
47
48//===----------------------------------------------------------------------===//
49// ACCSpecializeForHost patterns
50//===----------------------------------------------------------------------===//
51
52/// Populates patterns for converting orphan ACC operations to host.
53/// All patterns check that the operation is NOT inside or associated with a
54/// compute region before converting.
55/// @param enableLoopConversion Whether to convert orphan acc.loop operations.
57 OpenACCSupport &accSupport,
58 bool enableLoopConversion = true);
59
60/// Populates all patterns for host fallback path (when `if` clause evaluates
61/// to false). In this mode, ALL ACC operations should be converted or removed.
62/// @param enableLoopConversion Whether to convert orphan acc.loop operations.
64 OpenACCSupport &accSupport,
65 bool enableLoopConversion = true);
66
67/// Generate the code for registering conversion passes.
68#define GEN_PASS_REGISTRATION
69#include "mlir/Dialect/OpenACC/Transforms/Passes.h.inc"
70
71} // namespace acc
72} // namespace mlir
73
74#endif // MLIR_DIALECT_OPENACC_TRANSFORMS_PASSES_H
llvm::SmallSetVector< int64_t, 3 > TypesForDevice
Holds information for which integers represent a device type in the runtime.
Definition Passes.h:33
void populateACCOrphanToHostPatterns(RewritePatternSet &patterns, OpenACCSupport &accSupport, bool enableLoopConversion=true)
Populates patterns for converting orphan ACC operations to host.
void populateACCHostFallbackPatterns(RewritePatternSet &patterns, OpenACCSupport &accSupport, bool enableLoopConversion=true)
Populates all patterns for host fallback path (when if clause evaluates to false).
void populateACCSpecializeForDevicePatterns(RewritePatternSet &patterns, const TypesForDevice &theDeviceTypes)
Populates all patterns for device specialization.
Include the generated interface declarations.