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

Julia and BLAS integer sizes differ on ARM #39436

Closed
matbesancon opened this issue Jan 28, 2021 · 12 comments
Closed

Julia and BLAS integer sizes differ on ARM #39436

matbesancon opened this issue Jan 28, 2021 · 12 comments
Labels
building Build system, or building Julia or its dependencies linear algebra Linear algebra

Comments

@matbesancon
Copy link
Contributor

julia> versioninfo()
Julia Version 1.7.0-DEV.398
Commit 5cd1e3e1f2* (2021-01-27 22:13 UTC)
Platform Info:
  OS: Linux (aarch64-unknown-linux-gnu)
  CPU: unknown
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, tsv110)


julia> using LinearAlgebra

julia> Int
Int64

julia> LinearAlgebra.BlasInt
Int32

This leads to bugs when calling BLAS functions

julia> v = rand(typemax(Int32) + 2);

julia> norm(v);
ERROR: InexactError: trunc(Int32, 2147483649)
Stacktrace:
  [1] throw_inexacterror(f::Symbol, #unused#::Type{Int32}, val::Int64)
    @ Core ./boot.jl:605
  [2] checked_trunc_sint
    @ ./boot.jl:627 [inlined]
  [3] toInt32
    @ ./boot.jl:664 [inlined]
  [4] Int32
    @ ./boot.jl:754 [inlined]
  [5] convert
    @ ./number.jl:7 [inlined]
  [6] RefValue
    @ ./refvalue.jl:8 [inlined]
  [7] convert
    @ ./refpointer.jl:104 [inlined]
  [8] cconvert
    @ ./essentials.jl:398 [inlined]
  [9] nrm2
    @ /buildworker/worker/package_linuxaarch64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/blas.jl:487 [inlined]
 [10] nrm2
    @ /buildworker/worker/package_linuxaarch64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/blas.jl:493 [inlined]
 [11] norm2(x::Vector{Float64})
    @ LinearAlgebra /buildworker/worker/package_linuxaarch64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:105
 [12] norm(itr::Vector{Float64}, p::Int64)
    @ LinearAlgebra /buildworker/worker/package_linuxaarch64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/generic.jl:627
 [13] norm(itr::Vector{Float64})
    @ LinearAlgebra /buildworker/worker/package_linuxaarch64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/generic.jl:625
@staticfloat
Copy link
Sponsor Member

This is because we do not use an ILP64 build of OpenBLAS on aarch64. I don't remember why, but this is purposeful: JuliaPackaging/Yggdrasil@ee0693f

@ViralBShah @Keno can either of you think of a reason why this is? Should we switch aarch64 BLAS to be ILP64 in the future?

@ViralBShah
Copy link
Member

I don't remember why - but it is purposeful. Could be as simple as perhaps openblas not supporting it back then. In fact, a lot of Yggdrasil packages have conditionals for this as well. Good to revisit it and clean it up.

@matbesancon
Copy link
Contributor Author

Should we try again to open a PR on Yggdrasil to build it? I can open it, but I doubt I'll of much use beyond "change random characters until CI says green"

@staticfloat
Copy link
Sponsor Member

staticfloat commented Jan 28, 2021

I doubt I'll of much use beyond "change random characters until CI says green"

I think you underestimate how useful that is.

@staticfloat
Copy link
Sponsor Member

If Yggdrasil builds well, the next step is to try out a Julia build with that new configuration; you'll need to:

That should be enough for you to locally test and see if it works. To actually merge this into Julia, we'd also need to:

  • Update the source tarball version we install if not using BB-built binaries.

  • Synchronize the Yggdrasil source build flags with what we use in Julia itself, in particular, the set of patches applied.

  • Update checksums by running make -f contrib/refresh_checksums.mk openblas.

@matbesancon
Copy link
Contributor Author

matbesancon commented Jan 28, 2021

add USE_BLAS64:=1 in this block

Why will this be necessary? If we are already on a 64-bits machine won't BLAS use 64 by default?

Edit: ok no I see this is an ARM-only block

@staticfloat
Copy link
Sponsor Member

The way the build system works, you need to set USE_BLAS64=1 explicitly on all platforms you want it to be the case on.

https://github.com/JuliaLang/julia/blob/master/deps/blas.mk#L43

@ViralBShah
Copy link
Member

FWIW, whenever I am ready to land a blastrampoline PR, we will be able to remove all that complex BLAS stuff in Make.inc. I'll be opening it soon-ish, but it will take a long time to merge.

Irrespective, if we can have 64-bit blas on aarch64, the work discussed here still needs to get done.

This was referenced Feb 15, 2021
@ViralBShah
Copy link
Member

Fixed in #39455.

@ViralBShah ViralBShah added linear algebra Linear algebra building Build system, or building Julia or its dependencies labels Feb 21, 2021
@ViralBShah
Copy link
Member

I suppose this should be left open until the functionality is actually merged.

@ViralBShah ViralBShah reopened this Feb 22, 2021
@dkarrasch
Copy link
Member

#39455 got merged. Can we close this?

@matbesancon
Copy link
Contributor Author

matbesancon commented Mar 5, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies linear algebra Linear algebra
Projects
None yet
Development

No branches or pull requests

4 participants