Quadmath.jl
Quadmath.jl copied to clipboard
Quadmath doesn't work on PPC
On a Power9 machine:
julia> using DoubleFloats
[ Info: Precompiling DoubleFloats [497a8b3b-efae-58df-a0af-a86822472b78]
ERROR: LoadError: ccall: could not find function __floatsitf in library libgcc_s.so.1
Stacktrace:
[1] Quadmath.Float128(::Int32) at /home/vchuravy/.julia/packages/Quadmath/6EO4T/src/Quadmath.jl:144
[2] top-level scope at /home/vchuravy/.julia/packages/Quadmath/6EO4T/src/Quadmath.jl:271
[3] include at ./boot.jl:328 [inlined]
[4] include_relative(::Module, ::String) at ./loading.jl:1105
[5] include(::Module, ::String) at ./Base.jl:31
[6] top-level scope at none:2
[7] eval at ./boot.jl:330 [inlined]
[8] eval(::Expr) at ./client.jl:425
[9] top-level scope at ./none:3
in expression starting at /home/vchuravy/.julia/packages/Quadmath/6EO4T/src/Quadmath.jl:265
I found https://gcc.gnu.org/wiki/Ieee128PowerPC
In general it might be more reliable to use LLVM f128 support instead of doing target specific lowering in a package?
I agree it makes sense to switch to use LLVM support where available, since the hacks we have in place now are pretty cumbersome.
Does LLVM provide intrinsics for conversion, arithmetic etc?
Also is f128 on PPC match ieee754 binary128 or is it double-double?
f128 is always binary128 and double-double is ppc_fp128 (see https://llvm.org/docs/LangRef.html#floating-point-types)
So talking with @leios they way I would fix this is to define:
struct Float128
data::NTuple{2,Base.VecElement{Float64}}
end
function Float128(x::Float64)
y = Base.llvmcall(
$""
%2 = fpext double %0 to fp128
%3 = bitcast fp128 %2 to <2 x double>
ret <2 x double> %3
""", NTuple{2, VecElement{Float64}}, Tuple{Float64}, x)
return Float128(y)
end
Leave the target lowering up to LLVM to figure out. We might need to load the quadmath support with LD_GLOBAL.
I think the lowest hanging fruit is to make sure the package can load when libquadmath isn't present: we should be able to do that by removing the @eval here: https://github.com/JuliaMath/Quadmath.jl/blob/4f22e7f104aa019ec11b640089a20dd59c12ac24/src/Quadmath.jl#L271
@vchuravy I agree that in the long run we should generate fp128 IR where feasible. I tried that approach when I was working on the Windows ABI here without success. My recollection is that LLVM did not compile fp128 intrinsics correctly for Windows and some edge cases were suspect for Linux. I did not find much of a test suite for fp128 in LLVM or Clang, so I figured it was still WIP. That was about a year ago. (Note that on x86 LLVM compiles much fp128 IR into calls to the same libraries we are now using here.)
It looks like Clang 9 compiles for __float128 without complaint (but also without documentation); do you know if anyone does serious testing of it (particularly in Windows)? And is there an equivalent to libquadmath for Power9?
Looking at my system GCC does provide a libquadmath.so /home/software/spack/gcc/8.3.0-xdjkb2mmftikxvoeeyaxtxcjtpltcgiz/lib64/libquadmath.so
Current status is that the package should now load, but not work.