[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

Ethan Stewart via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 21 14:26:33 PST 2023


estewart08 added a comment.
Herald added a subscriber: steakhal.
Herald added a reviewer: NoQ.
Herald added a project: All.

In D74144#2308856 <https://reviews.llvm.org/D74144#2308856>, @ABataev wrote:

> In D74144#2308796 <https://reviews.llvm.org/D74144#2308796>, @cchen wrote:
>
>> In D74144#2307494 <https://reviews.llvm.org/D74144#2307494>, @ABataev wrote:
>>
>>> In D74144#2307454 <https://reviews.llvm.org/D74144#2307454>, @cchen wrote:
>>>
>>>> @ABataev, the below test is extracted from Sollve test suite and Clang now emit:
>>>>
>>>>   test.c:17:35: error: subscripted value is not an array or pointer
>>>>       #pragma omp target update to( (([N][N])foo)[1:M] )
>>>>                                     ^~~~~~~~~~~~~
>>>>   test.c:17:5: error: expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'
>>>>       #pragma omp target update to( (([N][N])foo)[1:M] )
>>>>
>>>> This error message came from the `ActOnOMPArraySectionExpr` which is called inside `ParsePostfixExpressionSuffix`. The issue is that the base expression in `ActOnOMPArraySectionExpr` looks like:
>>>>
>>>>   ParenExpr 0x122859be0 '<OpenMP array shaping type>' lvalue
>>>>   `-OMPArrayShapingExpr 0x122859b98 '<OpenMP array shaping type>' lvalue
>>>>     |-IntegerLiteral 0x122859b38 'int' 5
>>>>     |-IntegerLiteral 0x122859b58 'int' 5
>>>>     `-DeclRefExpr 0x122859b78 'int *' lvalue Var 0x1228599d0 'foo' 'int *'
>>>>
>>>> which is not a base that we would expect in an array section expr. I've tried relaxing the base type check in `ActOnOMPArraySectionExpr` but not sure it's the way to go. (or should I just extract the DeclReExpr from ArrayShapingExpr before calling `ActOnOMPArraySectionExpr`?)
>>>>
>>>>   #define N 5
>>>>   #define M 3
>>>>   
>>>>   int main(void) {
>>>>       int tmp[N][N];
>>>>       for(int i=0; i<N; i++)
>>>>           for(int j=0; j<N; j++)
>>>>               tmp[i][j] = N*i + j;
>>>>   
>>>>       int *foo = &tmp[0][0];
>>>>   
>>>>       // This compiles just fine
>>>>       //#pragma omp target update to( ([N][N])foo )
>>>>   
>>>>       // This is rejected by the compiler
>>>>       #pragma omp target update to( (([N][N])foo)[1:M] )
>>>>   }
>>>
>>> I don't think it is allowed by the standard.
>>>
>>> According to the standard, The shape-operator can appear only in clauses where it is explicitly allowed.
>>> In this case, array shaping is used as a base expression of array section (or subscript) expression, which does not meet the standard. Tje array sjaping operation is not used in clause, instead it is used as a base subexpression of another expression.
>>
>> In OpenMP 5.0 [2.12.6, target update construct, Restrictions, C/C++, p.1] The list items that appear in the to or from clauses may use shape-operators.
>> Also, in the array shaping section in https://github.com/OpenMP/Examples, the example is also illustrated with the same usage:
>>
>>   ...
>>   S-17 // update boundary points (two columns of 2D array) on the host
>>   S-18 // pointer is shaped to 2D array using the shape-operator
>>   S-19 #pragma omp target update from( (([nx][ny+2])a)[0:nx][1], (([nx][ny+2])a)[0:nx][ny] )
>>   ...
>
> Then just need to fix it, if examples document has this example.

Was this ever followed up on and fixed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74144/new/

https://reviews.llvm.org/D74144



More information about the cfe-commits mailing list