https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90742

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The firstprivate behavior should be covered by 2.19.3 "List Item Privatization"
because firstprivate is a privatization clause.
"For a list item or the subobject of a list item with the ALLOCATABLE
attribute:
• If the allocation status is unallocated, the new list item or the subobject
of the new list item will have an initial allocation status of unallocated;
• If the allocation status is allocated, the new list item or the subobject of
the new list item will have an initial allocation status of allocated; and
• If the new list item or the subobject of the new list item is an array, its
bounds will be the same as those of the original list item or the subobject of
the original list item."
So, for firstprivate(allocatable_var) one can allocate or deallocate or
reallocate as he wishes inside of the region.  I'd hope that at least for
non-target regions we implement it correctly, but it has been a while since
I've worked full time on Fortran OpenMP.
For the implicit mapping or privatization, there is also:
"If a scalar variable has the TARGET, ALLOCATABLE or POINTER attribute then it
is treated as if it has appeared in a map clause with a map-type of tofrom."
so allocatables are mapped by default if defaultmap clause is not present (or
is default).
For the map clause, there are additional restrictions:
"• If the allocation status of a list item or any subobject of the list item
with the ALLOCATABLE attribute is unallocated upon entry to a target region,
the list item or any subobject of the corresponding list item must be
unallocated upon exit from the region.
• If the allocation status of a list item or any subobject of the list item
with the ALLOCATABLE attribute is allocated upon entry to a target region, the
allocation status of the corresponding list item or any subobject of the
corresponding list item must not be changed and must not be reshaped in the
region."
So, while with firstprivate allocatable one can do anything he wishes, for
mapped allocatable if it is not allocated on mapping it should not be allocated
at the end either (so in the end it is like a private allocatable), and if it
is allocated its data can be mapped normally and user should not
allocate/deallocate/reallocate.

Reply via email to