llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.21k stars 11.14k forks source link

[Flang][OpenMP] Compilation error when end single construct has a copyprivate clause #87214

Open ohno-fj opened 4 months ago

ohno-fj commented 4 months ago
Version of flang-new : 19.0.0(cbcdf126ccc774c063b5d5140c1393ff5305dded)/AArch64

Compilation error occurs when end single construct has a copyprivate clause.

Compilation terminates normally in the following cases:

The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

omp30_example_a_37_01_22.f90:

program main
  REAL A, B
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE (A,B)
  print *,'pass'
end program main
$ flang-new -fopenmp omp30_example_a_37_01_22.f90
error: Semantic errors in omp30_example_a_37_01_22.f90
./omp30_example_a_37_01_22.f90:7:31: error: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context
  !$OMP END SINGLE COPYPRIVATE (A,B)
                                ^
./omp30_example_a_37_01_22.f90:7:33: error: COPYPRIVATE variable 'b' is not PRIVATE or THREADPRIVATE in outer context
  !$OMP END SINGLE COPYPRIVATE (A,B)
                                  ^
$
$ export OMP_NUM_THREADS=1; gfortran -fopenmp omp30_example_a_37_01_22.f90; ./a.out
 pass
$
$ export OMP_NUM_THREADS=1; ifort -qopenmp -diag-disable=10448 omp30_example_a_37_01_22.f90; ./a.out
 pass
$

omp30_example_a_37_01_222.f90:

program main
  REAL A, B
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE  ! COPYPRIVATE(A,B)
  print *,'pass'
end program main

omp30_example_a_37_01_223.f90:

program main
  REAL A, B
!$OMP THREADPRIVATE(A,B)
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE(A,B)
  print *,'pass'
end program main

omp30_example_a_37_01_224.f90:

program main
  REAL A, B
!$OMP PARALLEL
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE  COPYPRIVATE(A,B)
!$OMP END PARALLEL
  print *,'pass'
end program main
llvmbot commented 4 months ago

@llvm/issue-subscribers-openmp

Author: None (ohno-fj)

``` Version of flang-new : 19.0.0(cbcdf126ccc774c063b5d5140c1393ff5305dded)/AArch64 ``` Compilation error occurs when `end single` construct has a `copyprivate` clause. Compilation terminates normally in the following cases: - Delete the `COPYPRIVATE` clause, or (omp30_example_a_37_01_222.f90) - Add the following before the assignments A and B, or (omp30_example_a_37_01_223.f90) ``` !$OMP THREADPRIVATE(A,B) ``` - Add `PARALLEL` construct (omp30_example_a_37_01_224.f90) The following are the test program, Flang-new, Gfortran and ifort compilation/execution result. omp30_example_a_37_01_22.f90: ```fortran program main REAL A, B A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE COPYPRIVATE (A,B) print *,'pass' end program main ``` ``` $ flang-new -fopenmp omp30_example_a_37_01_22.f90 error: Semantic errors in omp30_example_a_37_01_22.f90 ./omp30_example_a_37_01_22.f90:7:31: error: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context !$OMP END SINGLE COPYPRIVATE (A,B) ^ ./omp30_example_a_37_01_22.f90:7:33: error: COPYPRIVATE variable 'b' is not PRIVATE or THREADPRIVATE in outer context !$OMP END SINGLE COPYPRIVATE (A,B) ^ $ ``` ``` $ export OMP_NUM_THREADS=1; gfortran -fopenmp omp30_example_a_37_01_22.f90; ./a.out pass $ ``` ``` $ export OMP_NUM_THREADS=1; ifort -qopenmp -diag-disable=10448 omp30_example_a_37_01_22.f90; ./a.out pass $ ``` omp30_example_a_37_01_222.f90: ```fortran program main REAL A, B A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE ! COPYPRIVATE(A,B) print *,'pass' end program main ``` omp30_example_a_37_01_223.f90: ```fortran program main REAL A, B !$OMP THREADPRIVATE(A,B) A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE COPYPRIVATE(A,B) print *,'pass' end program main ``` omp30_example_a_37_01_224.f90: ```fortran program main REAL A, B !$OMP PARALLEL A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE COPYPRIVATE(A,B) !$OMP END PARALLEL print *,'pass' end program main ```
llvmbot commented 4 months ago

@llvm/issue-subscribers-flang-frontend

Author: None (ohno-fj)

``` Version of flang-new : 19.0.0(cbcdf126ccc774c063b5d5140c1393ff5305dded)/AArch64 ``` Compilation error occurs when `end single` construct has a `copyprivate` clause. Compilation terminates normally in the following cases: - Delete the `COPYPRIVATE` clause, or (omp30_example_a_37_01_222.f90) - Add the following before the assignments A and B, or (omp30_example_a_37_01_223.f90) ``` !$OMP THREADPRIVATE(A,B) ``` - Add `PARALLEL` construct (omp30_example_a_37_01_224.f90) The following are the test program, Flang-new, Gfortran and ifort compilation/execution result. omp30_example_a_37_01_22.f90: ```fortran program main REAL A, B A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE COPYPRIVATE (A,B) print *,'pass' end program main ``` ``` $ flang-new -fopenmp omp30_example_a_37_01_22.f90 error: Semantic errors in omp30_example_a_37_01_22.f90 ./omp30_example_a_37_01_22.f90:7:31: error: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context !$OMP END SINGLE COPYPRIVATE (A,B) ^ ./omp30_example_a_37_01_22.f90:7:33: error: COPYPRIVATE variable 'b' is not PRIVATE or THREADPRIVATE in outer context !$OMP END SINGLE COPYPRIVATE (A,B) ^ $ ``` ``` $ export OMP_NUM_THREADS=1; gfortran -fopenmp omp30_example_a_37_01_22.f90; ./a.out pass $ ``` ``` $ export OMP_NUM_THREADS=1; ifort -qopenmp -diag-disable=10448 omp30_example_a_37_01_22.f90; ./a.out pass $ ``` omp30_example_a_37_01_222.f90: ```fortran program main REAL A, B A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE ! COPYPRIVATE(A,B) print *,'pass' end program main ``` omp30_example_a_37_01_223.f90: ```fortran program main REAL A, B !$OMP THREADPRIVATE(A,B) A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE COPYPRIVATE(A,B) print *,'pass' end program main ``` omp30_example_a_37_01_224.f90: ```fortran program main REAL A, B !$OMP PARALLEL A=1.0 B=2.0 !$OMP SINGLE !READ (11) A,B !$OMP END SINGLE COPYPRIVATE(A,B) !$OMP END PARALLEL print *,'pass' end program main ```
luporl commented 1 day ago

95799 was reverted. This issue should be fixed by https://github.com/llvm/llvm-project/pull/101009 now.