13#ifndef MLIR_DIALECT_OPENACC_OPENACC_H_
14#define MLIR_DIALECT_OPENACC_OPENACC_H_
24#include "mlir/Dialect/OpenACC/OpenACCOpsDialect.h.inc"
25#include "mlir/Dialect/OpenACC/OpenACCOpsEnums.h.inc"
27#include "mlir/Dialect/OpenACC/OpenACCTypeInterfaces.h.inc"
31#include "llvm/ADT/SmallVector.h"
34#define GET_TYPEDEF_CLASSES
35#include "mlir/Dialect/OpenACC/OpenACCOpsTypes.h.inc"
37#define GET_ATTRDEF_CLASSES
38#include "mlir/Dialect/OpenACC/OpenACCOpsAttributes.h.inc"
43#include "mlir/Dialect/OpenACC/OpenACCOps.h.inc"
45#define ACC_DATA_ENTRY_OPS \
46 mlir::acc::CopyinOp, mlir::acc::CreateOp, mlir::acc::PresentOp, \
47 mlir::acc::NoCreateOp, mlir::acc::AttachOp, mlir::acc::DevicePtrOp, \
48 mlir::acc::GetDevicePtrOp, mlir::acc::PrivateOp, \
49 mlir::acc::FirstprivateOp, mlir::acc::FirstprivateMapInitialOp, \
50 mlir::acc::UpdateDeviceOp, mlir::acc::UseDeviceOp, \
51 mlir::acc::ReductionOp, mlir::acc::DeclareDeviceResidentOp, \
52 mlir::acc::DeclareLinkOp, mlir::acc::CacheOp
53#define ACC_DATA_ENTRY_AND_INIT_OPS \
54 ACC_DATA_ENTRY_OPS, mlir::acc::ReductionInitOp
55#define ACC_DATA_EXIT_OPS \
56 mlir::acc::CopyoutOp, mlir::acc::DeleteOp, mlir::acc::DetachOp, \
57 mlir::acc::UpdateHostOp
58#define ACC_DATA_CLAUSE_OPS ACC_DATA_ENTRY_OPS, ACC_DATA_EXIT_OPS
59#define ACC_COMPUTE_CONSTRUCT_OPS \
60 mlir::acc::ParallelOp, mlir::acc::KernelsOp, mlir::acc::SerialOp
61#define ACC_COMPUTE_CONSTRUCT_AND_LOOP_OPS \
62 ACC_COMPUTE_CONSTRUCT_OPS, mlir::acc::LoopOp
63#define ACC_DATA_CONSTRUCT_STRUCTURED_OPS \
64 mlir::acc::DataOp, mlir::acc::DeclareOp, mlir::acc::HostDataOp
65#define ACC_DATA_CONSTRUCT_UNSTRUCTURED_OPS \
66 mlir::acc::EnterDataOp, mlir::acc::ExitDataOp, mlir::acc::UpdateOp, \
67 mlir::acc::DeclareEnterOp, mlir::acc::DeclareExitOp
68#define ACC_DATA_CONSTRUCT_OPS \
69 ACC_DATA_CONSTRUCT_STRUCTURED_OPS, ACC_DATA_CONSTRUCT_UNSTRUCTURED_OPS
70#define ACC_COMPUTE_AND_DATA_CONSTRUCT_OPS \
71 ACC_COMPUTE_CONSTRUCT_OPS, ACC_DATA_CONSTRUCT_OPS
72#define ACC_COMPUTE_LOOP_AND_DATA_CONSTRUCT_OPS \
73 ACC_COMPUTE_CONSTRUCT_AND_LOOP_OPS, ACC_DATA_CONSTRUCT_OPS
152std::optional<mlir::acc::DataClause>
180 return mlir::isa<mlir::acc::PointerLikeType>(type);
186 return mlir::isa<mlir::acc::MappableType>(type);
191 return StringLiteral(
"acc.declare");
195 return StringLiteral(
"acc.declare_action");
199 return RoutineInfoAttr::name;
203 return SpecializedRoutineAttr::name;
223 return StringLiteral(
"acc.offload_entry");
227 return StringLiteral(
"acc.from_default");
234 return StringLiteral(
"acc.no_device_descriptor");
240 return StringLiteral(
"acc.collapse_count");
247 return StringLiteral(
"acc.unstructured_independent_loop");
251 return VarNameAttr::name;
255 return CombinedConstructsTypeAttr::name;
260 mlir::StringRef
getName() const final {
return "AccRuntimeCounters"; }
266 mlir::StringRef
getName() const final {
return "AccConstructResource"; }
272 mlir::StringRef
getName() const final {
return "AccCurrentDeviceIdResource"; }
276template <
typename ComputeOpT>
279 auto stripIndexCasts = [](
Value val) ->
Value {
280 while (
auto castOp = val.getDefiningOp<arith::IndexCastOp>())
281 val = castOp.getIn();
285 auto numGangs = op.getNumGangsValues();
286 if (numGangs.empty())
288 for (
Value gangSize : numGangs) {
292 Value numWorkers = op.getNumWorkersValue();
295 Value vectorLength = op.getVectorLengthValue();
This class provides a mutable adaptor for a range of operands.
Operation is the basic unit of execution within MLIR.
bool hasDiscardableAttr(StringRef name)
Return true if this operation has a discardable attribute with the provided name.
This base class is used for derived effects that are non-parametric.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
static constexpr StringLiteral getNoDeviceDescriptorAttrName()
Name for a unit attribute on a data entry operation stating that nothing in the region reads the desc...
SmallVector< DeviceType, 3 > getDeviceTypesByPrecedence(DeviceType deviceType)
The clauses of a construct can be given once per device type.
bool getSyntheticFlag(mlir::Operation *accDataClauseOp)
Used to find out whether the implementation created the data operation for its own bookkeeping,...
static constexpr StringLiteral getFromDefaultClauseAttrName()
mlir::Value getAccVar(mlir::Operation *accDataClauseOp)
Used to obtain the accVar from a data clause operation.
mlir::Value getVar(mlir::Operation *accDataClauseOp)
Used to obtain the var from a data clause operation.
bool isAccRoutine(mlir::Operation *op)
Used to check whether the current operation is marked with acc routine.
mlir::TypedValue< mlir::acc::PointerLikeType > getAccPtr(mlir::Operation *accDataClauseOp)
Used to obtain the accVar from a data clause operation if it implements PointerLikeType.
static constexpr StringLiteral getSpecializedRoutineAttrName()
std::optional< mlir::acc::DataClause > getDataClause(mlir::Operation *accDataEntryOp)
Used to obtain the dataClause from a data entry operation.
bool isPointerLikeType(mlir::Type type)
Used to check whether the provided type implements the PointerLikeType interface.
mlir::MutableOperandRange getMutableDataOperands(mlir::Operation *accOp)
Used to get a mutable range iterating over the data operands.
mlir::SmallVector< mlir::Value > getBounds(mlir::Operation *accDataClauseOp)
Used to obtain bounds from an acc data clause operation.
bool isDataEntryOp(mlir::Operation *op)
Used to find out whether op is a data entry operation or an acc.map_info.
OpenACCExecMapping
Enumeration used to encode the execution mapping on a loop construct.
bool isSpecializedAccRoutine(mlir::Operation *op)
Used to check whether this is a specialized accelerator version of acc routine function.
static constexpr StringLiteral getUnstructuredIndependentLoopAttrName()
Name for a unit attribute attached to the region an unstructured independent loop was converted to,...
mlir::ValueRange getDataOperands(mlir::Operation *accOp)
Used to get an immutable range iterating over the data operands.
std::optional< llvm::StringRef > getVarName(mlir::Operation *accOp)
Used to obtain the name from an acc operation.
static constexpr StringLiteral getRoutineInfoAttrName()
bool isGangWorkerVectorAllOne(ComputeOpT op)
bool getImplicitFlag(mlir::Operation *accDataEntryOp)
Used to find out whether data operation is implicit.
mlir::SymbolRefAttr getRecipe(mlir::Operation *accOp)
Used to get the recipe attribute from a data clause operation.
mlir::SmallVector< mlir::Value > getAsyncOperands(mlir::Operation *accDataClauseOp)
Used to obtain async operands from an acc data clause operation.
bool isMappableType(mlir::Type type)
Used to check whether the provided type implements the MappableType interface.
static constexpr StringLiteral getCombinedConstructsAttrName()
mlir::Value getVarPtrPtr(mlir::Operation *accDataClauseOp)
Used to obtain the varPtrPtr from a data clause operation.
static constexpr StringLiteral getVarNameAttrName()
static constexpr StringLiteral getOffloadEntryAttrName()
Attribute on global symbols that are associated with device-side symbols of the same name.
mlir::ArrayAttr getAsyncOnly(mlir::Operation *accDataClauseOp)
Returns an array of acc:DeviceTypeAttr attributes attached to an acc data clause operation,...
static constexpr StringLiteral getDeclareAttrName()
Used to obtain the attribute name for declare.
static constexpr StringLiteral getDeclareActionAttrName()
mlir::Type getVarType(mlir::Operation *accDataClauseOp)
Used to obtains the varType from a data clause operation which records the type of variable.
static constexpr StringLiteral getCollapseCountAttrName()
Name for an attribute attached to a loop indicating the number of loops collapsed to create that loop...
mlir::TypedValue< mlir::acc::PointerLikeType > getVarPtr(mlir::Operation *accDataClauseOp)
Used to obtain the var from a data clause operation if it implements PointerLikeType.
mlir::ArrayAttr getAsyncOperandsDeviceType(mlir::Operation *accDataClauseOp)
Returns an array of acc:DeviceTypeAttr attributes attached to an acc data clause operation,...
Include the generated interface declarations.
bool isConstantIntValue(OpFoldResult ofr, int64_t value)
Return true if ofr is constant integer equal to value.
std::conditional_t< std::is_same_v< Ty, mlir::Type >, mlir::Value, detail::TypedValue< Ty > > TypedValue
If Ty is mlir::Type this will select Value instead of having a wrapper around it.
mlir::StringRef getName() const final
Return a string name of the resource.
bool isAddressable() const override
Returns true if this resource is addressable (effects on it can alias pointer-based memory).
bool isAddressable() const override
Returns true if this resource is addressable (effects on it can alias pointer-based memory).
mlir::StringRef getName() const final
Return a string name of the resource.
mlir::StringRef getName() const final
Return a string name of the resource.
bool isAddressable() const override
Returns true if this resource is addressable (effects on it can alias pointer-based memory).