Issue |
139636
|
Summary |
Flang OpenMP issue with copy private clauses on common blocks.
|
Labels |
flang
|
Assignees |
|
Reporter |
scamp-nvidia
|
We believe the following section of code should work properly as it works with NVIDIA's nvfortran 25.3 and GNU's gfortran version 15.1.
```
Program main
implicit none
call test_common()
End Program main
subroutine test_common()
implicit none
common /vals/ val
integer, target :: targ
integer, pointer :: ptr
integer :: val
!$omp threadprivate (/vals/)
targ = 200
!$omp parallel private(ptr) shared(targ) default(none)
!$omp single
val = 300
ptr => targ ! set private pointer to shared storage
#ifdef NO_COMMON
!$omp end single copyprivate(val, ptr)
#else
!$omp end single copyprivate(/vals/, ptr)
#endif
if (.not. associated(ptr)) then
print *, "ERROR: ptr is not associated"
else
if (ptr == 200 .and. val == 300) then
print *, "SUCCESS"
else
print *, "FAILURE"
end if
end if
!$omp end parallel
end subroutine test_common
```
By default, the code tries to do a copyprviate on a common block at the end of an OpenMP region, but all but 1 thread get the wrong behavior.
```
scamp@milan2:/local/home/scamp/common_issue$ export OMP_NUM_THREADS=4
scamp@milan2:/local/home/scamp/common_issue$ flang test.F90 -fopenmp -o test
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
scamp@milan2:/local/home/scamp/common_issue$ ./test
SUCCESS
ERROR: ptr is not associated
ERROR: ptr is not associated
ERROR: ptr is not associated
scamp@milan2:/local/home/scamp/common_issue$ gfortran test.F90 -fopenmp -o test
scamp@milan2:/local/home/scamp/common_issue$ ./test
SUCCESS
SUCCESS
SUCCESS
SUCCESS
scamp@milan2:/local/home/scamp/common_issue$ nvfortran test.F90 -mp -o test
scamp@milan2:/local/home/scamp/common_issue$ ./test
SUCCESS
SUCCESS
SUCCESS
SUCCESS
```
This is all with almost the latest version of Flang:
```
scamp@milan2:/local/home/scamp/common_issue$ flang --version
flang version 21.0.0git (https://github.com/llvm/llvm-project 227328f6f6d32e93a6c3c0d3c82a7601f92f9abb)
```
As seen in the code, you can work around it by not using the common block, but it should work with the common block as well.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs