Issue 143330
Summary [Flang][OpenMP] Execution error when array assignment statement for an array containing ":" is specified in forall construct within workshare construct
Labels flang:openmp
Assignees
Reporter ohno-fj
    ```
Version of flang : 21.0.0(b68565b8c70fc590f8e59799996f450b1072b532)/AArch64
```

In the attached program (`snggw638_220.f90`), when `array assignment statement` for an array containing `":"` is specified in `forall construct` within `workshare construct`, the execution terminates abnormally.

Execution ends normally in the following cases:
- No compilation option (`-fopenmp`)
- Change the value specified for `OMP_NUM_THREAD` from `2` to `1`
- Change `":"` to array subscripts (`1` and `2`)
  see `snggw638_221.f90` below.
- Change `":"` to loop variable (`n0`) and add loop (`forall(n0=1:2) / end forall`)
  see `snggw638_222.f90` below.

The combination of `OpenMP workshare construct` and `array assignment statement` for an array containing `":"` in `forall construct` does not appear to work correctly.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

snggw638_220.f90:
```fortran
program main
  integer a1(2,1,3)
 a1 = 0
!$omp parallel
!$omp workshare
  forall (n1=1:1)
     forall (n2=1:3)
        a1(:,n1,n2) = a1(:,n1,n2)+1
     end forall
  end forall
!$omp end workshare
!$omp end parallel
  print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggw638_220.f90; ./a.out
Segmentation fault (core dumped)
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snggw638_220.f90; ./a.out
 pass
$
```

```
$ export OMP_NUM_THREADS=2; ifx -qopenmp snggw638_220.f90; ./a.out
 pass
$
```

snggw638_221.f90:
```fortran
program main
  integer a1(2,1,3)
  a1 = 0
!$omp parallel
!$omp workshare
  forall (n1=1:1)
 forall (n2=1:3)
!        a1(:,n1,n2) = a1(:,n1,n2)+1
        a1(1,n1,n2) = a1(1,n1,n2)+1
        a1(2,n1,n2) = a1(2,n1,n2)+1
     end forall
  end forall
!$omp end workshare
!$omp end parallel
  print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggw638_221.f90; ./a.out
 pass
$
```

snggw638_222.f90:
```fortran
program main
  integer a1(2,1,3)
  a1 = 0
!$omp parallel
!$omp workshare
  forall (n0=1:2)
 forall (n1=1:1)
        forall (n2=1:3)
!           a1(:,n1,n2) = a1(:,n1,n2)+1
           a1(n0,n1,n2) = a1(n0,n1,n2)+1
        end forall
 end forall
  end forall
!$omp end workshare
!$omp end parallel
 print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggw638_222.f90; ./a.out
 pass
$
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to