https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122447
Bug ID: 122447
Summary: [OpenMP] Mapping same element with with two clause
fails ("appears more than once in data clauses")
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: openmp, rejects-valid
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The following fails with:
error: ‘ptr’ appears more than once in data clauses
it should be handled.
This is supposed to work at lexical scope (i.e. during the compilation), albeit
for 'S', note the complication.
This also appears in some OpenMP_VV testcase – and the mapping decay rules
appear (to be added to GCC as part of the pending/being-added 'declare mapper'
patches).
************
#include <cstdio>
#include <omp.h>
struct S {
int x[5];
int y[5];
};
int main()
{
size_t size = 10;
int *ptr = new int[size];
//int ptr[10];
S s = {{1,2,3,4,5}, {11,22,33,44,55}};
for (int i = 0; i < size; ++i)
ptr[i] = 42;
#pragma omp target map(to:ptr[0:size]) map(from:ptr[0:size])
{
#pragma omp teams distribute parallel for
for (int i =2 ; i < size -2; ++i)
ptr[i] = i;
}
for (int i = 0; i < size; ++i)
std::printf("%d ", ptr[i]);
std::printf("\n");
// This is supposed to be valid as well - note that 'to' and 'from'
// are not identical.
// Cf. first restriction which permits this for structs.
#pragma omp target map(to:s) map(from:s.y)
{
#pragma omp teams distribute parallel for
for (int i =2 ; i < size -2; ++i)
s.y[i] = s.x + i;
}
}