https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129254
Bug ID: 129254
Summary: [OpenMP][amdgcn] kernel executes an invalid
instruction at -O1 (HSA_STATUS_ERROR_INVALID_ISA)
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: jvdelisle at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
The program below, compiled with -O1 -fopenmp for amdgcn offloading,
kills the kernel on the GPU:
libgomp: GCN fatal error: Asynchronous queue error
Runtime message: HSA_STATUS_ERROR_INVALID_ISA: The instruction set
architecture is invalid.
The process then hangs until it is killed. With core dumps enabled,
ROCr's GPU core dump writer gets SIGPIPE first and the process exits
with status 141 without a message; run it under "ulimit -c 0" to see
the error above.
It passes at -O0 and -O2, and at -O1 with -fexpensive-optimizations or
-ftree-slp-vectorize added. Giving those options only to the offload
compiler (-foffload-options=...) does not help. The failure is the
same with one team and one thread (OMP_NUM_TEAMS=1 OMP_THREAD_LIMIT=1)
and with a larger stack (GCN_STACK_SIZE=262144).
The offload compiler's optimized dump of the kernel at -O1 differs from
the one with -fexpensive-optimizations only in that a division and a
modulo in the loop scheduling code become one .DIVMOD. The assembly of
the parallel body, __m_MOD_s._omp_fn.1, then differs in frame layout
("local vars size" 0 vs 16, "callee save size" 3016 vs 4040) and
register assignment, so this looks like an amdgcn code generation
problem rather than bad GIMPLE.
Each of these makes the failure go away: dropping the read of the
assumed-shape dummy AS, declaring it explicit-shape AS(M), or using
"target parallel do" or "target teams distribute" instead of the
combined construct. Declaring it CONTIGUOUS does not. A C program
with the same loop body (malloc, memcpy, a VLA and free per iteration)
passed.
$ gfortran -O1 -fopenmp pr.f90 && (ulimit -c 0; ./a.out)
module m
implicit none
integer(8), parameter :: n = 4000
integer(8) :: r(n)
contains
subroutine s (ex, as, v, cc, m)
integer(8) :: m, ex(m), as(:)
integer(8), value :: v
character(len=*) :: cc
integer(8) :: i
!$omp target teams distribute parallel do map(to: ex, cc, as) &
!$omp& map(tofrom: r) firstprivate(v)
do i = 1, n
block
integer(8) :: exl(size (ex)), vl
character(len=len(cc)) :: ccl
exl = ex
vl = v
ccl = cc
vl = vl + i
ccl(1:1) = 'z'
r(i) = sum (exl) + sum (as) + vl + len (ccl)
end block
end do
end subroutine
end module
program p
use m
implicit none
integer(8) :: x(3), y(3), i
x = 1; y = 2
call s (x, y, 10_8, 'abc', 3_8)
do i = 1, n
if (r(i) /= 3 + 6 + 10 + i + 3) stop 1
end do
print *, 'OK'
end program
Configuration: x86_64-pc-linux-gnu host configured with
--enable-offload-targets=amdgcn-amdhsa, accel compiler configured with
--with-arch=gfx10-3-generic, device gfx1032 (Navi 23). Trunk
basepoints/gcc-17-6999-g8de88fb84e7 plus local gfortran patches; the
only one that changes code this program uses (the map of assumed-shape
dummies, PR128977) was switched off and the failure remained. Older
releases not checked.
Found while testing the DO CONCURRENT to OpenMP lowering (PR128590).