JuliaLinearAlgebra / Arpack.jl

Julia Wrappers for the arpack-ng Fortran library
https://arpack.julialinearalgebra.org/stable
MIT License
69 stars 29 forks source link

Arpack on M1 #134

Closed kosiakk closed 2 years ago

kosiakk commented 3 years ago

Hi I'm experimenting with Julia on MacBook Air M1 using nightly builds: Version 1.7.0-beta3 (2021-07-07)

Everything works well in stable version, which is cross-compiled on the fly using Apple's Rosetta tool. But the native build, it seems, requires native build of Arpack library:

julia> using Arpack

julia> eigs(rand(10,10))
ERROR: UndefVarError: libarpack not defined
Stacktrace:
 [1] naupd(ido::Base.RefValue{Int64}, bmat::String, n::Int64, evtype::String, nev::Int64, TOL::Base.RefValue{Float64}, resid::Vector{Float64}, ncv::Int64, v::Matrix{Float64}, ldv::Int64, iparam::Vector{Int64}, ipntr::Vector{Int64}, workd::Vector{Float64}, workl::Vector{Float64}, lworkl::Int64, info::Base.RefValue{Int64})
   @ Arpack ~/.julia/packages/Arpack/pLziT/src/libarpack.jl:297
 [2] aupd_wrapper(T::Type, matvecA!::Arpack.var"#18#28"{Matrix{Float64}}, matvecB::Arpack.var"#19#29", solveSI::Arpack.var"#20#30", n::Int64, sym::Bool, cmplx::Bool, bmat::String, nev::Int64, ncv::Int64, which::String, tol::Float64, maxiter::Int64, mode::Int64, v0::Vector{Float64}, check::Int64)
   @ Arpack ~/.julia/packages/Arpack/pLziT/src/libarpack.jl:134
 [3] _eigs(A::Matrix{Float64}, B::LinearAlgebra.UniformScaling{Bool}; nev::Int64, ncv::Int64, which::Symbol, tol::Float64, maxiter::Int64, sigma::Nothing, v0::Vector{Float64}, ritzvec::Bool, explicittransform::Symbol, check::Int64)
   @ Arpack ~/.julia/packages/Arpack/pLziT/src/Arpack.jl:243
 [4] _eigs
   @ ~/.julia/packages/Arpack/pLziT/src/Arpack.jl:79 [inlined]
 [5] #eigs#10
   @ ~/.julia/packages/Arpack/pLziT/src/Arpack.jl:51 [inlined]
 [6] eigs
   @ ~/.julia/packages/Arpack/pLziT/src/Arpack.jl:51 [inlined]
 [7] #eigs#9
   @ ~/.julia/packages/Arpack/pLziT/src/Arpack.jl:50 [inlined]
 [8] eigs(A::Matrix{Float64})
   @ Arpack ~/.julia/packages/Arpack/pLziT/src/Arpack.jl:50
 [9] top-level scope
   @ REPL[6]:1

arpak itself seems to be supported on MacOS and even uses Apple own compilation of BLAS/LAPACK (included in Accelerate) which should be able to use private matrix CPU instructions on M1.

It seems I was able to follow arpack-ng instructions and build it on my machine:

-- Install configuration: "Release"
-- Installing: /usr/local/lib/libarpack.2.1.0.dylib
-- Installing: /usr/local/lib/libarpack.2.dylib
-- Installing: /usr/local/lib/libarpack.dylib
-- Installing: /usr/local/lib/pkgconfig/arpack.pc
-- Installing: /usr/local/lib/libparpack.2.1.0.dylib
-- Installing: /usr/local/lib/libparpack.2.dylib
-- Installing: /usr/local/lib/libparpack.dylib
-- Installing: /usr/local/lib/pkgconfig/parpack.pc
-- Installing: /usr/local/include/arpack/debug.h
-- Installing: /usr/local/include/arpack/stat.h
-- Installing: /usr/local/include/arpack/arpackdef.h
-- Installing: /usr/local/include/arpack/arpackicb.h
-- Installing: /usr/local/lib/cmake/arpack-ng/arpack-ng-config.cmake
-- Installing: /usr/local/lib/cmake/arpack-ng/arpack-ng-config-version.cmake

but this library is still not seen by the Julia package. What should I try next?

mryodo commented 3 years ago

Exactly same behaviour. Does anybody have a solution?

andreasnoack commented 3 years ago

So I believe that the latest jll actually includes versions for M1, see https://github.com/JuliaBinaryWrappers/Arpack_jll.jl. However, the arpack-ng folks broke something between 3.5 and 3.6 that causes test failure here, see https://github.com/JuliaLinearAlgebra/Arpack.jl/issues/118, and nobody has had time to debug the issue.

ViralBShah commented 3 years ago

We actually do not have M1 binaries for Arpack. https://github.com/JuliaPackaging/Yggdrasil/blob/master/A/Arpack/build_tarballs.jl does not enable experimental builds which is what you need for the M1 binaries.

It's easy to enable that, but we need a version bump for that (since the new binaries will only work on Julia 1.6 and later) - and we are stuck on Arpack 3.5 for now.

giordano commented 3 years ago

Does anybody have a solution?

]add https://github.com/giordano/Arpack_jll.jl 
ViralBShah commented 2 years ago

This is now fixed with the latest Arpack_jll release 3.5.1.