MLIR

Multi-Level IR Compiler Framework

'acc' Dialect

The acc dialect is an MLIR dialect for representing the OpenACC programming model. OpenACC is a standardized directive-based model which is used with C, C++, and Fortran to enable programmers to expose parallelism in their code. The descriptive approach used by OpenACC allows targeting of parallel multicore and accelerator targets like GPUs by giving the compiler the freedom of how to parallelize for specific architectures. OpenACC also provides the ability to optimize the parallelism through increasingly more prescriptive clauses.

This dialect models the constructs from the OpenACC 3.3 specification

This document describes the design of the OpenACC dialect in MLIR. It lists and explains design goals and design choices along with their rationale. It also describes specifics with regards to acc dialect operations, types, and attributes.

Dialect Design Goals 

  • Needs to have complete representation of the OpenACC language.
    • A frontend requires this in order to properly generate a representation of possible acc pragmas in MLIR. Additionally, this dialect is expected to be further lowered when materializing its semantics. Without a complete representation, a frontend might choose a lower abstraction (such as direct runtime call) - but this would impact the ability to do analysis and optimizations on the dialect.
  • Allow representation at the same semantic level as the OpenACC language while having capability to represent nuances of the source language semantics (such as Fortran descriptors) in an agnostic manner.
    • Using abstractions that closely model the OpenACC language simplifies frontend implementation. It also allows for easier debugging of the IR. However, sometimes source language specific behavior is needed when materializing OpenACC. In these cases, such as privatization of C++ objects with default constructor, the frontend fills in the recipe along with the private operation which can be packaged neatly with the acc dialect operations.
  • Be able to regenerate the semantic equivalent of the user pragmas from the dialect (including bounds, names, clauses, modifiers, etc).
    • This is a strong measure of making sure that the dialect is not lossy in semantics. It also allows capability to generate appropriate and useful debug information outside of the frontend.
  • Be dialect agnostic so that it can be used and coexist with other dialects including but not limited to hlfir, fir, llvm, cir.
    • Directive-based models such as OpenACC are always used with a source language, so the acc dialect coexisting with other dialect(s) is necessary by construction. Through proper abstractions, neither the acc dialect nor the source language dialect should have dependencies on each other; where needed, interfaces should be used to ensure acc dialect can verify expected properties.
  • The dialect must allow dataflow to be modeled accurately and performantly using MLIR’s existing facilities.
    • Appropriate dataflow modeling is important for analyses and IR reasoning - even something as simple as walking the uses. Therefore operations, like data operations, are expected to generate results which can be used in modeling behavior. For example, consider an acc copyin clause. After the acc.copyin operation, a pointer which lives on devices should be distinguishable from one that lives in host memory.
  • Be friendly to MLIR optimization passes by implementing common interfaces.
    • Interfaces, such as MemoryEffects, are the key way MLIR transformations and analyses are designed to interact with the IR. In order for the operations in the acc dialect to be optimizable (either directly or even indirectly by not blocking optimizations of nested IR), implementing relevant common interfaces is needed.

The design philosophy of the acc dialect is one where the design goals are adhered to. Current and planned operations, attributes, types must adhere to the design goals.

Operation Categories 

The OpenACC dialect includes both high-level operations (which retain the same semantic meaning as their OpenACC language equivalent), intermediate-level operations (which are used to decompose clauses from constructs), and low-level operations (to encode specifics associated with source language in a generic way).

The high-level operations list contains the following OpenACC language constructs and their corresponding operations:

  • acc parallelacc.parallel
  • acc kernelsacc.kernels
  • acc serialacc.serial
  • acc dataacc.data
  • acc loopacc.loop
  • acc enter dataacc.enter_data
  • acc exit dataacc.exit_data
  • acc host_dataacc.host_data
  • acc initacc.init
  • acc shutdownacc.shutdown
  • acc updateacc.update
  • acc setacc.set
  • acc waitacc.wait
  • acc atomic readacc.atomic.read
  • acc atomic writeacc.atomic.write
  • acc atomic updateacc.atomic.update
  • acc atomic captureacc.atomic.capture

This second group contains operations which are used to represent either decomposed constructs or clauses for more accurate modeling:

  • acc routineacc.routine + acc.routine_info attribute
  • acc declareacc.declare_enter + acc.declare_exit or acc.declare
  • acc {construct} copyinacc.copyin (before region) + acc.delete (after region)
  • acc {construct} copyacc.copyin (before region) + acc.copyout (after region)
  • acc {construct} copyoutacc.create (before region) + acc.copyout (after region)
  • acc {construct} attachacc.attach (before region) + acc.detach (after region)
  • acc {construct} createacc.create (before region) + acc.delete (after region)
  • acc {construct} presentacc.present (before region) + acc.delete (after region)
  • acc {construct} no_createacc.nocreate (before region) + acc.delete (after region)
  • acc {construct} deviceptracc.deviceptr
  • acc {construct} privateacc.private
  • acc {construct} firstprivateacc.firstprivate
  • acc {construct} reductionacc.reduction
  • acc cacheacc.cache
  • acc update deviceacc.update_device
  • acc update hostacc.update_host
  • acc host_data use_deviceacc.use_device
  • acc declare device_residentacc.declare_device_resident
  • acc declare linkacc.declare_link
  • acc exit data deleteacc.delete (with structured flag as false)
  • acc exit data detachacc.detach (with structured flag as false)
  • acc {construct} {data_clause}(var[lb:ub])acc.bounds

The low-level operations are:

  • acc.private.recipe
  • acc.reduction.recipe
  • acc.firstprivate.recipe
  • acc.global_ctor
  • acc.global_dtor
  • acc.yield
  • acc.terminator The low-level operations semantics and reasoning are further explained in sections below.

Data Operations 

Data Clause Decomposition 

The data clauses are decomposed from their constructs for better dataflow modeling in MLIR. There are multiple reasons for this which are consistent with the dialect goals:

  • Correctly represents dataflow. Data clauses have different effects at entry to region and at exit from region.
  • Friendlier to add attributes such as MemoryEffects to a single operation. This can better reflect semantics (like the fact that an acc.copyin operation only reads host memory)
  • Operations can be moved or optimized individually (eg CSE).
  • Easier to keep track of debug information. Line location can point to the text representing the data clause instead of the construct. Additionally, attributes can be used to keep track of variable names in clauses without having to walk the IR tree in attempt to recover the information (this makes acc dialect more agnostic with regards to what other dialect it is used with).
  • Clear operation ordering since all data operations are on same list.

Each of the acc dialect data operations represents either the entry or the exit portion of the data action specification. Thus, acc.copyin represents the semantics defined in section 2.7.7 copyin clause whose wording starts with At entry to a region. The decomposed exit operation acc.delete represents the second part of that section, whose wording starts with At exit from the region. The delete action may be performed after checking and updating of the relevant reference counters noted.

The acc data operations, even when decomposed, retain their original data clause in an operation operand dataClause for possibility to recover this information during debugging. For example, acc copy, does not translate to acc.copy operation, but instead to acc.copyin for entry and acc.copyout for exit. Both the decomposed operations hold a dataClause field that specifies this was an acc copy.

The link between the decomposed entry and exit operations is the ssa value produced by the entry operation. Namely, it is the accPtr result which is used both in the dataOperands of the operation used for the construct and in the accPtr operand of the exit operation.

Bounds 

OpenACC data clauses allow the use of bounds specifiers as per 2.7.1 Data Specification in Data Clauses. However, array dimensions for the data are not always required in the clause if the source language’s type system captures this information - the user can just specify the variable name in the data clause. So the acc.bounds operation is an important piece to ensure uniform representation of both explicit user set dimensions and implicit type-based dimensions. It contains several key features to allow properly encoding sizes in a manner flexible and agnostic to the source language’s dialect:

  • Multi-dimensional arrays can be represented by using multiple ordered acc.bounds operations.
  • Bounds are required to be zero-normalized. This works well with the PointerLikeType requirement in data clauses - since a lowerbound of 0 means looking at data at the zero offset from pointer. This requirement also works well in ensuring the acc dialect is agnostic to source language dialect since it prevents ambiguity such as the case of Fortran arrays where the lower bound is not a fixed value.
  • If the source dialect does not encode the dimensions in the type (eg !fir.array<?x?xi32>) but instead encodes it in some other way (such as through descriptors), then the frontend must fill in the acc.bounds operands with appropriate information (such as loads from descriptor). The acc.bounds operation also permits lossy source dialect, such as if the frontend uses aggressive pointer decay and cannot represent the dimensions in the type system (eg using !llvm.ptr for arrays). Both of these aspects show acc.bounds’ operation’s flexibility to allow the representation to be agnostic since the acc dialect is not expected to be able to understand how to extract dimension information from the types of the source dialect.
  • The OpenACC specification allows either extent or upperbound in the data clause depending on whether it is Fortran or C and C++. The acc.bounds operation is rich enough to accept either or both - for convenience in lowering to the dialect and for ability to precisely capture the meaning from the clause.
  • The stride, either in units or bytes, can be also captured in the acc.bounds operation. This is also an important part to be able to accept a source language’s arrays without forcing the frontend to normalize them in some way. For example, consider a case where in a parent function, a whole array is mapped to device. Then only a view of a non-1 stride is passed to child function (eg Fortran array slice with non-1 stride). A copy operation of this data in child should be able to avoid remapping this array. If instead the operation required normalizing the array (such as making it contiguous), then unexpected disjoint mapping of the same host data would be error-prone since it would result in multiple mappings to device.

Counters 

The data operations also maintain semantics described in the OpenACC specification related to runtime counters. More specifically, consider the specification of the entry portion of acc copyin in section 2.7.7:

At entry to a region, the structured reference counter is used. On an
enter data directive, the dynamic reference counter is used.
- If var is present and is not a null pointer, a present increment
action with the appropriate reference counter is performed.
- If var is not present, a copyin action with the appropriate reference
counter is performed.
- If var is a pointer reference, an attach action is performed.

The acc.copyin operation includes these semantics, including those related to attach, which is specified through the varPtrPtr operand. The structured flag on the operation is important since the structured reference counter should be used when the flag is true; and the dynamic reference counter should be used when it is false.

At exit from structured regions (acc data, acc kernels), the acc copyin operation is decomposed to acc.delete (with the structured flag as true). The semantics of the acc.delete are also consistent with the OpenACC specification noted for the exit portion of the acc copyin clause:

At exit from the region:
- If the structured reference counter for var is zero, no action is
taken.
- Otherwise, a detach action is performed if var is a pointer reference,
and a present decrement action with the structured reference counter is
performed if var is not a null pointer. If both structured and dynamic
reference counters are zero, a delete action is performed.

Types 

There are a few acc dialect type categories to describe:

  • type of acc data clause operation input varPtr
    • The type of varPtr must be pointer-like. This is done by attaching the PointerLikeType interface to the appropriate MLIR type. Although memory/storage concept is a lower level abstraction, it is useful because the OpenACC model distinguishes between host and device memory explicitly - and the mapping between the two is done through pointers. Thus, by explicitly requiring it in the dialect, the appropriate language frontend must create storage or use type that satisfies the mapping constraint.
  • type of result of acc data clause operations
    • The type of the acc data clause operation is exactly the same as varPtr. This was done intentionally instead of introducing an acc.ref/ptr type so that IR compatibility and the dialect’s existing strong type checking can be maintained. This is needed since the acc dialect must live within another dialect whose type system is unknown to it. The only constraint is that the appropriate dialect type must use the PointerLikeType interface.
  • type of decomposed clauses
    • Decomposed clauses, such as acc.bounds and acc.declare_enter produce types to allow their results to be used only in specific operations.

Recipes 

Recipes are a generic way to express source language specific semantics.

There are currently two categories of recipes, but the recipe concept can be extended for any additional low-level information that needs to be captured for successful lowering of OpenACC. The two categories are:

  • recipes used in the context of privatization associated with a construct
  • recipes used in the context of additional specification of data semantics

The intention of the recipes is to specify how materialization of action, such as privatization, should be done when the semantics of the action needs interpreted and lowered, such as before generating LLVM dialect.

The recipes used for privatization provide a source-language independent way of specifying the creation of a local variable of that type. This means using the appropriate alloca instruction and being able to specify default initialization or default constructor.

Routine 

The routine directive is used to note that a procedure should be made available for the accelerator in a way that is consistent with its modifiers, such as those that describe the parallelism. In the acc dialect, an acc routine is represented through two joint pieces - an attribute and an operation:

  • The acc.routine operation is simply a specifier which notes which symbol (or string) the acc routine is needed for, along with parallelism associated. This defines a symbol that can be referenced in attribute.
  • The acc.routine_info attribute is an attribute used on the source dialect specific operation which specifies one or multiple acc.routine symbols. Typically, this is attached to func.func which either provides the declaration (in case of externals) or provides the actual body of the acc routine in the dialect that the source language was translated to.

Declare 

OpenACC declare is a mechanism which declares a definition of a global or a local to be accessible to accelerator with an implicit lifetime as that of the scope where it was declared in. Thus, declare semantics are represented through multiple operations and attributes:

  • acc.declare - This is a structured operation which contains an MLIR region and can be used in similar manner as acc.data to specify an implicit data region with specific procedure lifetime. This is typically used inside func.func after variable declarations.
  • acc.declare_enter - This is an unstructured operation which is used as a decomposed form of acc declare. It effectively allows the entry operation to exist in a scope different than the exit operation. It can also be used along acc.declare_exit which consumes its token to define a scoped region without using MLIR region. This operation is also used in acc.global_ctor.
  • acc.declare_exit - The matching equivalent of acc.declare_enter except that it specifies exit semantics. This operation is typically used inside a func.func at the exit points or with acc.global_dtor.
  • acc.global_ctor - Lives at the same level as source dialect globals and is used to specify data actions to be done at program entry. This is used in conjunction with source dialect globals whose lifetime is not just a single procedure.
  • acc.global_dtor - Defines the exit data actions that should be done at program exit. Typically used to revert the actions of acc.global_ctor.

The attributes:

  • acc.declare - This is a facility for easier determination of variables which are acc declare’d. This attribute is used on operations producing globals and on operations producing locals such as dialect specific alloca’s. Having this attribute is required in order to appear in a data mapping operation associated with any of the acc.declare* operations.
  • acc.declare_action - Since the OpenACC specification allows declaration of variables that have yet to be allocated, this attribute is used at the allocation and deallocation points. More specifically, this attribute captures symbols of functions to be called to perform an action either pre-allocate, post-allocate, pre-deallocate, or post-deallocate. Calls to these functions should be materialized when lowering OpenACC semantics to ensure proper data actions are done after the allocation/deallocation.

OpenACC Transforms and Analyses 

The design goal for the acc dialect is to be friendly to MLIR optimization passes including CSE and LICM. Additionally, since it is designed to recover original clauses, it makes late verification and analysis possible in the MLIR framework outside of the frontend.

This section describes a few MLIR-level passes for which the acc dialect design should be friendly for. This section is currently solely outlining the possibilities intended by the design and not necessarily existing passes.

Verification 

Since the OpenACC dialect is not lossy with regards to its representation, it is possible to do OpenACC language semantic checking at the MLIR-level. What follows is a list of various semantic checks needed.

This first list is required to be done in the frontend because the acc dialect operations must be valid when constructed:

  • Ensure that only listed clauses are allowed for each directive.
  • Ensure that only listed modifiers are allowed for each clause.

However, the following are semantic checks that can be done at the MLIR-level (either in a separate pass or as part of the operation verifier):

  • Specify the validity checks that each modifier needs. (eg num_gangs may need a positive integer).
  • Ensure valid clause nesting.
  • Validate clause restrictions which cannot appear with others.
  • Validate that no conflicting clauses are used on variables.

Note that some of these checks can be even more precise when done at the MLIR level because optimizations like inlining and constant propagation expose detail that wouldn’t have been visible in the frontend.

Implicit Data Attributes 

The OpenACC specification includes a section on 2.6.2 Variables with Implicitly Determined Data Attributes. What this section describes are the data actions that should be applied to a variable for which user did not specify a data action for. The action depends on the construct being used and also on the default clause. However, the point to note here is that variables which are live-in into the acc region must employ some data mapping so the data can be passed to accelerator.

One possible optimizations that affects data attributes needed is Scalar Replacement of Aggregates (SROA). The acc dialect should not prevent this from happening on the source dialect.

Because it is intended to be possible to apply optimizations across an acc region, the analysis/transformation pass that applies the implicit data attributes should be run as late as possible - ideally right before any outlining process which uses the acc region body to create an accelerator procedure. It is expected that existing MLIR facilities, such as mlir::Liveness will work for the acc region and thus can be used to perform this analysis.

Redundant Clause Elimination 

The data operations are modeled in a way where data entry operations look like loads and data exit operations look like stores. Thus these operations are intended to be optimized in the following ways:

  • Be able to eliminate redundant operations such as when an acc.copyin dominates another.
  • Be able to hoist/sink such operations out of loops.

Operations TOC 

Operations 

source

acc.atomic.capture (acc::AtomicCaptureOp) 

Performs an atomic capture

Syntax:

operation ::= `acc.atomic.capture` $region attr-dict

This operation performs an atomic capture.

The region has the following allowed forms:

  acc.atomic.capture {
    acc.atomic.update ...
    acc.atomic.read ...
    acc.terminator
  }

  acc.atomic.capture {
    acc.atomic.read ...
    acc.atomic.update ...
    acc.terminator
  }

  acc.atomic.capture {
    acc.atomic.read ...
    acc.atomic.write ...
    acc.terminator
  }

Traits: RecursiveMemoryEffects, SingleBlockImplicitTerminator<TerminatorOp>, SingleBlock

Interfaces: AtomicCaptureOpInterface

acc.atomic.read (acc::AtomicReadOp) 

Performs an atomic read

Syntax:

operation ::= `acc.atomic.read` $v `=` $x
              `:` type($v) `,` type($x) `,` $element_type attr-dict

This operation performs an atomic read.

The operand x is the address from where the value is atomically read. The operand v is the address where the value is stored after reading.

Interfaces: AtomicReadOpInterface

Attributes: 

AttributeMLIR TypeDescription
element_type::mlir::TypeAttrany type attribute

Operands: 

OperandDescription
xpointer-like type
vpointer-like type

acc.atomic.update (acc::AtomicUpdateOp) 

Performs an atomic update

Syntax:

operation ::= `acc.atomic.update` $x `:` type($x) $region attr-dict

This operation performs an atomic update.

The operand x is exactly the same as the operand x in the OpenACC Standard (OpenACC 3.3, section 2.12). It is the address of the variable that is being updated. x is atomically read/written.

The region describes how to update the value of x. It takes the value at x as an input and must yield the updated value. Only the update to x is atomic. Generally the region must have only one instruction, but can potentially have more than one instructions too. The update is sematically similar to a compare-exchange loop based atomic update.

The syntax of atomic update operation is different from atomic read and atomic write operations. This is because only the host dialect knows how to appropriately update a value. For example, while generating LLVM IR, if there are no special atomicrmw instructions for the operation-type combination in atomic update, a compare-exchange loop is generated, where the core update operation is directly translated like regular operations by the host dialect. The front-end must handle semantic checks for allowed operations.

Traits: RecursiveMemoryEffects, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: AtomicUpdateOpInterface

Operands: 

OperandDescription
xpointer-like type

acc.atomic.write (acc::AtomicWriteOp) 

Performs an atomic write

Syntax:

operation ::= `acc.atomic.write` $x `=` $expr
              `:` type($x) `,` type($expr)
              attr-dict

This operation performs an atomic write.

The operand x is the address to where the expr is atomically written w.r.t. multiple threads. The evaluation of expr need not be atomic w.r.t. the write to address. In general, the type(x) must dereference to type(expr).

Interfaces: AtomicWriteOpInterface

Operands: 

OperandDescription
xpointer-like type
exprany type

acc.attach (acc::AttachOp) 

Represents acc attach semantics which updates a pointer in device memory with the corresponding device address of the pointee.

Syntax:

operation ::= `acc.attach` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.bounds (acc::DataBoundsOp) 

Represents normalized bounds information for acc data clause.

Syntax:

operation ::= `acc.bounds` oilist(
              `lowerbound` `(` $lowerbound `:` type($lowerbound) `)`
              | `upperbound` `(` $upperbound `:` type($upperbound) `)`
              | `extent` `(` $extent `:` type($extent) `)`
              | `stride` `(` $stride `:` type($stride) `)`
              | `startIdx` `(` $startIdx `:` type($startIdx) `)`
              ) attr-dict

This operation is used to record bounds used in acc data clause in a normalized fashion (zero-based). This works well with the PointerLikeType requirement in data clauses - since a lowerbound of 0 means looking at data at the zero offset from pointer.

The operation must have an upperbound or extent (or both are allowed - but not checked for consistency). When the source language’s arrays are not zero-based, the startIdx must specify the zero-position index.

Examples below show copying a slice of 10-element array except first element. Note that the examples use extent in data clause for C++ and upperbound for Fortran (as per 2.7.1). To simplify examples, the constants are used directly in the acc.bounds operands - this is not the syntax of operation.

C++:

int array[10];
#pragma acc copy(array[1:9])

=>

acc.bounds lb(1) ub(9) extent(9) startIdx(0)

Fortran:

integer :: array(1:10)
!$acc copy(array(2:10))

=>

acc.bounds lb(1) ub(9) extent(9) startIdx(1)

Traits: AttrSizedOperandSegments

Interfaces: NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
strideInBytes::mlir::BoolAttrbool attribute

Operands: 

OperandDescription
lowerboundinteger or index
upperboundinteger or index
extentinteger or index
strideinteger or index
startIdxinteger or index

Results: 

ResultDescription
resultType for representing acc data clause bounds information

acc.cache (acc::CacheOp) 

Represents the cache directive that is associated with a loop.

Syntax:

operation ::= `acc.cache` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface), NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.copyin (acc::CopyinOp) 

Represents copyin semantics for acc data clauses like acc copyin and acc copy.

Syntax:

operation ::= `acc.copyin` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.copyout (acc::CopyoutOp) 

Represents acc copyout semantics - reverse of copyin.

Syntax:

