Repository navigation
v0.10, CPU/POCL backend: ifelse on Complex (aggregate select) aborts in SPIR-V llc #760
Copy link
Copy link
Closed
Description
Yet another minimised issue observed at CliMA/Oceananigans.jl#5799
using KernelAbstractions
@kernel function pick!(out, x, y, flag)
i = @index(Global, Linear)
@inbounds out[i] = ifelse(flag[i], x[i], y[i])
end
n = 8
x = rand(ComplexF64, n); y = rand(ComplexF64, n); flag = rand(Bool, n); out = zeros(ComplexF64, n)
pick!(CPU(), 4)(out, x, y, flag; ndrange = n)gives an error like
Select values must have same type as select instruction!
%165 = select i1 %145, i32 %154, i32 %164
Select values must have same type as select instruction!
%233 = select i1 %210, i32 %222, i32 %232
in function _Z44gpu_solve_batched_tridiagonal_system_kernel_16CompilerMetadataI10StaticSizeI6_4__5_E12DynamicCheckvv7NDRangeILi2ES0_I6_1__1_ES0_I8_16__16_EvvEE13CLDeviceArrayI7ComplexI7Float64ELi3ELi1EES8_ISA_Li1ELi1EES8_ISA_Li3ELi1EESD_SC_SE_15RectilinearGridISA_8PeriodicSG_7Bounded28StaticVerticalDiscretizationI11OffsetArrayISA_Li1ESD_ESK_SK_SK_ESA_SA_SJ_ISA_Li1E12StepRangeLenISA_14TwicePrecisionISA_ESO_5Int64EESR_vvEv5TupleIJEE10ZDirection
LLVM ERROR: Broken function found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /var/lib/buildkite-agent/.julia/artifacts/b1f23ea20454ce8dbba12ceb574519da0e09d20b/bin/llc /tmp/jl_HObONaxYhg.bc -filetype=obj -o /tmp/jl_JeDQFgNOhM.spv -spirv-ext=+SPV_EXT_shader_atomic_float_add,+SPV_EXT_shader_atomic_float_min_max
1. Running pass 'Function Pass Manager' on module '/tmp/jl_HObONaxYhg.bc'.
2. Running pass 'Module Verifier' on function '@_Z44gpu_solve_batched_tridiagonal_system_kernel_16CompilerMetadataI10StaticSizeI6_4__5_E12DynamicCheckvv7NDRangeILi2ES0_I6_1__1_ES0_I8_16__16_EvvEE13CLDeviceArrayI7ComplexI7Float64ELi3ELi1EES8_ISA_Li1ELi1EES8_ISA_Li3ELi1EESD_SC_SE_15RectilinearGridISA_8PeriodicSG_7Bounded28StaticVerticalDiscretizationI11OffsetArrayISA_Li1ESD_ESK_SK_SK_ESA_SA_SJ_ISA_Li1E12StepRangeLenISA_14TwicePrecisionISA_ESO_5Int64EESR_vvEv5TupleIJEE10ZDirection'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 llc 0x0000000001dccf88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1 llc 0x0000000001dca454
2 libc.so.6 0x00007fc3c4233330
3 libc.so.6 0x00007fc3c428cb2c pthread_kill + 284
4 libc.so.6 0x00007fc3c423327e gsignal + 30
5 libc.so.6 0x00007fc3c42168ff abort + 223
6 llc 0x000000000076c599
7 llc 0x0000000001d127e8
8 llc 0x0000000001458192
9 llc 0x000000000139d340 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1120
10 llc 0x000000000139d5bc llvm::FPPassManager::runOnModule(llvm::Module&) + 44
11 llc 0x000000000139eddb llvm::legacy::PassManagerImpl::run(llvm::Module&) + 907
12 llc 0x000000000084f84e
13 llc 0x0000000000780a5c main + 1100
14 libc.so.6 0x00007fc3c42181ca
15 libc.so.6 0x00007fc3c421828b __libc_start_main + 139
16 llc 0x0000000000845dc6
Probably an upstream issue, more artifacts by the bot:
select_aggregate.ll: Standalone LLVM IR, no Julia involved, shaped like Julia's output withinsertvalueandextractvaluearound the select.llc select_aggregate2.ll -filetype=obj -o out.spvgives the exact same "Select values must have same type" error.select_aggregate2.ll: Same but loading and storing the aggregate directly. That variant segfaults insideSPIRVEmitIntrinsicsinstead. Its stack dump takes about two minutes to print because of symbolization, which is what made the run look hung.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
vchuravy commentedon Sep 10, 2026
cc: @maleadt
maleadt commentedon Sep 11, 2026
This is llvm/llvm-project#201417, which is part of LLVM 23, so we should rebuild PoCL. Problem is that LLVM 23 isn't supported, so this presumably needs a simple backport.
maleadt commentedon Sep 11, 2026
Wait, no. This isn't a crash during machine code emission from pocl, it's one during SPIR-V emission using SPIRV_LLVM_Backend? So in that case #761 should fix this already.
christiangnrd commentedon Sep 12, 2026
Is this resolved?
giordano commentedon Sep 12, 2026
Looks like it
Add regression test for ifelse on Complex values
Add regression test for ifelse on Complex values (#777)