You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong results for overflowing Int16 arithmetic in a reduction kernel #670
On an Iris Xe (i7-1165G7), a reduction of abs2 over Complex{Int16} values gives wrong results when abs2 overflows Int16, in AcceleratedKernels' generic mapreducedim! kernel (the one used for sources without strides). Julia's IR is correct (wrapping mul i16/add i16 feeding llvm.smax.i16), so this looks like a miscompile further down, in the SPIR-V translation or IGC.
GPUArrays 12's testsuite hit it (reductions/mapreducedim!, Base.mapreducedim!(abs2, max, R, adjoint(A)) with Complex{Int16}). GPUArrays 12.0.1 keeps those values small.
using oneAPI
functioncheck(label, gen, f)
bad =0for _ in1:50
A =gen()
R0 =zeros(Int16, 1, 3)
mk = A ->view(permutedims(A), [1, 2, 3, 4], :) # not strided: AK's generic kernel
c = Base.mapreducedim!(f, max, copy(R0), mk(A))
g =Array(Base.mapreducedim!(f, max, oneArray(R0), mk(oneArray(A))))
c == g || (bad +=1)
endprintln(rpad(label, 30), bad, "/50")
endfunctionmain()
small = () ->complex.(rand(Int16(-100):Int16(100), 3, 4), rand(Int16(-100):Int16(100), 3, 4))
full = () ->rand(Complex{Int16}, 3, 4)
check("small abs2", small, abs2)
check("full abs2", full, abs2)
check("full re*re", full, x ->real(x) *real(x))
check("full re*re+im*im", full, x ->real(x) *real(x) +imag(x) *imag(x))
check("full re*im", full, x ->real(x) *imag(x))
endmain()
small abs2 0/50
full abs2 50/50
full re*re 0/50
full re*re+im*im 49/50
full re*im 0/50
Hand-written @oneapi kernels with the same arithmetic (max over abs2 of Complex{Int16} loaded from a 2D array, with the seed passed as an argument or as a constant) compute the right result, so I couldn't reduce it below AK's kernel yet.
oneAPI 2.9.2 and the GPUArrays 12 port (#665), AcceleratedKernels 0.5.1, Julia 1.12.7 and 1.13.
Activity