operation ::= `acc.copyout` `accPtr` `(` $accPtr `:` type($accPtr) `)`
              (`bounds` `(` $bounds^ `)` )?
              (`async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
              `to` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              attr-dict
  • varPtr: The address of variable to copy back to.

    • accPtr: The acc address of variable. This is the link from the data-entry operation used.
    • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
    • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
    • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
    • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
    • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
    • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
    • name: Holds the name of variable as specified in user clause (including bounds).

    The async values attached to the data exit operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
accPtrPointerLikeType instance
varPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

acc.create (acc::CreateOp) 

Represents create semantics for acc data clauses like acc create and acc copyout.

Syntax:

operation ::= `acc.create` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.data (acc::DataOp) 

Data construct

Syntax:

operation ::= `acc.data` oilist(
              `if` `(` $ifCond `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              | `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              | `wait` `` custom<WaitClause>($waitOperands, type($waitOperands),
              $waitOperandsDeviceType, $waitOperandsSegments, $hasWaitDevnum,
              $waitOnly)
              )
              $region attr-dict-with-keyword

The “acc.data” operation represents a data construct. It defines vars to be allocated in the current device memory for the duration of the region, whether data should be copied from local memory to the current device memory upon region entry , and copied from device memory to local memory upon region exit.

Example:

acc.data present(%a: memref<10x10xf32>, %b: memref<10x10xf32>,
    %c: memref<10xf32>, %d: memref<10xf32>) {
  // data region
}

async and wait operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: AttrSizedOperandSegments, RecursiveMemoryEffects

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
waitOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
waitOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
hasWaitDevnum::mlir::ArrayAttr1-bit boolean array attribute
waitOnly::mlir::ArrayAttrdevice type array attribute
defaultAttr::mlir::acc::ClauseDefaultValueAttr
DefaultValue Clause

Enum cases:

  • present (Present)
  • none (None)

Operands: 

OperandDescription
ifCond1-bit signless integer
asyncOperandsvariadic of integer or index
waitOperandsvariadic of integer or index
dataClauseOperandsvariadic of PointerLikeType instance

acc.declare (acc::DeclareOp) 

Declare implicit region

Syntax:

operation ::= `acc.declare` `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              $region attr-dict-with-keyword

The “acc.declare” operation represents an implicit declare region in function (and subroutine in Fortran).

Example:

%pa = acc.present varPtr(%a : memref<10x10xf32>) -> memref<10x10xf32>
acc.declare dataOperands(%pa: memref<10x10xf32>) {
  // implicit region
}

Traits: RecursiveMemoryEffects

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource}

Operands: 

OperandDescription
dataClauseOperandsvariadic of PointerLikeType instance

acc.declare_device_resident (acc::DeclareDeviceResidentOp) 

Represents acc declare device_resident semantics.

Syntax:

operation ::= `acc.declare_device_resident` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.declare_enter (acc::DeclareEnterOp) 

Declare directive - entry to implicit data region

Syntax:

operation ::= `acc.declare_enter` oilist(
              `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              )
              attr-dict-with-keyword

The “acc.declare_enter” operation represents the OpenACC declare directive and captures the entry semantics to the implicit data region. This operation is modeled similarly to “acc.enter_data”.

Example showing acc declare create(a):

%0 = acc.create varPtr(%a : !llvm.ptr) -> !llvm.ptr
acc.declare_enter dataOperands(%0 : !llvm.ptr)

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Operands: 

OperandDescription
dataClauseOperandsvariadic of PointerLikeType instance

Results: 

ResultDescription
tokendeclare token type

acc.declare_exit (acc::DeclareExitOp) 

Declare directive - exit from implicit data region

Syntax:

operation ::= `acc.declare_exit` oilist(
              `token` `(` $token `)` |
              `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              )
              attr-dict-with-keyword

The “acc.declare_exit” operation represents the OpenACC declare directive and captures the exit semantics from the implicit data region. This operation is modeled similarly to “acc.exit_data”.

Example showing acc declare device_resident(a):

%0 = acc.getdeviceptr varPtr(%a : !llvm.ptr) -> !llvm.ptr {dataClause = #acc<data_clause declare_device_resident>}
acc.declare_exit dataOperands(%0 : !llvm.ptr)
acc.delete accPtr(%0 : !llvm.ptr) {dataClause = #acc<data_clause declare_device_resident>}

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Operands: 

OperandDescription
tokendeclare token type
dataClauseOperandsvariadic of PointerLikeType instance

Represents acc declare link semantics.

Syntax:

operation ::= `acc.declare_link` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.delete (acc::DeleteOp) 

Represents acc delete semantics - reverse of create.

Syntax:

operation ::= `acc.delete` `accPtr` `(` $accPtr `:` type($accPtr) `)`
              (`bounds` `(` $bounds^ `)` )?
              (`async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
              attr-dict
  • accPtr: The acc address of variable. This is the link from the data-entry operation used.
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data exit operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
accPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

acc.detach (acc::DetachOp) 

Represents acc detach semantics - reverse of attach.

Syntax:

operation ::= `acc.detach` `accPtr` `(` $accPtr `:` type($accPtr) `)`
              (`bounds` `(` $bounds^ `)` )?
              (`async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
              attr-dict
  • accPtr: The acc address of variable. This is the link from the data-entry operation used.
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data exit operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
accPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

acc.deviceptr (acc::DevicePtrOp) 

Specifies that the variable pointer is a device pointer.

Syntax:

operation ::= `acc.deviceptr` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.enter_data (acc::EnterDataOp) 

Enter data operation

Syntax:

operation ::= `acc.enter_data` oilist(
              `if` `(` $ifCond `)`
              | `async` `(` $asyncOperand `:` type($asyncOperand) `)`
              | `wait_devnum` `(` $waitDevnum `:` type($waitDevnum) `)`
              | `wait` `(` $waitOperands `:` type($waitOperands) `)`
              | `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              )
              attr-dict-with-keyword

The “acc.enter_data” operation represents the OpenACC enter data directive.

Example:

acc.enter_data create(%d1 : memref<10xf32>) attributes {async}

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
async::mlir::UnitAttrunit attribute
wait::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
ifCond1-bit signless integer
asyncOperandinteger or index
waitDevnuminteger or index
waitOperandsvariadic of integer or index
dataClauseOperandsvariadic of PointerLikeType instance

acc.exit_data (acc::ExitDataOp) 

Exit data operation

Syntax:

operation ::= `acc.exit_data` oilist(
              `if` `(` $ifCond `)`
              | `async` `(` $asyncOperand `:` type($asyncOperand) `)`
              | `wait_devnum` `(` $waitDevnum `:` type($waitDevnum) `)`
              | `wait` `(` $waitOperands `:` type($waitOperands) `)`
              | `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              )
              attr-dict-with-keyword

The “acc.exit_data” operation represents the OpenACC exit data directive.

Example:

acc.exit_data delete(%d1 : memref<10xf32>) attributes {async}

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
async::mlir::UnitAttrunit attribute
wait::mlir::UnitAttrunit attribute
finalize::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
ifCond1-bit signless integer
asyncOperandinteger or index
waitDevnuminteger or index
waitOperandsvariadic of integer or index
dataClauseOperandsvariadic of PointerLikeType instance

acc.firstprivate (acc::FirstprivateOp) 

Represents firstprivate semantic for the acc firstprivate clause.

Syntax:

operation ::= `acc.firstprivate` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.firstprivate.recipe (acc::FirstprivateRecipeOp) 

Privatization recipe

Syntax:

operation ::= `acc.firstprivate.recipe` $sym_name `:` $type attr-dict-with-keyword `init` $initRegion
              `copy` $copyRegion
              (`destroy` $destroyRegion^)?

Declares an OpenACC privatization recipe with copy of the initial value. The operation requires two mandatory regions and one optional.

  1. The initializer region specifies how to allocate and initialize a new private value. For example in Fortran, a derived-type might have a default initialization. The region has an argument that contains the value that need to be privatized. This is useful if the type is not known at compile time and the private value is needed to create its copy.
  2. The copy region specifies how to copy the initial value to the newly created private value. It takes the initial value and the privatized value as arguments.
  3. The destroy region specifies how to destruct the value when it reaches its end of life. It takes the privatized value as argument. It is optional.

A single privatization recipe can be used for multiple operand if they have the same type and do not require a specific default initialization.

Example:

acc.firstprivate.recipe @privatization_f32 : f32 init {
^bb0(%0: f32):
  // init region contains a sequence of operations to create and
  // initialize the copy if needed. It yields the create copy.
} copy {
^bb0(%0: f32, %1: !llvm.ptr):
  // copy region contains a sequence of operations to copy the initial value
  // of the firstprivate value to the newly created value.
} destroy {
^bb0(%0: f32)
  // destroy region contains a sequences of operations to destruct the
  // created copy.
}

// The privatization symbol is then used in the corresponding operation.
acc.parallel firstprivate(@privatization_f32 -> %a : f32) {
}

Traits: IsolatedFromAbove

Interfaces: RecipeInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
type::mlir::TypeAttrany type attribute

acc.getdeviceptr (acc::GetDevicePtrOp) 

Gets device address if variable exists on device.

Syntax:

operation ::= `acc.getdeviceptr` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

This operation is used to get the accPtr for a variable. This is often used in conjunction with data exit operations when the data entry operation is not visible. This operation can have a dataClause argument that is any of the valid mlir::acc::DataClause entries. \

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.global_ctor (acc::GlobalConstructorOp) 

Used to hold construction operations associated with globals such as declare

Syntax:

operation ::= `acc.global_ctor` $sym_name $region attr-dict-with-keyword

The “acc.global_ctor” operation is used to capture OpenACC actions to apply on globals (such as acc declare) at the entry to the implicit data region. This operation is isolated and intended to be used in a module.

Example showing declare create of global:

llvm.mlir.global external @globalvar() : i32 {
  %0 = llvm.mlir.constant(0 : i32) : i32
  llvm.return %0 : i32
}
acc.global_ctor @acc_constructor {
  %0 = llvm.mlir.addressof @globalvar : !llvm.ptr
  %1 = acc.create varPtr(%0 : !llvm.ptr) -> !llvm.ptr
  acc.declare_enter dataOperands(%1 : !llvm.ptr)
}

Traits: IsolatedFromAbove

Interfaces: Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute

acc.global_dtor (acc::GlobalDestructorOp) 

Used to hold destruction operations associated with globals such as declare

Syntax:

operation ::= `acc.global_dtor` $sym_name $region attr-dict-with-keyword

The “acc.global_dtor” operation is used to capture OpenACC actions to apply on globals (such as acc declare) at the exit from the implicit data region. This operation is isolated and intended to be used in a module.

Example showing delete associated with declare create of global:

llvm.mlir.global external @globalvar() : i32 {
  %0 = llvm.mlir.constant(0 : i32) : i32
  llvm.return %0 : i32
}
acc.global_dtor @acc_destructor {
  %0 = llvm.mlir.addressof @globalvar : !llvm.ptr
  %1 = acc.getdeviceptr varPtr(%0 : !llvm.ptr) -> !llvm.ptr {dataClause = #acc<data_clause create>}
  acc.declare_exit dataOperands(%1 : !llvm.ptr)
  acc.delete accPtr(%1 : !llvm.ptr) {dataClause = #acc<data_clause create>}
}

Traits: IsolatedFromAbove

Interfaces: Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute

acc.host_data (acc::HostDataOp) 

Host_data construct

Syntax:

operation ::= `acc.host_data` oilist(
              `if` `(` $ifCond `)`
              | `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              )
              $region attr-dict-with-keyword

The “acc.host_data” operation represents the OpenACC host_data construct.

Example:

%0 = acc.use_device varPtr(%a : !llvm.ptr) -> !llvm.ptr
acc.host_data dataOperands(%0 : !llvm.ptr) {

}

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
ifPresent::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
ifCond1-bit signless integer
dataClauseOperandsvariadic of PointerLikeType instance

acc.init (acc::InitOp) 

Init operation

Syntax:

operation ::= `acc.init` oilist(`device_num` `(` $deviceNumOperand `:` type($deviceNumOperand) `)`
              | `if` `(` $ifCond `)`
              ) attr-dict-with-keyword

The “acc.init” operation represents the OpenACC init executable directive.

Example:

acc.init
acc.init device_num(%dev1 : i32)

Traits: AttrSizedOperandSegments

Attributes: 

AttributeMLIR TypeDescription
device_types::mlir::ArrayAttrDevice type attributes

Operands: 

OperandDescription
deviceNumOperandinteger or index
ifCond1-bit signless integer

acc.kernels (acc::KernelsOp) 

Kernels construct

Syntax:

operation ::= `acc.kernels` ( `combined` `(` `loop` `)` $combined^)?
              oilist(
              `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              | `num_gangs` `(` custom<NumGangs>($numGangs,
              type($numGangs), $numGangsDeviceType, $numGangsSegments) `)`
              | `num_workers` `(` custom<DeviceTypeOperands>($numWorkers,
              type($numWorkers), $numWorkersDeviceType) `)`
              | `vector_length` `(` custom<DeviceTypeOperands>($vectorLength,
              type($vectorLength), $vectorLengthDeviceType) `)`
              | `wait` `` custom<WaitClause>($waitOperands, type($waitOperands),
              $waitOperandsDeviceType, $waitOperandsSegments, $hasWaitDevnum,
              $waitOnly)
              | `self` `(` $selfCond `)`
              | `if` `(` $ifCond `)`
              )
              $region attr-dict-with-keyword

The “acc.kernels” operation represents a kernels construct block. It has one region to be compiled into a sequence of kernels for execution on the current device.

Example:

acc.kernels num_gangs(%c10) num_workers(%c10)
    private(%c : memref<10xf32>) {
  // kernels region
}

collapse, gang, worker, vector, seq, independent, auto and tile operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: AttrSizedOperandSegments, AutomaticAllocationScope, RecursiveMemoryEffects

Interfaces: ComputeRegionOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
waitOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
waitOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
hasWaitDevnum::mlir::ArrayAttr1-bit boolean array attribute
waitOnly::mlir::ArrayAttrdevice type array attribute
numGangsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
numGangsDeviceType::mlir::ArrayAttrdevice type array attribute
numWorkersDeviceType::mlir::ArrayAttrdevice type array attribute
vectorLengthDeviceType::mlir::ArrayAttrdevice type array attribute
selfAttr::mlir::UnitAttrunit attribute
defaultAttr::mlir::acc::ClauseDefaultValueAttr
DefaultValue Clause

Enum cases:

  • present (Present)
  • none (None)
combined::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
asyncOperandsvariadic of integer or index
waitOperandsvariadic of integer or index
numGangsvariadic of integer or index
numWorkersvariadic of integer or index
vectorLengthvariadic of integer or index
ifCond1-bit signless integer
selfCond1-bit signless integer
dataClauseOperandsvariadic of PointerLikeType instance

acc.loop (acc::LoopOp) 

Loop construct

Syntax:

operation ::= `acc.loop` custom<CombinedConstructsLoop>($combined)
              oilist(
              `gang` `` custom<GangClause>($gangOperands, type($gangOperands),
              $gangOperandsArgType, $gangOperandsDeviceType,
              $gangOperandsSegments, $gang)
              | `worker` `` custom<DeviceTypeOperandsWithKeywordOnly>(
              $workerNumOperands, type($workerNumOperands),
              $workerNumOperandsDeviceType, $worker)
              | `vector` `` custom<DeviceTypeOperandsWithKeywordOnly>($vectorOperands,
              type($vectorOperands), $vectorOperandsDeviceType, $vector)
              | `private` `(` custom<SymOperandList>(
              $privateOperands, type($privateOperands), $privatizations) `)`
              | `tile` `(` custom<DeviceTypeOperandsWithSegment>($tileOperands,
              type($tileOperands), $tileOperandsDeviceType, $tileOperandsSegments)
              `)`
              | `reduction` `(` custom<SymOperandList>(
              $reductionOperands, type($reductionOperands), $reductionRecipes)
              `)`
              | `cache` `(` $cacheOperands `:` type($cacheOperands) `)`
              )
              custom<LoopControl>($region, $lowerbound, type($lowerbound), $upperbound,
              type($upperbound), $step, type($step))
              ( `(` type($results)^ `)` )?
              attr-dict-with-keyword

The “acc.loop” operation represents the OpenACC loop construct. The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound. If the inclusive attribute is set then the upper bound is included.

Example:

acc.loop gang() vector() (%arg3 : index, %arg4 : index, %arg5 : index) = 
    (%c0, %c0, %c0 : index, index, index) to 
    (%c10, %c10, %c10 : index, index, index) step 
    (%c1, %c1, %c1 : index, index, index) {
  // Loop body
  acc.yield
} attributes { collapse = [3] }

collapse, gang, worker, vector, seq, independent, auto and tile operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: AttrSizedOperandSegments, AutomaticAllocationScope, RecursiveMemoryEffects

Interfaces: ComputeRegionOpInterface, LoopLikeOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource}

Attributes: 

AttributeMLIR TypeDescription
inclusiveUpperbound::mlir::DenseBoolArrayAttri1 dense array attribute
collapse::mlir::ArrayAttr64-bit integer array attribute
collapseDeviceType::mlir::ArrayAttrdevice type array attribute
gangOperandsArgType::mlir::ArrayAttrgang arg type array attribute
gangOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
gangOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
workerNumOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
vectorOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
seq::mlir::ArrayAttrdevice type array attribute
independent::mlir::ArrayAttrdevice type array attribute
auto_::mlir::ArrayAttrdevice type array attribute
gang::mlir::ArrayAttrdevice type array attribute
worker::mlir::ArrayAttrdevice type array attribute
vector::mlir::ArrayAttrdevice type array attribute
tileOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
tileOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
privatizations::mlir::ArrayAttrsymbol ref array attribute
reductionRecipes::mlir::ArrayAttrsymbol ref array attribute
combined::mlir::acc::CombinedConstructsTypeAttr
Differentiate between combined constructs

Enum cases:

  • kernels_loop (KernelsLoop)
  • parallel_loop (ParallelLoop)
  • serial_loop (SerialLoop)

Operands: 

OperandDescription
lowerboundvariadic of integer or index
upperboundvariadic of integer or index
stepvariadic of integer or index
gangOperandsvariadic of integer or index
workerNumOperandsvariadic of integer or index
vectorOperandsvariadic of integer or index
tileOperandsvariadic of integer or index
cacheOperandsvariadic of PointerLikeType instance
privateOperandsvariadic of PointerLikeType instance
reductionOperandsvariadic of any type

Results: 

ResultDescription
resultsvariadic of any type

acc.nocreate (acc::NoCreateOp) 

Represents acc no_create semantics.

Syntax:

operation ::= `acc.nocreate` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.parallel (acc::ParallelOp) 

Parallel construct

Syntax:

operation ::= `acc.parallel` ( `combined` `(` `loop` `)` $combined^)?
              oilist(
              `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              | `firstprivate` `(` custom<SymOperandList>($firstprivateOperands,
              type($firstprivateOperands), $firstprivatizations)
              `)`
              | `num_gangs` `(` custom<NumGangs>($numGangs,
              type($numGangs), $numGangsDeviceType, $numGangsSegments) `)`
              | `num_workers` `(` custom<DeviceTypeOperands>($numWorkers,
              type($numWorkers), $numWorkersDeviceType) `)`
              | `private` `(` custom<SymOperandList>(
              $privateOperands, type($privateOperands), $privatizations)
              `)`
              | `vector_length` `(` custom<DeviceTypeOperands>($vectorLength,
              type($vectorLength), $vectorLengthDeviceType) `)`
              | `wait` `` custom<WaitClause>($waitOperands, type($waitOperands),
              $waitOperandsDeviceType, $waitOperandsSegments, $hasWaitDevnum,
              $waitOnly)
              | `self` `(` $selfCond `)`
              | `if` `(` $ifCond `)`
              | `reduction` `(` custom<SymOperandList>(
              $reductionOperands, type($reductionOperands), $reductionRecipes)
              `)`
              )
              $region attr-dict-with-keyword

The “acc.parallel” operation represents a parallel construct block. It has one region to be executed in parallel on the current device.

Example:

acc.parallel num_gangs(%c10) num_workers(%c10)
    private(%c : memref<10xf32>) {
  // parallel region
}

async, wait, num_gangs, num_workers and vector_length operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: AttrSizedOperandSegments, AutomaticAllocationScope, RecursiveMemoryEffects

Interfaces: ComputeRegionOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
waitOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
waitOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
hasWaitDevnum::mlir::ArrayAttr1-bit boolean array attribute
waitOnly::mlir::ArrayAttrdevice type array attribute
numGangsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
numGangsDeviceType::mlir::ArrayAttrdevice type array attribute
numWorkersDeviceType::mlir::ArrayAttrdevice type array attribute
vectorLengthDeviceType::mlir::ArrayAttrdevice type array attribute
selfAttr::mlir::UnitAttrunit attribute
reductionRecipes::mlir::ArrayAttrsymbol ref array attribute
privatizations::mlir::ArrayAttrsymbol ref array attribute
firstprivatizations::mlir::ArrayAttrsymbol ref array attribute
defaultAttr::mlir::acc::ClauseDefaultValueAttr
DefaultValue Clause

Enum cases:

  • present (Present)
  • none (None)
combined::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
asyncOperandsvariadic of integer or index
waitOperandsvariadic of integer or index
numGangsvariadic of integer or index
numWorkersvariadic of integer or index
vectorLengthvariadic of integer or index
ifCond1-bit signless integer
selfCond1-bit signless integer
reductionOperandsvariadic of any type
privateOperandsvariadic of PointerLikeType instance
firstprivateOperandsvariadic of PointerLikeType instance
dataClauseOperandsvariadic of PointerLikeType instance

acc.present (acc::PresentOp) 

Specifies that the variable is already present on device.

Syntax:

operation ::= `acc.present` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.private (acc::PrivateOp) 

Represents private semantics for acc private clause.

Syntax:

operation ::= `acc.private` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.private.recipe (acc::PrivateRecipeOp) 

Privatization recipe

Syntax:

operation ::= `acc.private.recipe` $sym_name `:` $type attr-dict-with-keyword `init` $initRegion
              (`destroy` $destroyRegion^)?

Declares an OpenACC privatization recipe. The operation requires one mandatory and one optional region.

  1. The initializer region specifies how to allocate and initialize a new private value. For example in Fortran, a derived-type might have a default initialization. The region has an argument that contains the value that need to be privatized. This is useful if the type is not known at compile time and the private value is needed to create its copy.
  2. The destroy region specifies how to destruct the value when it reaches its end of life. It takes the privatized value as argument.

A single privatization recipe can be used for multiple operand if they have the same type and do not require a specific default initialization.

Example:

acc.private.recipe @privatization_f32 : f32 init {
^bb0(%0: f32):
  // init region contains a sequence of operations to create and
  // initialize the copy if needed. It yields the create copy.
} destroy {
^bb0(%0: f32)
  // destroy region contains a sequences of operations to destruct the
  // created copy.
}

// The privatization symbol is then used in the corresponding operation.
acc.parallel private(@privatization_f32 -> %a : f32) {
}

Traits: IsolatedFromAbove

Interfaces: RecipeInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
type::mlir::TypeAttrany type attribute

acc.reduction (acc::ReductionOp) 

Represents reduction semantics for acc reduction clause.

Syntax:

operation ::= `acc.reduction` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.reduction.recipe (acc::ReductionRecipeOp) 

Reduction recipe

Syntax:

operation ::= `acc.reduction.recipe` $sym_name `:` $type attr-dict-with-keyword
              `reduction_operator` $reductionOperator
              `init` $initRegion `combiner` $combinerRegion

Declares an OpenACC reduction recipe. The operation requires two mandatory regions.

  1. The initializer region specifies how to initialize the local reduction value. The region has a first argument that contains the value of the reduction accumulator at the start of the reduction. It is expected to acc.yield the new value. Extra arguments can be added to deal with dynamic arrays.
  2. The reduction region contains a sequences of operations to combine two values of the reduction type into one. It has at least two arguments and it is expected to acc.yield the combined value. Extra arguments can be added to deal with dynamic arrays.

Example:

acc.reduction.recipe @reduction_add_i64 : i64 reduction_operator<add> init {
^bb0(%0: i64):
  // init region contains a sequence of operations to initialize the local
  // reduction value as specified in 2.5.15
  %c0 = arith.constant 0 : i64
  acc.yield %c0 : i64
} combiner {
^bb0(%0: i64, %1: i64)
  // combiner region contains a sequence of operations to combine
  // two values into one.
  %2 = arith.addi %0, %1 : i64
  acc.yield %2 : i64
}

// The reduction symbol is then used in the corresponding operation.
acc.parallel reduction(@reduction_add_i64 -> %a : i64) {
}

The following table lists the valid operators and the initialization values according to OpenACC 3.3:

|————————————————|

C/C++Fortran
operatorinit value
+0
*1
maxleast
minlargest
&~0
^0
&&1
————————————————-

Traits: IsolatedFromAbove

Interfaces: RecipeInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
type::mlir::TypeAttrany type attribute
reductionOperator::mlir::acc::ReductionOperatorAttr
built-in reduction operations supported by OpenACC

Enum cases:

  • add (AccAdd)
  • mul (AccMul)
  • max (AccMax)
  • min (AccMin)
  • iand (AccIand)
  • ior (AccIor)
  • xor (AccXor)
  • eqv (AccEqv)
  • neqv (AccNeqv)
  • land (AccLand)
  • lor (AccLor)

acc.routine (acc::RoutineOp) 

Acc routine operation

Syntax:

operation ::= `acc.routine` $sym_name `func` `(` $func_name `)`
              oilist (
              `bind` `(` custom<BindName>($bindName, $bindNameDeviceType) `)`
              | `gang` `` custom<RoutineGangClause>($gang, $gangDim, $gangDimDeviceType)
              | `worker` custom<DeviceTypeArrayAttr>($worker)
              | `vector` custom<DeviceTypeArrayAttr>($vector)
              | `seq` custom<DeviceTypeArrayAttr>($seq)
              | `nohost` $nohost
              | `implicit` $implicit
              ) attr-dict-with-keyword

The acc.routine operation is used to capture the clauses of acc routine directive, including the associated function name. The associated function keeps track of its corresponding routine declaration through the RoutineInfoAttr.

Example:

func.func @acc_func(%a : i64) -> () attributes 
    {acc.routine_info = #acc.routine_info<[@acc_func_rout1]>} {
  return
}
acc.routine @acc_func_rout1 func(@acc_func) gang

bind, gang, worker, vector and seq operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: IsolatedFromAbove

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
func_name::mlir::StringAttrstring attribute
bindName::mlir::ArrayAttrstring array attribute
bindNameDeviceType::mlir::ArrayAttrdevice type array attribute
worker::mlir::ArrayAttrdevice type array attribute
vector::mlir::ArrayAttrdevice type array attribute
seq::mlir::ArrayAttrdevice type array attribute
nohost::mlir::UnitAttrunit attribute
implicit::mlir::UnitAttrunit attribute
gang::mlir::ArrayAttrdevice type array attribute
gangDim::mlir::ArrayAttr64-bit integer array attribute
gangDimDeviceType::mlir::ArrayAttrdevice type array attribute

acc.serial (acc::SerialOp) 

Serial construct

Syntax:

operation ::= `acc.serial` ( `combined` `(` `loop` `)` $combined^)?
              oilist(
              `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              | `firstprivate` `(` custom<SymOperandList>($firstprivateOperands,
              type($firstprivateOperands), $firstprivatizations)
              `)`
              | `private` `(` custom<SymOperandList>(
              $privateOperands, type($privateOperands), $privatizations)
              `)`
              | `wait` `` custom<WaitClause>($waitOperands, type($waitOperands),
              $waitOperandsDeviceType, $waitOperandsSegments, $hasWaitDevnum,
              $waitOnly)
              | `self` `(` $selfCond `)`
              | `if` `(` $ifCond `)`
              | `reduction` `(` custom<SymOperandList>(
              $reductionOperands, type($reductionOperands), $reductionRecipes)
              `)`
              )
              $region attr-dict-with-keyword

The “acc.serial” operation represents a serial construct block. It has one region to be executed in serial on the current device.

Example:

acc.serial private(%c : memref<10xf32>) {
  // serial region
}

async and wait operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: AttrSizedOperandSegments, AutomaticAllocationScope, RecursiveMemoryEffects

Interfaces: ComputeRegionOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
waitOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
waitOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
hasWaitDevnum::mlir::ArrayAttr1-bit boolean array attribute
waitOnly::mlir::ArrayAttrdevice type array attribute
selfAttr::mlir::UnitAttrunit attribute
reductionRecipes::mlir::ArrayAttrsymbol ref array attribute
privatizations::mlir::ArrayAttrsymbol ref array attribute
firstprivatizations::mlir::ArrayAttrsymbol ref array attribute
defaultAttr::mlir::acc::ClauseDefaultValueAttr
DefaultValue Clause

Enum cases:

  • present (Present)
  • none (None)
combined::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
asyncOperandsvariadic of integer or index
waitOperandsvariadic of integer or index
ifCond1-bit signless integer
selfCond1-bit signless integer
reductionOperandsvariadic of any type
privateOperandsvariadic of PointerLikeType instance
firstprivateOperandsvariadic of PointerLikeType instance
dataClauseOperandsvariadic of PointerLikeType instance

acc.set (acc::SetOp) 

Set operation

Syntax:

operation ::= `acc.set` oilist(`default_async` `(` $defaultAsync `:` type($defaultAsync) `)`
              | `device_num` `(` $deviceNum `:` type($deviceNum) `)`
              | `if` `(` $ifCond `)`
              ) attr-dict-with-keyword

The “acc.set” operation represents the OpenACC set directive.

Example:

acc.set device_num(%dev1 : i32)

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
device_type::mlir::acc::DeviceTypeAttr
built-in device type supported by OpenACC

Enum cases:

  • none (None)
  • star (Star)
  • default (Default)
  • host (Host)
  • multicore (Multicore)
  • nvidia (Nvidia)
  • radeon (Radeon)

Operands: 

OperandDescription
defaultAsyncinteger or index
deviceNuminteger or index
ifCond1-bit signless integer

acc.shutdown (acc::ShutdownOp) 

Shutdown operation

Syntax:

operation ::= `acc.shutdown` oilist(`device_num` `(` $deviceNumOperand `:` type($deviceNumOperand) `)`
              |`if` `(` $ifCond `)`
              ) attr-dict-with-keyword

The “acc.shutdown” operation represents the OpenACC shutdown executable directive.

Example:

acc.shutdown
acc.shutdown device_num(%dev1 : i32)

Traits: AttrSizedOperandSegments

Attributes: 

AttributeMLIR TypeDescription
device_types::mlir::ArrayAttrDevice type attributes

Operands: 

OperandDescription
deviceNumOperandinteger or index
ifCond1-bit signless integer

acc.terminator (acc::TerminatorOp) 

Generic terminator for OpenACC regions

Syntax:

operation ::= `acc.terminator` attr-dict

A terminator operation for regions that appear in the body of OpenACC operation. Generic OpenACC construct regions are not expected to return any value so the terminator takes no operands. The terminator op returns control to the enclosing op.

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

acc.update (acc::UpdateOp) 

Update operation

Syntax:

operation ::= `acc.update` oilist(
              `if` `(` $ifCond `)`
              | `async` `` custom<DeviceTypeOperandsWithKeywordOnly>(
              $asyncOperands, type($asyncOperands),
              $asyncOperandsDeviceType, $async)
              | `wait` `` custom<WaitClause>($waitOperands, type($waitOperands),
              $waitOperandsDeviceType, $waitOperandsSegments, $hasWaitDevnum,
              $waitOnly)
              | `dataOperands` `(` $dataClauseOperands `:` type($dataClauseOperands) `)`
              )
              attr-dict-with-keyword

The acc.update operation represents the OpenACC update executable directive. As host and self clauses are synonyms, any operands for host and self are add to $hostOperands.

Example:

acc.update device(%d1 : memref<10xf32>) attributes {async}

async and wait operands are supported with device_type information. They should only be accessed by the extra provided getters. If modified, the corresponding device_type attributes must be modified as well.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::acc::ConstructResource, MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
async::mlir::ArrayAttrdevice type array attribute
waitOperandsSegments::mlir::DenseI32ArrayAttri32 dense array attribute
waitOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
hasWaitDevnum::mlir::ArrayAttr1-bit boolean array attribute
waitOnly::mlir::ArrayAttrdevice type array attribute
ifPresent::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
ifCond1-bit signless integer
asyncOperandsvariadic of integer or index
waitOperandsvariadic of integer or index
dataClauseOperandsvariadic of PointerLikeType instance

acc.update_device (acc::UpdateDeviceOp) 

Represents acc update device semantics.

Syntax:

operation ::= `acc.update_device` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.update_host (acc::UpdateHostOp) 

Represents acc update host semantics.

Syntax:

operation ::= `acc.update_host` `accPtr` `(` $accPtr `:` type($accPtr) `)`
              (`bounds` `(` $bounds^ `)` )?
              (`async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
              `to` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              attr-dict
  • varPtr: The address of variable to copy back to.

    • accPtr: The acc address of variable. This is the link from the data-entry operation used.
    • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
    • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
    • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
    • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
    • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
    • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
    • name: Holds the name of variable as specified in user clause (including bounds).

    The async values attached to the data exit operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters, MemoryEffects::Write on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
accPtrPointerLikeType instance
varPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

acc.use_device (acc::UseDeviceOp) 

Represents acc use_device semantics.

Syntax:

operation ::= `acc.use_device` `varPtr` `(` $varPtr `:` type($varPtr) `)`
              oilist(
              `varPtrPtr` `(` $varPtrPtr `:` type($varPtrPtr) `)`
              | `bounds` `(` $bounds `)`
              | `async` `(` custom<DeviceTypeOperands>($asyncOperands,
              type($asyncOperands), $asyncOperandsDeviceType) `)`
              ) `->` type($accPtr) attr-dict

Description of arguments:

  • varPtr: The address of variable to copy.
  • varPtrPtr: Specifies the address of varPtr - only used when the variable copied is a field in a struct. This is important for OpenACC due to implicit attach semantics on data clauses (2.6.4).
  • bounds: Used when copying just slice of array or array’s bounds are not encoded in type. They are in rank order where rank 0 is inner-most dimension.
  • asyncOperands and asyncOperandsDeviceType: pair-wise lists of the async clause values associated with device_type’s.
  • asyncOnly: a list of device_type’s for which async clause does not specify a value (default is acc_async_noval - OpenACC 3.3 2.16.1).
  • dataClause: Keeps track of the data clause the user used. This is because the acc operations are decomposed. So a ‘copy’ clause is decomposed to both acc.copyin and acc.copyout operations, but both have dataClause that specifies acc_copy in this field.
  • structured: Flag to note whether this is associated with structured region (parallel, kernels, data) or unstructured (enter data, exit data). This is important due to spec specifically calling out structured and dynamic reference counters (2.6.7).
  • implicit: Whether this is an implicitly generated operation, such as copies done to satisfy “Variables with Implicitly Determined Data Attributes” in 2.6.2.
  • name: Holds the name of variable as specified in user clause (including bounds).

The async values attached to the data entry operation imply that the data action applies to all device types specified by the device_type clauses using the activity queues on these devices as defined by the async values.

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::CurrentDeviceIdResource}, MemoryEffects::Effect{MemoryEffects::Read on ::mlir::acc::RuntimeCounters}

Attributes: 

AttributeMLIR TypeDescription
asyncOperandsDeviceType::mlir::ArrayAttrdevice type array attribute
asyncOnly::mlir::ArrayAttrdevice type array attribute
dataClause::mlir::acc::DataClauseAttr
data clauses supported by OpenACC

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)
structured::mlir::BoolAttrbool attribute
implicit::mlir::BoolAttrbool attribute
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
varPtrPointerLikeType instance
varPtrPtrPointerLikeType instance
boundsvariadic of Type for representing acc data clause bounds information
asyncOperandsvariadic of integer or index

Results: 

ResultDescription
accPtrPointerLikeType instance

acc.wait (acc::WaitOp) 

Wait operation

Syntax:

operation ::= `acc.wait` ( `(` $waitOperands^ `:` type($waitOperands) `)` )?
              oilist(`async` `(` $asyncOperand `:` type($asyncOperand) `)`
              |`wait_devnum` `(` $waitDevnum `:` type($waitDevnum) `)`
              |`if` `(` $ifCond `)`
              ) attr-dict-with-keyword

The “acc.wait” operation represents the OpenACC wait executable directive.

Example:

acc.wait(%value1: index)
acc.wait() async(%async1: i32)

acc.wait does not implement MemoryEffects interface, so it affects all the resources. This is conservatively correct. More precise modelling of the memory effects seems to be impossible without the whole program analysis.

Traits: AttrSizedOperandSegments

Attributes: 

AttributeMLIR TypeDescription
async::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
waitOperandsvariadic of integer or index
asyncOperandinteger or index
waitDevnuminteger or index
ifCond1-bit signless integer

acc.yield (acc::YieldOp) 

Acc yield and termination operation

Syntax:

operation ::= `acc.yield` attr-dict ($operands^ `:` type($operands))?

acc.yield is a special terminator operation for block inside regions in various acc ops (including parallel, loop, atomic.update). It returns values to the immediately enclosing acc op.

Traits: AlwaysSpeculatableImplTrait, HasParent<FirstprivateRecipeOp, LoopOp, ParallelOp, PrivateRecipeOp,ReductionRecipeOp, SerialOp, AtomicUpdateOp>, ReturnLike, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), RegionBranchTerminatorOpInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operandsvariadic of any type

Attributes 

DeclareActionAttr 

Syntax:

#acc.declare_action<
  SymbolRefAttr,   # preAlloc
  SymbolRefAttr,   # postAlloc
  SymbolRefAttr,   # preDealloc
  SymbolRefAttr   # postDealloc
>

Parameters: 

ParameterC++ typeDescription
preAllocSymbolRefAttr
postAllocSymbolRefAttr
preDeallocSymbolRefAttr
postDeallocSymbolRefAttr

DeclareAttr 

Syntax:

#acc.declare<
  DataClauseAttr,   # dataClause
  bool   # implicit
>

Parameters: 

ParameterC++ typeDescription
dataClauseDataClauseAttr
implicitbool

ClauseDefaultValueAttr 

DefaultValue Clause

Syntax:

#acc.defaultvalue<
  ::mlir::acc::ClauseDefaultValue   # value
>

Enum cases:

  • present (Present)
  • none (None)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::ClauseDefaultValuean enum of type ClauseDefaultValue

CombinedConstructsTypeAttr 

Differentiate between combined constructs

Syntax:

#acc.combined_constructs<
  ::mlir::acc::CombinedConstructsType   # value
>

Enum cases:

  • kernels_loop (KernelsLoop)
  • parallel_loop (ParallelLoop)
  • serial_loop (SerialLoop)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::CombinedConstructsTypean enum of type CombinedConstructsType

ConstructAttr 

constructs supported by OpenACC

Syntax:

#acc.construct<
  ::mlir::acc::Construct   # value
>

Enum cases:

  • acc_construct_parallel (acc_construct_parallel)
  • acc_construct_kernels (acc_construct_kernels)
  • acc_construct_loop (acc_construct_loop)
  • acc_construct_data (acc_construct_data)
  • acc_construct_enter_data (acc_construct_enter_data)
  • acc_construct_exit_data (acc_construct_exit_data)
  • acc_construct_host_data (acc_construct_host_data)
  • acc_construct_atomic (acc_construct_atomic)
  • acc_construct_declare (acc_construct_declare)
  • acc_construct_init (acc_construct_init)
  • acc_construct_shutdown (acc_construct_shutdown)
  • acc_construct_set (acc_construct_set)
  • acc_construct_update (acc_construct_update)
  • acc_construct_routine (acc_construct_routine)
  • acc_construct_wait (acc_construct_wait)
  • acc_construct_runtime_api (acc_construct_runtime_api)
  • acc_construct_serial (acc_construct_serial)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::Constructan enum of type Construct

DataClauseAttr 

data clauses supported by OpenACC

Syntax:

#acc.data_clause<
  ::mlir::acc::DataClause   # value
>

Enum cases:

  • acc_copyin (acc_copyin)
  • acc_copyin_readonly (acc_copyin_readonly)
  • acc_copy (acc_copy)
  • acc_copyout (acc_copyout)
  • acc_copyout_zero (acc_copyout_zero)
  • acc_present (acc_present)
  • acc_create (acc_create)
  • acc_create_zero (acc_create_zero)
  • acc_delete (acc_delete)
  • acc_attach (acc_attach)
  • acc_detach (acc_detach)
  • acc_no_create (acc_no_create)
  • acc_private (acc_private)
  • acc_firstprivate (acc_firstprivate)
  • acc_deviceptr (acc_deviceptr)
  • acc_getdeviceptr (acc_getdeviceptr)
  • acc_update_host (acc_update_host)
  • acc_update_self (acc_update_self)
  • acc_update_device (acc_update_device)
  • acc_use_device (acc_use_device)
  • acc_reduction (acc_reduction)
  • acc_declare_device_resident (acc_declare_device_resident)
  • acc_declare_link (acc_declare_link)
  • acc_cache (acc_cache)
  • acc_cache_readonly (acc_cache_readonly)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::DataClausean enum of type DataClause

DeviceTypeAttr 

built-in device type supported by OpenACC

Syntax:

#acc.device_type<
  ::mlir::acc::DeviceType   # value
>

Enum cases:

  • none (None)
  • star (Star)
  • default (Default)
  • host (Host)
  • multicore (Multicore)
  • nvidia (Nvidia)
  • radeon (Radeon)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::DeviceTypean enum of type DeviceType

GangArgTypeAttr 

Differentiate the different gang arg values

Syntax:

#acc.gang_arg_type<
  ::mlir::acc::GangArgType   # value
>

Enum cases:

  • Num (Num)
  • Dim (Dim)
  • Static (Static)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::GangArgTypean enum of type GangArgType

ReductionOperatorAttr 

built-in reduction operations supported by OpenACC

Syntax:

#acc.reduction_operator<
  ::mlir::acc::ReductionOperator   # value
>

Enum cases:

  • add (AccAdd)
  • mul (AccMul)
  • max (AccMax)
  • min (AccMin)
  • iand (AccIand)
  • ior (AccIor)
  • xor (AccXor)
  • eqv (AccEqv)
  • neqv (AccNeqv)
  • land (AccLand)
  • lor (AccLor)

Parameters: 

ParameterC++ typeDescription
value::mlir::acc::ReductionOperatoran enum of type ReductionOperator

RoutineInfoAttr 

Keeps track of associated acc routine information

Syntax:

#acc.routine_info<
  ::llvm::ArrayRef<SymbolRefAttr>   # accRoutines
>

This attribute is used to create the association between a function and its acc.routine operation. A func.func uses this if its name was referenced in an acc routine directive.

Parameters: 

ParameterC++ typeDescription
accRoutines::llvm::ArrayRef<SymbolRefAttr>

Types 

DataBoundsType 

Type for representing acc data clause bounds information

Syntax: !acc.data_bounds_ty

DeclareTokenType 

declare token type

Syntax: !acc.declare_token

acc.declare_token is a type returned by a declare_enter operation and can be passed to a declare_exit operation to represent an implicit data region.

Enums 

ClauseDefaultValue 

DefaultValue Clause

Cases: 

SymbolValueString
Present0present
None1none

CombinedConstructsType 

Differentiate between combined constructs

Cases: 

SymbolValueString
KernelsLoop1kernels_loop
ParallelLoop2parallel_loop
SerialLoop3serial_loop

Construct 

constructs supported by OpenACC

Cases: 

SymbolValueString
acc_construct_parallel0acc_construct_parallel
acc_construct_kernels1acc_construct_kernels
acc_construct_loop2acc_construct_loop
acc_construct_data3acc_construct_data
acc_construct_enter_data4acc_construct_enter_data
acc_construct_exit_data5acc_construct_exit_data
acc_construct_host_data6acc_construct_host_data
acc_construct_atomic7acc_construct_atomic
acc_construct_declare8acc_construct_declare
acc_construct_init9acc_construct_init
acc_construct_shutdown10acc_construct_shutdown
acc_construct_set11acc_construct_set
acc_construct_update12acc_construct_update
acc_construct_routine13acc_construct_routine
acc_construct_wait14acc_construct_wait
acc_construct_runtime_api15acc_construct_runtime_api
acc_construct_serial16acc_construct_serial

DataClause 

data clauses supported by OpenACC

Cases: 

SymbolValueString
acc_copyin1acc_copyin
acc_copyin_readonly2acc_copyin_readonly
acc_copy3acc_copy
acc_copyout4acc_copyout
acc_copyout_zero5acc_copyout_zero
acc_present6acc_present
acc_create7acc_create
acc_create_zero8acc_create_zero
acc_delete9acc_delete
acc_attach10acc_attach
acc_detach11acc_detach
acc_no_create12acc_no_create
acc_private13acc_private
acc_firstprivate14acc_firstprivate
acc_deviceptr15acc_deviceptr
acc_getdeviceptr16acc_getdeviceptr
acc_update_host17acc_update_host
acc_update_self18acc_update_self
acc_update_device19acc_update_device
acc_use_device20acc_use_device
acc_reduction21acc_reduction
acc_declare_device_resident22acc_declare_device_resident
acc_declare_link23acc_declare_link
acc_cache24acc_cache
acc_cache_readonly25acc_cache_readonly

DeviceType 

built-in device type supported by OpenACC

Cases: 

SymbolValueString
None0none
Star1star
Default2default
Host3host
Multicore4multicore
Nvidia5nvidia
Radeon6radeon

GangArgType 

Differentiate the different gang arg values

Cases: 

SymbolValueString
Num0Num
Dim1Dim
Static2Static

ReductionOperator 

built-in reduction operations supported by OpenACC

Cases: 

SymbolValueString
AccAdd0add
AccMul1mul
AccMax2max
AccMin3min
AccIand4iand
AccIor5ior
AccXor6xor
AccEqv7eqv
AccNeqv8neqv
AccLand9land
AccLor10lor