Skip to content
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

Quadmath doesn't work on PPC #46

Open
vchuravy opened this issue Feb 23, 2020 · 8 comments · Fixed by #47
Open

Quadmath doesn't work on PPC #46

vchuravy opened this issue Feb 23, 2020 · 8 comments · Fixed by #47

Comments

@vchuravy
Copy link
Collaborator

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?

@simonbyrne
Copy link
Member

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?

@simonbyrne
Copy link
Member

Also is f128 on PPC match ieee754 binary128 or is it double-double?

@vchuravy
Copy link
Collaborator Author

f128 is always binary128 and double-double is ppc_fp128 (see https://llvm.org/docs/LangRef.html#floating-point-types)

@vchuravy
Copy link
Collaborator Author

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.

@simonbyrne
Copy link
Member

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:

@eval begin

simonbyrne added a commit that referenced this issue Feb 25, 2020
this should allow it to load (but not run) on machines where libquadmath is not present.

partially fixes #46.
simonbyrne added a commit that referenced this issue Feb 25, 2020
this should allow it to load (but not run) on machines where libquadmath is not present.

partially fixes #46.
@RalphAS
Copy link
Collaborator

RalphAS commented Mar 2, 2020

@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?

@vchuravy
Copy link
Collaborator Author

vchuravy commented Mar 2, 2020

Looking at my system GCC does provide a libquadmath.so /home/software/spack/gcc/8.3.0-xdjkb2mmftikxvoeeyaxtxcjtpltcgiz/lib64/libquadmath.so

@simonbyrne simonbyrne reopened this Mar 2, 2020
@simonbyrne
Copy link
Member

Current status is that the package should now load, but not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants