Skip to content

Commit 482c1df

Browse files
author
Razvan Lupusoru
committed
[mlir][openacc] Add descriptions for new acc data operations
The acc.bounds operation now clarifies that it is meant to be zero-based. I added example for both C++ and Fortran to show the normalized representation. I also added description for each operand in the data entry and data exit operations. Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D148860
1 parent 4f02a0f commit 482c1df

File tree

1 file changed

+77
-1
lines changed

1 file changed

+77
-1
lines changed

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,43 @@ def OpenACC_DataClauseEnum : I64EnumAttr<"DataClause",
101101
// Either (or both) extent and upperbound must be specified.
102102
def OpenACC_DataBoundsOp : OpenACC_Op<"bounds",
103103
[AttrSizedOperandSegments, NoMemoryEffect]> {
104-
let summary = "Represents bounds information for acc data clause.";
104+
let summary = "Represents normalized bounds information for acc data clause.";
105+
106+
let description = [{
107+
This operation is used to record bounds used in acc data clause in a
108+
normalized fashion (zero-based). This works well with the `PointerLikeType`
109+
requirement in data clauses - since a `lowerbound` of 0 means looking
110+
at data at the zero offset from pointer.
111+
112+
The operation must have an `upperbound` or `extent` (or both are allowed
113+
- but not checked for consistency). When the source language's arrays are
114+
not zero-based, the `startIdx` must specify the zero-position index.
115+
116+
Examples below show copying a slice of 10-element array except first element.
117+
Note that the examples use extent in data clause for C++ and upperbound
118+
for Fortran (as per 2.7.1). To simplify examples, the constants are used
119+
directly in the acc.bounds operands - this is not the syntax of operation.
120+
121+
C++:
122+
```
123+
int array[10];
124+
#pragma acc copy(array[1:9])
125+
```
126+
=>
127+
```mlir
128+
acc.bounds lb(1) ub(9) extent(9) startIdx(0)
129+
```
130+
131+
Fortran:
132+
```
133+
integer :: array(1:10)
134+
!$acc copy(array(2:10))
135+
```
136+
=>
137+
```mlir
138+
acc.bounds lb(1) ub(9) extent(9) startIdx(1)
139+
```
140+
}];
105141

106142
let arguments = (ins Optional<IntOrIndex>:$lowerbound,
107143
Optional<IntOrIndex>:$upperbound,
@@ -144,6 +180,26 @@ class OpenACC_DataEntryOp<string mnemonic, string clause, list<Trait> traits = [
144180
OptionalAttr<StrAttr>:$name);
145181
let results = (outs OpenACC_PointerLikeTypeInterface:$accPtr);
146182

183+
let description = [{
184+
- `varPtr`: The address of variable to copy.
185+
- `varPtrPtr`: Specifies the address of varPtr - only used when the variable
186+
copied is a field in a struct. This is important for OpenACC due to implicit
187+
attach semantics on data clauses (2.6.4).
188+
- `bounds`: Used when copying just slice of array or array's bounds are not
189+
encoded in type. They are in rank order where rank 0 is inner-most dimension.
190+
- `dataClause`: Keeps track of the data clause the user used. This is because
191+
the acc operations are decomposed. So a 'copy' clause is decomposed to both
192+
`acc.copyin` and `acc.copyout` operations, but both have dataClause that
193+
specifies `acc_copy` in this field.
194+
- `structured`: Flag to note whether this is associated with structured region
195+
(parallel, kernels, data) or unstructured (enter data, exit data). This is
196+
important due to spec specifically calling out structured and dynamic reference
197+
counters (2.6.7).
198+
- `implicit`: Whether this is an implicitly generated operation, such as copies
199+
done to satisfy "Variables with Implicitly Determined Data Attributes" in 2.6.2.
200+
- `name`: Holds the name of variable as specified in user clause (including bounds).
201+
}];
202+
147203
let assemblyFormat = [{
148204
`varPtr` `(` $varPtr `:` type($varPtr) `)`
149205
oilist(
@@ -245,6 +301,26 @@ class OpenACC_DataExitOp<string mnemonic, string clause, list<Trait> traits = []
245301
DefaultValuedAttr<BoolAttr, "false">:$implicit,
246302
OptionalAttr<StrAttr>:$name);
247303

304+
let description = [{
305+
- `varPtr`: The address of variable to copy back to. This only applies to
306+
`acc.copyout`
307+
- `accPtr`: The acc address of variable. This is the link from the data-entry
308+
operation used.
309+
- `bounds`: Used when copying just slice of array or array's bounds are not
310+
encoded in type. They are in rank order where rank 0 is inner-most dimension.
311+
- `dataClause`: Keeps track of the data clause the user used. This is because
312+
the acc operations are decomposed. So a 'copy' clause is decomposed to both
313+
`acc.copyin` and `acc.copyout` operations, but both have dataClause that
314+
specifies `acc_copy` in this field.
315+
- `structured`: Flag to note whether this is associated with structured region
316+
(parallel, kernels, data) or unstructured (enter data, exit data). This is
317+
important due to spec specifically calling out structured and dynamic reference
318+
counters (2.6.7).
319+
- `implicit`: Whether this is an implicitly generated operation, such as copies
320+
done to satisfy "Variables with Implicitly Determined Data Attributes" in 2.6.2.
321+
- `name`: Holds the name of variable as specified in user clause (including bounds).
322+
}];
323+
248324
let assemblyFormat = [{
249325
`accPtr` `(` $accPtr `:` type($accPtr) `)`
250326
oilist(

0 commit comments

Comments
 (0)