[J3] Question: Aliasing in Parallel Procedure Instances in OpenMP Parallel Regions
Klemm, Michael
Michael.Klemm at amd.com
Sat Feb 10 15:51:25 UTC 2024
[Public]
Hi folks,
In the OpenMP Language Committee at discussion happened about the below piece of Fortran code. There was some dissent in the discussion, so I'm hoping for some clarification.
In the example, someone spawns a few threads and calls a Fortran procedure, passing along a variable that's shared in the parallel region. We understand that dummy arguments cannot alias. But what about the "variable" dummy argument that aliases in two parallel instances of the same procedure? It seems that the wording of the aliasing rule does not define that at all (which is not surprising, given that Fortran does not know threads).
So, the question is: Are we in UB land with the below example? Does the definition of dummy-argument aliasing in Fortran extend to the parallel case, too?
Kind regards,
-michael
subroutine test(variable)
use omp_lib, only : omp_get_thread_num
implicit none
integer :: variable
!$omp single
variable = 1234
!$omp end single
if (variable .ne. 1234) then
print '(A,I0,A,I0)', "ERROR: variable=", variable, ", TID=",omp_get_thread_num()
endif
end subroutine test
program main
implicit none
integer :: variable2
interface
subroutine test(variable)
implicit none
integer :: variable
end subroutine test
end interface
variable2 = -42
!$omp parallel shared(variable2)
call test(variable2)
!$omp end parallel
end program main
More information about the J3
mailing list