| Issue |
172928
|
| Summary |
[Flang][OpenMP] Execution terminates abnormally when using array constructor within WORKSHARE construct
|
| Labels |
flang:openmp
|
| Assignees |
|
| Reporter |
ohno-fj
|
```
Version of flang : 22.0.0(bcbbe2c2bcbeee4e37ca39c8088bbc0702f7f69c)/AArch64
```
In the attached program (`fa903_2.f90`), using `array constructors ([b3] and [b1])` as argument to `ANY intrinsic function` within `WORKSHARE construct` inside `PARALLEL construct` causes the program to terminate abnormally at runtime. However, it may occasionally execute normally.
As shown below, 7 out of 10 runs terminated abnormally.
The program executes normally in the following cases:
- Remove `WORKSHARE construct`, or
(The above is `fa903_21.f90`.)
- Unused `array constructors ([b3] or [b1])`
Example: Change [b3] and [b1] to b3 and b1
(The above is `fa903_22.f90`.)
The attached log shows 10 runs after the modification. I performed an additional 100 runs, but no abnormal termination occurred.
The following are the test program, Flang, Gfortran and ifx compilation/execution results.
fa903_2.f90:
```fortran
program main
call test()
print *,'pass'
end program main
module mod
integer,dimension(4)::b1,b3
end module mod
subroutine test()
use mod
logical(8)::l1,l2
call set(b1)
call set(b3)
!$omp parallel
!$omp workshare
l2 = any([b3]/=[b1])
!$omp end workshare
if (l2) print *,"fail2"
!$omp end parallel
end subroutine
subroutine set(b)
integer::b(4)
b=1
end subroutine set
```
```
$ flang -fopenmp fa903_2.f90
$ export OMP_NUM_THREADS=16; ./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out
Segmentation fault (core dumped)
Segmentation fault (core dumped)
pass
fatal Fortran runtime errorSegmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
pass
fatal Fortran runtime error: Assign: mismatching element counts in array assignment (to 1, from 4)
Aborted (core dumped)
Segmentation fault (core dumped)
pass
$
```
```
$ gfortran -fopenmp fa903_2.f90
$ export OMP_NUM_THREADS=16; ./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out
pass
pass
pass
pass
pass
pass
pass
pass
pass
pass
$
```
```
$ ifx -qopenmp fa903_2.f90
$ export OMP_NUM_THREADS=16; ./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out
pass
pass
pass
pass
pass
pass
pass
pass
pass
pass
$
```
fa903_21.f90:
```fortran
program main
call test()
print *,'pass'
end program main
module mod
integer,dimension(4)::b1,b3
end module mod
subroutine test()
use mod
logical(8)::l1,l2
call set(b1)
call set(b3)
!$omp parallel
l2 = any([b3]/=[b1])
if (l2) print *,"fail2"
!$omp end parallel
end subroutine
subroutine set(b)
integer::b(4)
b=1
end subroutine set
```
```
$ flang -fopenmp fa903_21.f90
$ export OMP_NUM_THREADS=16; ./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out
pass
pass
pass
pass
pass
pass
pass
pass
pass
pass
$
```
fa903_22.f90:
```fortran
program main
call test()
print *,'pass'
end program main
module mod
integer,dimension(4)::b1,b3
end module mod
subroutine test()
use mod
logical(8)::l1,l2
call set(b1)
call set(b3)
!$omp parallel
!$omp workshare
! l2 = any([b3]/=[b1])
l2 = any(b3/=b1)
!$omp end workshare
if (l2) print *,"fail2"
!$omp end parallel
end subroutine
subroutine set(b)
integer::b(4)
b=1
end subroutine set
```
```
$ flang -fopenmp fa903_22.f90
$ export OMP_NUM_THREADS=16; ./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out;./a.out
pass
pass
pass
pass
pass
pass
pass
pass
pass
pass
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs