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

            Bug ID: 104949
           Summary: [OpenMP] omp target: firstprivate of allocatable array
                    – only descriptor firstprivatized
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

Found via
https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/target/test_target_defaultmap_firstprivate.F90

The line:
  !$omp target firstprivate(A)

is translated as

        .omp_data_arr.19.a = &a;
        #pragma omp target num_teams(1) thread_limit(0) firstprivate(a)
               [child fn: MAIN__._omp_fn.1 (.omp_data_arr.19,
.omp_data_sizes.20,
                                            .omp_data_kinds.21)]

Thus, it does not handle the descriptor. See also PR 90742.

 * * *

implicit none (type,external)
integer, allocatable :: A(:)
A = [1,2,3,4,5,6]

!$omp parallel firstprivate(A)
!$omp master
  if (any (A /= [1,2,3,4,5])) error stop
  A(:) = [99,88,77,66,55]
!$omp end master
!$omp end parallel

!$omp target firstprivate(A)
  if (any (A /= [1,2,3,4,5])) error stop
  A(:) = [99,88,77,66,55]
!$omp end target
if (any (A /= [1,2,3,4,5])) error stop
end

Reply via email to