COPYPRIVATE in SINGLE region segfaulting

We have OpenMP problem regarding the use of a COPYPRIVATE at the end of a SINGLE region with PGI 14.9.0 64-bit on X86-64. If the SINGLE clause is separated from the binding PARALLEL region, then the COPYPRIVATE causes a segfault if the variable to which it is applied is local to the subroutine and stack-allocated. The problem can be circumvented if the variable is given the ALLOCATABLE attribute and allocated explicitly within the subroutine. The code does not segfault when built with Intel, GNU, or the Cray compiler.

Many thanks for any advice.

Code:
program test
!
implicit none
!
call master()
!
end program test
!
!-------------------------------
!
subroutine master
!
implicit none
!
integer(KIND=8), ALLOCATABLE:: tts(:)
integer(KIND=8) ttt(2)
integer nt,OMP_GET_NUM_THREADS,tpi,OMP_GET_THREAD_NUM
!
nt = 4
call OMP_SET_NUM_THREADS(nt)
allocate(tts(nt))
!
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(ttt,tpi)
!
tpi = OMP_GET_THREAD_NUM() + 1
!$OMP SINGLE
call System_Clock(count_rate=ttt(1))
!$OMP END SINGLE COPYPRIVATE(ttt)
!
tts(tpi) = ttt(1)
!
!$OMP END PARALLEL
!
write(,) ‘All embedded:’
do tpi=1,nt
write(,) 'Thread ‘,tpi,’: ',tts(tpi)
end do
!
!
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(ttt,tpi)
!
tpi = OMP_GET_NUM_THREADS()
call do_the_same_hidden(tpi,tts)
!
!$OMP END PARALLEL
!
write(,) ‘Hidden:’
do tpi=1,nt
write(,) 'Thread ‘,tpi,’: ',tts(tpi)
end do
!
end subroutine master
!
!----------------------------------------
!
subroutine do_the_same_hidden(tpn,tts)
!
implicit none
!
integer, INTENT(IN):: tpn
!
integer(KIND=8) tts(tpn)
integer(KIND=8) ttt(2) ! this will not work with PGI
! integer (KIND=8), ALLOCATABLE:: ttt(:) ! this will work with PGI
integer OMP_GET_THREAD_NUM,tpi
!
! allocate(ttt(tpn)) ! see above
tpi = OMP_GET_THREAD_NUM() + 1
!$OMP SINGLE
call System_Clock(count_rate=ttt(1))
!$OMP END SINGLE COPYPRIVATE(ttt)
!
tts(tpi) = ttt(1)
! deallocate(ttt) ! see above
!
end subroutine do_the_same_hidden

I have replicated your behavior, and have shown the code does work as expected with gfortran and intel ifort.

We have created TPR 21078 to address this.

Many thanks!

Hi jtull, is there a mechanism for users to track the progress of bugs?

Hi jtull, is there a mechanism for users to track the progress of bugs?

Not at this time.

Note that since your submitted this issue on the PGI Users Forum, notifications will be made on this post. If you wish to have the notifications sent directly to you, please send a note to PGI Customer Service (trs@pgroup.com) asking them to add you to the notification list. You can also send them a note if you want to know the status.

  • Mat

TPR 21078 - OpenMP program using ’ integer(KIND=8) ttt(2);!$OMP END SINGLE COPYPRIVATE(ttt)

has been corrected in the current 15.1 release.

thanks,
dave