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