Issue 180094
Summary [Flang][OpenMP] Compilation error when specifying a host associated THREADPRIVATE variable in COPYIN clause
Labels flang:openmp
Assignees
Reporter ohno-fj
    ```
Version of flang : 23.0.0(beb0e7e15005f96b144fcac51a765fedd52c4b7c)/AArch64
```

In the attached program (`snggy256_2.f90`), specifying a host associated `THREADPRIVATE variable` in `COPYIN clause` causes a compilation error.
The error detail is as follows:
`Non-THREADPRIVATE object 'k1' in COPYIN clause`

The `k1` specified in `COPYIN clause` is defined as the data object of 'COMMON block' using `THREADPRIVATE directive` and is host associated. Therefore, it is likely `THREADPRIVATE`.

Compilation completes successfully in the following cases:
- specify a non host associated `THREADPRIVATE variable` in `COPYIN clause`
  The above refers to `snggy256_21.f90`.

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

snggy256_2.f90:
```fortran
program main
  common /cmn/ k1
!$omp threadprivate(/cmn/)
  call ss1
  print *,'pass'
contains
  subroutine ss1
    k1=1
!$omp parallel copyin (k1)
 if (k1/=1) print *,1131
!$omp end parallel
  end subroutine ss1
end program main
```

```
$ flang -fopenmp snggy256_2.f90
error: Semantic errors in snggy256_2.f90
./snggy256_2.f90:9:24: error: Non-THREADPRIVATE object 'k1' in COPYIN clause
  !$omp parallel copyin (k1)
 ^^
$
```

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

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

snggy256_21.f90:
```fortran
program main
  common /cmn/ k1
!$omp threadprivate(/cmn/)
  k1=1
!$omp parallel copyin (k1)
  if (k1/=1) print *,1131
!$omp end parallel
  print *,'pass'
end program main
```

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

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to