https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88852
Bug ID: 88852
Summary: [openacc] Host fallback doesn't create private copy
for reduction var on gang clause
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
spinoff from PR 80547 - '[7/8/9 Regression] nvptx back end ICE with OpenACC
"reduction(OP:x)", "x = [...]"'.
Consider this test-case:
...
int
main (void)
{
int x = 123;
#pragma acc parallel num_gangs(1) reduction (+: x)
{
x = 23;
}
if (x != 146)
__builtin_abort();
.
return 0;
}
...
The semantics of the reduction variable are:
...
The reduction clause is allowed on the parallel construct. It specifies a
reduction operator and one or more scalar variables. For each variable, a
private copy is created for each parallel gang and initialized for that
operator. At the end of the region, the values for each gang are combined
using the reduction operator, and the result combined with the value of the
original variable and stored in the original variable. The reduction result is
available after the region
...
Looking at the host fallback at oaccdevlow:
...
__attribute__((oacc function (1, 1, 1), omp target entrypoint))
main._omp_fn.0 (const struct .omp_data_t.0 & restrict .omp_data_i)
{
int x;
int * _3;
int * _6;
int * _8;
int * _11;
<bb 2> [local count: 1073741824]:
_3 = *.omp_data_i_2(D).x;
x_5 = *_3;
_6 = *.omp_data_i_2(D).x;
_8 = *.omp_data_i_2(D).x;
x_10 = 23;
_11 = *.omp_data_i_2(D).x;
*_11 = x_10;
return;
}
...
we see that there's no private copy initialized, and no combination with
original value done.