-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Float16 broken on Julia 1.9 (LLVM14) on Intel Sapphire Rapids #51686
Comments
Much simpler reproducer on 1.9.3: julia> Float16(Float32(4.0))
Float16(0.0)
julia> @code_llvm Float16(Float32(4.0)) ; @ float.jl:256 within `Float16`
define half @julia_Float16_138(float %0) #0 {
top:
%1 = fptrunc float %0 to half
ret half %1
} julia> @code_native Float16(Float32(4.0)) .text
.file "Float16"
.globl julia_Float16_171 # -- Begin function julia_Float16_171
.p2align 4, 0x90
.type julia_Float16_171,@function
julia_Float16_171: # @julia_Float16_171
; ┌ @ float.jl:256 within `Float16`
.cfi_startproc
# %bb.0: # %top
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
vcvtss2sh %xmm0, %xmm0, %xmm0
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Lfunc_end0:
.size julia_Float16_171, .Lfunc_end0-julia_Float16_171
.cfi_endproc
; └
# -- End function
.section ".note.GNU-stack","",@progbits But the LLVM IR looks legitimate. On a not too old nightly build (f066500) this works correctly: julia> Float16(Float32(4.0))
Float16(4.0)
julia> @code_llvm debuginfo=:none Float16(Float32(4.0)) ; Function Signature: (::Type{Float16})(Float32)
define half @julia_Float16_1174(float %"x::Float32") #0 {
top:
%0 = fptrunc float %"x::Float32" to half
ret half %0
} julia> @code_native debuginfo=:none Float16(Float32(4.0)) .text
.file "Float16"
.globl julia_Float16_1306 # -- Begin function julia_Float16_1306
.p2align 4, 0x90
.type julia_Float16_1306,@function
julia_Float16_1306: # @julia_Float16_1306
; Function Signature: (::Type{Float16})(Float32)
# %bb.0: # %top
#DEBUG_VALUE: Float16:x <- $xmm0
push rbp
mov rbp, rsp
vcvtss2sh xmm0, xmm0, xmm0
pop rbp
ret
.Lfunc_end0:
.size julia_Float16_1306, .Lfunc_end0-julia_Float16_1306
# -- End function
.type ".L+Core.Float16#1308",@object # @"+Core.Float16#1308"
.section .rodata,"a",@progbits
.p2align 3
".L+Core.Float16#1308":
.quad ".L+Core.Float16#1308.jit"
.size ".L+Core.Float16#1308", 8
.set ".L+Core.Float16#1308.jit", 140549906661152
.size ".L+Core.Float16#1308.jit", 0
.section ".note.GNU-stack","",@progbits |
It's an ABI issue ;) |
Is there concretely something that can be done to fix this on v1.9 with LLVM 14 or we have to live with the fact that series will be always broken but 1.10+ will work ok? |
Hey, look what I found in julia/src/llvm-demote-float16.cpp Lines 50 to 58 in bed2cd5
This section was revamped in Julia 1.10 to not have this always-false method based on compiler constants. I replaced the function with the one in 1.10 and it seems to be working. At least, the simple examples here are working; CSV.jl is still crashing during precompilation. |
https://discourse.julialang.org/t/julia-1-9-on-intel-sapphire-rapid-cpu-doesnt-work/118444 confirmed everything works in v1.10 and v1.11. Since it's unlikely there will be a new release in the v1.9 series at this point, I'm going to close this ticket |
Tracking down the cause of a segmentation fault on Sapphire Rapids #51482, I may have found the root issue. Float16 is broken on this platform, possibly due to bad LLVM output.
The issue does not occur with Julia 1.8 (LLVM 13) or Julia 1.10-beta3 (LLVM 15).
The text was updated successfully, but these errors were encountered: