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 result from a reduction with a branching operator on Julia 1.12 with --check-bounds=yes #678
With the GPUArrays 12 port (#665), == between two equal 64×64 oneArrays returns false. This only happens on Julia 1.12 and with bounds checking enabled, which Pkg.test does by default. It makes the strided reductions testset in test/array.jl:223 fail on 1.12. CI only tests 1.10 and 1.13, so it doesn't show up there.
GPUArrays' == reduces over a named tuple of two Bools (one tracking missing, one the result), and its reducer branches on the missing flag. Reduced:
using oneAPI
A =rand(Int32(1):Int32(4), 64, 64); dA =oneArray(A); dB =oneArray(A)
init = (; is_missing=false, is_equal=true)
mapper(a, b) = (; is_missing=false, is_equal=a == b)
branching(a, b) = (a.is_missing || b.is_missing) ? (; is_missing=true, is_equal=false) :
(; is_missing=false, is_equal=a.is_equal & b.is_equal)
branchless(a, b) = (; is_missing=a.is_missing | b.is_missing, is_equal=a.is_equal & b.is_equal)
@showmapreduce(mapper, branching, dA, dB; init) # is_equal = false with --check-bounds=yes on 1.12@showmapreduce(mapper, branchless, dA, dB; init) # is_equal = true@showmapreduce(mapper, branching, oneArray(ones(Int32, 4096)), oneArray(ones(Int32, 4096)); init) # 1-D: true
--check-bounds=yes
--check-bounds=auto
Julia 1.12.7
wrong (deterministic)
correct
Julia 1.13.1
correct
correct
Julia 1.10.12
correct
correct
Only 2-D inputs fail. 1-D vectors of 1 to 4096 elements are correct.
The missing-tracking mapper doesn't matter. Replacing the branching reducer with a branchless one fixes it.
It doesn't depend on AcceleratedKernels (0.5.2, 0.5.3 and 0.5.4 all fail) or GPUCompiler (2.13.0, 2.13.1 and 2.13.2 all fail).
The same code on CUDA.jl with Julia 1.12 and --check-bounds=yes is correct.
oneAPI's main branch (GPUArrays 11) isn't affected, but it uses different reduction kernels.
The SPIR-V path for this kernel seems the likely culprit, on Julia 1.12's LLVM 18 or in IGC.
Activity