https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121453
Bug ID: 121453
Summary: [OpenMP] 'omp simd' with 'collapse' – variable
'.count' uninitialized, but used as 'if (.iter.14 ==
.count.15)'
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: openmp, wrong-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
This shows up with the SPEC ACCEL testcase '455.seismic' by failing with nvptx
offload as:
libgomp: cuCtxSynchronize error: an illegal memory access was encountered
or in the debugger:
CUDA Exception: Warp Out-of-range Address
THis seems to be due to what is diagnosed by '-Wall':
warning: ‘.count.1179’ may be used uninitialized
Simplified example – compile with '-fopenmp' (and for the warning, add some
optimization level; depending on the code, -O3 or -O1 is enough).
Dump with '-fopenmp -O0':
unsigned int .count.34;
unsigned int .count.22;
if (.iter.33 == .count.34) goto <D.4885>; else goto
<D.4884>;
That is: '.count.34' is used in a condition but never actually
assigned any value.
* * *
Both .iter and .count are generated in 'omp_extract_for_data'.
BTW: I tried gfortran-7 – and is shows the same issue according to the omplower
tree dump.
* * *
! Simplified example
implicit none
double precision, allocatable, dimension(:,:,:) :: vv
integer :: NX, NY, NZ
integer :: k, j, i
NX = 5; NY = 5; NZ = 5
allocate (vv(NX,NY,NZ))
!$omp target teams distribute parallel do simd collapse(3)
! - simpler version: !$omp target simd collapse(3)
! - simplest version: !$omp simd collapse(3)
do k=1, NZ
do j=1, NY
do i=1, NX
vv(i,j,k) = 0.d0
enddo
enddo
enddo
end