Open
Description
Testing SPEC Accel OMP with Flang highlighted this particular bug. When using OpenMP target variables in an openmp pragma - if we add "-g" to the compilation line, then the debugging information has issues and causes a compilation crash.
Reproducing example:
variable.f90:
MODULE VARIABLE_MOD
IMPLICIT NONE
INTEGER :: &
NX, NY, NZ
!$omp declare target(NX,NY,NZ)
END MODULE VARIABLE_MOD
filter.f90:
MODULE filter
USE variable_mod
IMPLICIT NONE
END MODULE
break.f90:
MODULE break
USE filter_mod
IMPLICIT NONE
CONTAINS
SUBROUTINE crash (field )
REAL :: field(:,:,:)
REAL :: fieldsum
INTEGER :: &
I, J, K
!$omp target map(tofrom: fieldsum)
!$omp teams reduction(+:fieldsum)
!$omp distribute parallel do reduction(+:fieldsum)
DO K = 1, NX
!$omp simd reduction(+:fieldsum)
DO J = 1, NY
fieldsum = fieldsum + ( ( field(1,J,K)))
END DO
END DO
!$omp distribute parallel do reduction(+:fieldsum)
DO J = 1, NY
!$omp simd reduction(+:fieldsum)
DO I = 1, NZ
fieldsum = fieldsum + ( ( field(I,J,1)))
END DO
END DO
!$omp end teams
!$omp end target
END SUBROUTINE crash
END MODULE break
Using a recent Flang build:
scamp@genx4:/local/home/scamp/TEST$ flang --version
flang version 21.0.0git (https://github.com/llvm/llvm-project d06e9ce1dd69d53a2a2afd06c027ca8af87a7d7e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /proj/nv/llvm/Linux_x86_64/llvm-5541/bin
Build config: +assertions
scamp@genx4:/local/home/scamp/TEST$ flang -fopenmp -g variable.f90 -c
scamp@genx4:/local/home/scamp/TEST$ flang -fopenmp -g filter.f90 -c
scamp@genx4:/local/home/scamp/TEST$ flang -fopenmp -g break.f90 -c
conflicting debug info for argument
#dbg_declare(ptr %12, !56, !DIExpression(), !53)
!52 = !DILocalVariable(name: "ny", arg: 13, scope: !39, file: !3, line: 5, type: !8)
!56 = !DILocalVariable(name: "ny", arg: 13, scope: !39, file: !3, line: 4, type: !8)
error: failed to create the LLVM module
Compiling without "-g" leads to no issues. NVHPC and GCC 14 handle this correctly:
NVHPC:
scamp@genx4:/local/home/scamp/TEST$ nvfortran -mp -g variable.f90 -c
scamp@genx4:/local/home/scamp/TEST$ nvfortran -mp -g filter.f90 -c
scamp@genx4:/local/home/scamp/TEST$ nvfortran -mp -g break.f90 -c
scamp@genx4:/local/home/scamp/TEST$
GCC:
scamp@genx4:/local/home/scamp/TEST$ gfortran -fopenmp -g variable.f90 -c
scamp@genx4:/local/home/scamp/TEST$ gfortran -fopenmp -g filter.f90 -c
scamp@genx4:/local/home/scamp/TEST$ gfortran -fopenmp -g break.f90 -c
scamp@genx4:/local/home/scamp/TEST$