https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122728
Bug ID: 122728
Summary: [OpenMP] Bogus warning "allocator with access trait
set to ‘thread’ results in undefined behavior for
‘target’ directive"
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
That's for:
https://github.com/OpenMP-Validation-and-Verification/OpenMP_VV/blob/master/tests/5.0/target/test_target_uses_allocators_thread.c#L28
Namely,
#pragma omp target parallel \
uses_allocators(omp_thread_mem_alloc) \
allocate(omp_thread_mem_alloc: x) private(x)
GCC warns about this as:
In function ‘test_uses_allocators_thread’:
test_target_uses_allocators_thread.c:28:75:
warning: allocator with access trait set to ‘thread’ results in
undefined behavior for ‘target’ directive [-Wopenmp]
That's based on:
Restrictions to the allocate clause are as follows:
…
* For task, taskloop or target directives, allocation requests to memory
allocators with the access trait set to thread result in unspecified
behavior.
→ OpenMP 5.0, "2.11.4 allocate Clause" – or TR14, "13.6 allocate Clause"
However, that shouldn't be applied.
OpenMP 5.2's "17.2 Clauses on Combined and Composite Constructs" states:
The effect of the allocate clause is as if it is applied to all leaf
constructs that permit the clause and to which a data-sharing attribute
clause that may create a private copy of the same list item is
applied.
But:
The effect of the private clause is as if it is applied only to
the innermost leaf construct that permits it.
Hence, it should only be applied to 'parallel' and there 'thread' is fine!