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

Fixes for macos 11 and later (Big Sur onwards, including current Monterey) #43

Merged
merged 1 commit into from
Aug 7, 2022

Conversation

daviehh
Copy link
Contributor

@daviehh daviehh commented Nov 30, 2021

Attempting to fix #42: starting with Big Sur, release note, esp. 62986286, the system libraries are now removed to a cache and the corresponding dylib/frameworks used here are now no longer working: right now, using this package fails with

ERROR: LoadError: Accelerate framework not found at /System/Library/Frameworks/Accelerate.framework/Accelerate

This changes ccall to use function handle provided dlopen and dlsym.

Alternatively, just commenting out
https://github.com/JuliaMath/AppleAccelerate.jl/blob/1767883f594f25024cd41d46abe912611e8d0ce5/src/AppleAccelerate.jl#L6-L8

also works

@mcabbott
Copy link
Contributor

mcabbott commented Dec 2, 2021

Does this work locally, and on what machine?

I was hoping it might fix things on M1, but it does not seem to:

julia> AppleAccelerate.exp!(rand(100), rand(100))
ERROR: could not load symbol "vvexp":
invalid handle passed to dlsym()
Stacktrace:
 [1] dlsym(hnd::Ptr{Nothing}, s::String; throw_error::Bool)
   @ Base.Libc.Libdl ./libdl.jl:59
 [2] dlsym
   @ ./libdl.jl:57 [inlined]
 [3] get_fptr
   @ ~/.julia/packages/AppleAccelerate/VdzWL/src/AppleAccelerate.jl:12 [inlined]
 [4] exp!(out::Vector{Float64}, X::Vector{Float64})
   @ AppleAccelerate ~/.julia/packages/AppleAccelerate/VdzWL/src/Array.jl:30

julia> versioninfo()
Julia Version 1.8.0-DEV.1063
Commit aeab8a2a16 (2021-11-24 18:46 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin20.6.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)

@daviehh
Copy link
Contributor Author

daviehh commented Dec 2, 2021

@mcabbott I've tested this locally on julia 1.7.0 official lease binaries, both the native m1 and the intel running over rosetta works,

image

and ]test also passed

image

tested on macbook pro 14", macos 12.0.1 if this matters.

Incidentally, what does AppleAccelerate.libacc return on your end? And dlsym(AppleAccelerate.libacc, "vvexp") or dlsym(AppleAccelerate.libacc, :vvexp)

@mcabbott
Copy link
Contributor

mcabbott commented Dec 2, 2021

Ah that's great. These commands give me:

julia> AppleAccelerate.libacc
Ptr{Nothing} @0x00000001548093e0

julia> AppleAccelerate.dlsym(AppleAccelerate.libacc, "vvexp")
ERROR: could not load symbol "vvexp":
invalid handle passed to dlsym()
Stacktrace:
 [1] dlsym(hnd::Ptr{Nothing}, s::String; throw_error::Bool)
   @ Base.Libc.Libdl ./libdl.jl:59
 [2] dlsym(hnd::Ptr{Nothing}, s::String)
   @ Base.Libc.Libdl ./libdl.jl:57
 [3] top-level scope
   @ REPL[13]:1

julia> AppleAccelerate.dlsym(AppleAccelerate.libacc, :vvexp)
ERROR: could not load symbol "vvexp":

This is a 13" macbook pro with Big Sur 11.6.1. I will try with the official 1.7 in a bit. Same results from the official 1.7 binary. Perhaps the MacOS version matters?

@mcabbott
Copy link
Contributor

mcabbott commented Apr 18, 2022

I tried this again, M1 with MacOS 12.0.1, Julia 1.9.0-DEV.357, and now it seems to work.

However, the things I tried seem substantially slower than Julia's: because they were too small, I think.

# 1 thousand:

julia> @btime AppleAccelerate.log!($(rand(1000)), $(rand(1000)));
  8.472 μs (0 allocations: 0 bytes)

julia> @btime $(rand(1000)) .= log.($(rand(1000)));
  4.500 μs (0 allocations: 0 bytes)

# 1 million:

julia> @btime AppleAccelerate.log!($(rand(10^6)), $(rand(10^6)));
  1.519 ms (0 allocations: 0 bytes)

julia> @btime $(rand(10^6)) .= log.($(rand(10^6)));
  4.706 ms (0 allocations: 0 bytes)

@ViralBShah ViralBShah merged commit d79efa2 into JuliaLinearAlgebra:master Aug 7, 2022
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 this pull request may close these issues.

Can't install on Big Sur
3 participants