MLIR 24.0.0git
ACCDataRuntime.h
Go to the documentation of this file.
1//===- ACCDataRuntime.h - OpenACC data runtime arguments --------*- 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//
9// Arguments and descriptors the OpenACC data runtime entry points are called
10// with. A conversion that lowers its own construct to those entry points emits
11// them with these, rather than restating the argument layout.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef MLIR_CONVERSION_OPENACCTOLLVM_ACCDATARUNTIME_H
16#define MLIR_CONVERSION_OPENACCTOLLVM_ACCDATARUNTIME_H
17
19#include "mlir/IR/Value.h"
20#include "llvm/ADT/SmallVector.h"
21
22#include <cstdint>
23
24namespace mlir {
25class MemRefType;
26class Operation;
27class ConversionPatternRewriter;
28class RewriterBase;
29class Region;
30class SymbolTable;
31
32namespace acc {
33class OpenACCSupport;
34} // namespace acc
35
36/// The arguments every mapping entry point of the OpenACC runtime takes, in the
37/// order they are passed. An entry point that maps `argNum` objects reads one
38/// element from each of the arrays below per object; an entry point may also
39/// take further arguments of its own, which are not part of this set.
41 /// Source position and enclosing function name of the directive.
43 /// Reserved for per-call runtime flags; no flag is defined yet.
45 /// Device type the directive applies to, in the runtime encoding.
47 /// Number of mapped objects, that is, the length of each array below.
49 /// Array of pointer slots to attach a mapped object to, null when the object
50 /// is not attached to anything.
52 /// Array of addresses of the mapped objects themselves.
54 /// Array of object sizes in bytes; zero where the descriptor or the bounds
55 /// state the extent instead.
57 /// Array of map-type flags, in the runtime encoding of `acc::MapFlags`.
59 /// Array of variable names for runtime diagnostics, null where unknown.
61 /// Array of user-defined mappers. OpenACC has none, so this is always null.
63 /// Array of descriptors stating layout and bounds, null for whole objects of
64 /// a known size.
66
67 /// Returns the fields above in the order the entry points take them, so that
68 /// a caller only appends the arguments specific to the one it calls.
70};
71
72/// Identifies how data runtime arguments will be consumed.
77
78/// Materialize \p values as a stack-allocated LLVM array.
79Value createACCDataArray(Location loc, Type elementType, ArrayRef<Value> values,
80 RewriterBase &rewriter);
81
82/// Wrap \p baseDescriptor in the OpenACC overlay that carries \p bounds.
83/// Field zero of \p baseDescriptor is set to \p version with the OpenACC
84/// descriptor bit added.
85Value createACCDataDescriptor(Location loc, Value baseDescriptor,
86 Type baseDescriptorType, uint32_t version,
87 ValueRange bounds, Value elementSize,
88 ConversionPatternRewriter &rewriter);
89
90/// Build the runtime argument descriptor wrapping an already converted memref.
91/// The memref descriptor itself is the one the memref-to-LLVM conversion
92/// produced; this points the runtime at it. When \p bounds is non-empty, the
93/// wrapper is nested in the OpenACC overlay that carries those bounds instead
94/// of being stored on its own.
95Value createACCMemRefDescriptorWrapperArg(Location loc, MemRefType memrefType,
96 Value convertedMemref,
97 ValueRange bounds, Value elementSize,
98 ConversionPatternRewriter &rewriter);
99
100/// Build the runtime argument descriptor for \p mapOp, or a null pointer when
101/// the mapping needs no descriptor.
102Value createACCArgumentDescriptor(Operation *mapOp, Value convertedOperand,
103 acc::OpenACCSupport &accSupport,
104 ConversionPatternRewriter &rewriter);
105
106/// Emit the OpenACC data runtime arguments for data-clause operands. The
107/// operands may be `acc.map_info` or the data-clause operations it replaces.
108/// The emitted arrays name globals after the mapped objects and the position
109/// of the directive; they are created in \p globalSymbolRegion, with \p
110/// symbolTable as in acc::getOrCreateGlobalString.
111LogicalResult emitACCDataRuntimeArgs(
112 Location loc, ValueRange mappingOperands, ValueRange convertedOperands,
113 ConversionPatternRewriter &rewriter, Region &globalSymbolRegion,
114 acc::OpenACCSupport &accSupport, const acc::ACCRuntimeCallConfig &config,
115 ACCDataRuntimeArgs &runtimeArgs,
117 SymbolTable *symbolTable = nullptr);
118
119} // namespace mlir
120
121#endif // MLIR_CONVERSION_OPENACCTOLLVM_ACCDATARUNTIME_H
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Definition SymbolTable.h:24
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.
Value createACCDataArray(Location loc, Type elementType, ArrayRef< Value > values, RewriterBase &rewriter)
Materialize values as a stack-allocated LLVM array.
Value createACCDataDescriptor(Location loc, Value baseDescriptor, Type baseDescriptorType, uint32_t version, ValueRange bounds, Value elementSize, ConversionPatternRewriter &rewriter)
Wrap baseDescriptor in the OpenACC overlay that carries bounds.
ACCDataCallKind
Identifies how data runtime arguments will be consumed.
Value createACCArgumentDescriptor(Operation *mapOp, Value convertedOperand, acc::OpenACCSupport &accSupport, ConversionPatternRewriter &rewriter)
Build the runtime argument descriptor for mapOp, or a null pointer when the mapping needs no descript...
LogicalResult emitACCDataRuntimeArgs(Location loc, ValueRange mappingOperands, ValueRange convertedOperands, ConversionPatternRewriter &rewriter, Region &globalSymbolRegion, acc::OpenACCSupport &accSupport, const acc::ACCRuntimeCallConfig &config, ACCDataRuntimeArgs &runtimeArgs, ACCDataCallKind callKind=ACCDataCallKind::DataEnter, SymbolTable *symbolTable=nullptr)
Emit the OpenACC data runtime arguments for data-clause operands.
Value createACCMemRefDescriptorWrapperArg(Location loc, MemRefType memrefType, Value convertedMemref, ValueRange bounds, Value elementSize, ConversionPatternRewriter &rewriter)
Build the runtime argument descriptor wrapping an already converted memref.
The arguments every mapping entry point of the OpenACC runtime takes, in the order they are passed.
Value argNames
Array of variable names for runtime diagnostics, null where unknown.
Value deviceType
Device type the directive applies to, in the runtime encoding.
Value argSizes
Array of object sizes in bytes; zero where the descriptor or the bounds state the extent instead.
Value argMappers
Array of user-defined mappers. OpenACC has none, so this is always null.
Value ident
Source position and enclosing function name of the directive.
Value argTypes
Array of map-type flags, in the runtime encoding of acc::MapFlags.
SmallVector< Value > getCallArgs() const
Returns the fields above in the order the entry points take them, so that a caller only appends the a...
Value argBasePtrs
Array of pointer slots to attach a mapped object to, null when the object is not attached to anything...
Value argNum
Number of mapped objects, that is, the length of each array below.
Value argDescs
Array of descriptors stating layout and bounds, null for whole objects of a known size.
Value flags
Reserved for per-call runtime flags; no flag is defined yet.
Value argPtrs
Array of addresses of the mapped objects themselves.