Hi Chung-Lin,

https://gcc.gnu.org/pipermail/gcc-patches/2024-January/641669.html

Chung-Lin Tang wrote:
this patch implements reductions for arrays and structs for OpenACC. Following 
the pattern for OpenACC reductions [...]

(Stumbled over while looking at the Fortran patch, but applying to C/C++, hence mentioned here; the Fortran patch is at https://gcc.gnu.org/pipermail/gcc-patches/2024-February/645205.html )


OpenACC permits array elements and subarrays. I have not checked whether array elements are currently rejected or fully supported, but I miss a testcase for both array elements (unless there is one already) and array sections.

If implemented, I think there should be a working run-time test.
If not supported, there should be a sorry_at error for those.

Note: the parser should handle array sections as OpenMP handles them.

The testcase should cover something like the following:

void f(int n)
{
  int x[5][5]; // Multimensional array;
  int y[n]; // VLA
  int *z = (int*)malloc(5*5*sizeof(int)); // Allocated array

... reduction(+:x)
... reduction(+:y)

... reduction(+:x[0:5][2:1])  // OK
... reduction(+:x[1:4][2:1])
  // invalid - while contiguous, first dim does not span the whole array
... reduction(+:y[2:2])  // OK
... reduction(+:y[3:])  // OK - same as [3:n-3]
... reduction(+:y[:2])  // OK - same as [0:2]
... reduction(+:z[1:2][1:6])  // OK

And the same where at least one of the const number is replaced by
a variable.

Note: The 'invalid' reduction is fine in terms of being contiguous (last dimension contains a single element, hence, the dimension before does not need to span the whole extend) - but OpenACC requires the all dimensions but the last to span the whole range.

See "2.7.1 Data Specification in Data Clauses" for the subarray description.

I think - if known at compile time - there should be also a diagnostic if the any dimension but the last does not span the whole range.

Thanks,

Tobias

Reply via email to