julialinearalgebra / blis.jl Goto Github PK
View Code? Open in Web Editor NEWThis repo plans to provide a low-level Julia wrapper for BLIS typed interface.
License: BSD 3-Clause "New" or "Revised" License
This repo plans to provide a low-level Julia wrapper for BLIS typed interface.
License: BSD 3-Clause "New" or "Revised" License
When I install BLIS.jl with julia 1.7.3, it gives BLIS v0.2.0 and blis_jll v0.8.1, despite there being more recent updates to the package. In particular, I'm also getting the crash fixed in #12
I think this commit: f805070 might have bumped the version down by accident so Pkg.jl automatically installs an older version. I had to do dev BLIS
to work around this.
▶ testjulia1 % julia --project=@.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.3 (2022-05-06)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(@v1.7) pkg> activate .
Activating new project at `~/Sandboxes/testjulia1`
(testjulia1) pkg> add BLIS
Updating registry at `~/.julia/registries/General.toml`
Resolving package versions...
Updating `~/Sandboxes/testjulia1/Project.toml`
[32f2db32] + BLIS v0.2.0
Updating `~/Sandboxes/testjulia1/Manifest.toml`
[32f2db32] + BLIS v0.2.0
[692b3bcd] + JLLWrappers v1.4.1
[21216c6a] + Preferences v1.3.0
[1d63c593] + LLVMOpenMP_jll v14.0.4+0
[6136c539] + blis_jll v0.8.1+3
etc.
(the version numbers for BLIS and blis_jll are wrong)
This runs in the base environment in a new Julia session:
| | |_| | | | (_| | | Version 1.7.1 (2021-12-22)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> n = 1000; a = fill(1., n, n); a*a;
However:
julia> using BLIS
[ Info: blis_jll yields BLIS installation: ~/.julia/artifacts/567e1b2234ebc730bc16e33871144bf9b561f1fa/lib/libblis.4.0.0.dylib.
julia> n = 1000; a = fill(1., n, n); a*a;
signal (10): Bus error: 10
in expression starting at REPL[4]:1
jl_system_image_data at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
Allocations: 12825733 (Pool: 12821375; Big: 4358); GC: 13
[1] 4388 bus error julia
To improve visibility and maintainability, would you be comfortable moving this repo to https://github.com/JuliaLinearAlgebra ownership?
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
It would be great to use the same mechanism that MKL.jl uses now, and leverage libblastrampoline.
https://github.com/JuliaLinearAlgebra/MKL.jl/blob/master/src/MKL.jl
cf. discussions at the end of #20
Simple reproducer:
julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, haswell)
(tmp) pkg> st -m BLIS blis_jll
Status `/tmp/Manifest.toml`
[32f2db32] BLIS v0.2.0
[6136c539] blis_jll v0.8.1+0
julia> using BenchmarkTools, BLIS
[ Info: blis_jll yields BLIS installation: /home/mose/.julia/artifacts/3bd06aa4f9939a35f5cb53773bd177f94ec99078/lib/libblis.so.
julia> @benchmark BLIS.BLASInterface.axpy!(a, x, y) setup=(T=Float32; N=100; a=randn(T); x=randn(T, N); y=randn(T, N)) evals=1
GC error (probable corruption) :
Allocations: 21278104 (Pool: 21271094; Big: 7010); GC: 26
!!! ERROR in jl_ -- ABORTING !!!
0x7f70fc77f010: Root object: 0x7f7152ae4010 :: 0x7f7149ad2070 (bits: 3)
of type Task
0x7f70fc77f028: Root object: 0x7f71498c1760 :: 0x7f7149859b30 (bits: 3)
of type Module
0x7f70fc77f040: Root object: 0x7f714985a620 :: 0x7f714985a2b0 (bits: 3)
of type Array{Any, 1}
0x7f70fc77f058: Root object: 0x7f714e0ed220 :: 0x7f714985a380 (bits: 3)
of type UnionAll
0x7f70fc77f070: Root object: 0x7f714d451b60 :: 0x7f71498d7f50 (bits: 3)
of type Core.TypeMapEntry
0x7f70fc77f088: Root object: 0x7f714d5bbfa0 :: 0x7f71498d7f50 (bits: 3)
of type Core.TypeMapEntry
0x7f70fc77f0a0: Root object: 0x7f714b87b220 :: 0x7f71498d7f50 (bits: 3)
of type Core.TypeMapEntry
# Continues a _huge_ wall of errors
Perhaps some variables shared with the library aren't rooted correctly?
Thanks for putting together this package.
I wanted to check that you were aware that the 'C'
("Conjugate Transpose) option when applied to real matrices has the same behaviour as the 'N'
("No Transpose") option, and when applied to complex matrices, it is the same as just conjugating the entries but without transpose.
My expectation follows from Reference BLAS notes: http://www.netlib.org/blas/blasqr.pdf
and here: http://www.math.utah.edu/software/lapack/lapack-blas/zgemm.html
I guess the reason for the behaviour is clear from the definition in types.jl
:
char_to_trans = Dict( 'N' => BLIS_NO_TRANSPOSE,
'n' => BLIS_NO_TRANSPOSE,
'T' => BLIS_TRANSPOSE,
't' => BLIS_TRANSPOSE,
'C' => BLIS_CONJ_NO_TRANSPOSE,
'c' => BLIS_CONJ_NO_TRANSPOSE )
Here is a MWE.
A = Float64[1. 2.; 3. 4.]
B = Float64[5. 6.; 7. 8.]
C = zeros(Float64, 2, 2);
# # Note! : 'C' is equivalent to 'N', not 'T' on real matrices:
BLIS.BLASInterface.gemm!('N', 'C', 1.0, A, B, 1.0, copy(C)) == BLIS.BLASInterface.gemm!('N', 'N', 1.0, A, B, 1.0, copy(C))
# true
I was expecting
BLIS.BLASInterface.gemm!('N', 'C', 1.0, A, B, 1.0, copy(C)) == BLIS.BLASInterface.gemm!('N', 'T', 1.0, A, B, 1.0, copy(C))
# false : not expected
But now I see that LinearAlgebra.BLAS seems to follow the same convention too!
A = Matrix(UniformScaling(1.0+0.0im), 2, 2)
B = rand(ComplexF64, 2, 2);
@assert LinearAlgebra.BLAS.gemm('N','N',A,B) == B
@assert LinearAlgebra.BLAS.gemm('N','T',A,B) == transpose(B)
@assert LinearAlgebra.BLAS.gemm('N','C',A,B) == conj(B)
@assert LinearAlgebra.BLAS.gemm('N','C',A, Matrix(B')) == transpose(B)
Clarification welcome!
Platform: macOS and some Linux
Problem: multiplying A & B with at least one side generically-strided (e.g. A = view(Abase, 1:Mst:M, ...) | Mst>1
) yields all-0 results.
Possible cause: upstream (reproduced in C).
Status: investigating.
Workaround: as is stated in README.jl
, failed methods can be blacklisted to block from the LinearAlgebra
interface:
echo "gemm" > ~/.blis_jlbla_blacklist
# Trigger JIT reload.
touch $(find ~/.julia/packages/ -name "BLIS.jl" | tail -n 1)
Here is a MWE crash reproducer (fails at time of writing onJulia Version 1.10.0-DEV.1059
) extracted from init_test_mmul.jl
:
using LinearAlgebra
T = Float32
αr = 1.1
βr = 1.1
αu = T(αr)
βu = T(βr)
χlarge = 500
Alarge_base = rand(ComplexF64, χlarge, χlarge)
Blarge_base = rand(ComplexF64, χlarge, χlarge)
Clarge_base = rand(ComplexF64, χlarge, χlarge)
Alarge = zeros(T, χlarge, χlarge)
Blarge = zeros(T, χlarge, χlarge)
elconv = x -> real(x)
Alarge .= elconv.(Alarge_base)
Blarge .= elconv.(Blarge_base)
Clarge_gemm_cur = T.(elconv.(Clarge_base))
BLAS.gemm!('N', 'N', αu, Alarge, Blarge, βu, Clarge_gemm_cur)
X_jl = deepcopy(Clarge_gemm_cur)
using BLIS
Clarge_gemm_cur = T.(elconv.(Clarge_base))
BLAS.gemm!('N', 'N', αu, Alarge, Blarge, βu, Clarge_gemm_cur)
X_bl = deepcopy(Clarge_gemm_cur)
@assert all(X_jl .≈ X_bl)
LinearAlgebra
module.https://github.com/flame/blis/releases/tag/0.8.1
Likely would first require updating the build at https://github.com/JuliaPackaging/Yggdrasil/tree/master/B/blis
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.