LinearAlgebra Frontend
The first thing BLIS.jl provides is a linear algebra frontend which resembles BLAS functions very much akin to LinearAlgebra.BLAS.gemm!, but defined for both column-major and generic strided matrices (namely all strides(A)[1] >= 1). An example for direct computation of generic strided case could be:
using BLIS
A = rand(ComplexF64, 4, 4);
B = rand(ComplexF64, 4, 4);
C = ones(ComplexF64, 4, 4);
# Create matrix views. No memory copied!
wA = view(A, 1:2:4, 1:2:4);
wB = view(B, 1:2:4, 1:2:4);
wC = view(C, 1:2:4, 1:2:4);
# wA * wB' can be directly computed via:
sC = wA * wB';
# without reallocating wA or wB to other arrays as
# mul! is overriden to call BLIS within this module.
# One can also use the same gemm! as provided in
# LinearAlgebra.BLAS to compute this 2×2×2 product:
# wA*wB -> wC
BLIS.BLASInterface.gemm!('N', 'N', 1.0+0im, wA, wB, 1.0+0im, wC)
# Note that storage target can also be generic-strided.Mixed precision is also directly supported by this interface.
Testing LinearAlgebra Frontend
As the LinearAlgebra frontend overwrites Julia's Base methods, it's recommended to run tests before using. Currently level-3 tests are implemented within the package and can be invoked by:
using Pkg
Pkg.test("BLIS")
# or simply `]test BLIS`The testsuite is method-resolved and comes with a failure workaround. If failure occurs with a message like:
[ Info: `gemm` test failed. Consider adding it to ~/.blis_jlbla_blacklist.
BLAS level-3 LinearAlgebra interface: Test Failed at ...One can make the following blacklist to block the very failing method and use the rest:
echo "gemm" > ~/.blis_jlbla_blacklist
# Trigger JIT reload.
touch $(find ~/.julia/packages/ -name "BLIS.jl" | tail -n 1)BLIS.BLASInterface: Level-1
LinearAlgebra.BLAS.scal! — Functionscal!(n, α, x, incx)BLIS-based SCAL. This is the same as BLAS' ?scal.
LinearAlgebra.BLAS.blascopy! — Functionblascopy!(n, x, incx, y, incy)BLIS-based COPY. This is the same as BLAS' ?copy.
LinearAlgebra.axpy! — Functionaxpy!(α, x, y)BLIS-based AXPY.
LinearAlgebra.axpby! — Functionaxpby!(α, x, β, y)BLIS-based AXPBY.
BLIS.BLASInterface: Level-2
LinearAlgebra.BLAS.gemv! — Functiongemv!(tA, α, A, x, β, y)BLIS-based GEMV with strides support & mixed-precision.
LinearAlgebra.BLAS.hemv! — Functionhemv!(ul, α, A, x, β, y)BLIS-based HEMV with strides support & mixed-precision.
LinearAlgebra.BLAS.symv! — Functionsymv!(ul, α, A, x, β, y)BLIS-based SYMV with strides support & mixed-precision.
LinearAlgebra.BLAS.trmv! — Functiontrmv!(ul, tA, dA, A, b)BLIS-based TRMV with strides support & mixed-precision.
LinearAlgebra.BLAS.trsv! — Functiontrsv!(ul, tA, dA, A, b)BLIS-based TRSV with strides support & mixed-precision.
LinearAlgebra.BLAS.ger! — Functionger!(α, x, y, A)BLIS-based GER with strides support & mixed-precision.
LinearAlgebra.BLAS.her! — Functionher!(uplo, α, x, A)BLIS-based HER with strides support & mixed-precision.
LinearAlgebra.BLAS.syr! — Functionsyr!(uplo, α, x, A)BLIS-based SYR with strides support & mixed-precision.
BLIS.BLASInterface: Level-3
LinearAlgebra.BLAS.gemm! — Functiongemm!(tA, tB, α, A, B, β, C)BLIS-based GEMM with generic strides & mixed precision directly supported:
\[C = β C + α A^{tA} B^{tB}\]
LinearAlgebra.BLAS.hemm! — Functionhemm!(side, uplo, α, A, B, β, C)BLIS-based HEMM with generic strides & mixed precision directly supported. A expresses a Hermitian matrix with its uplo triangle.
LinearAlgebra.BLAS.symm! — Functionsymm!(side, uplo, α, A, B, β, C)BLIS-based SYMM with generic strides & mixed precision directly supported. A expresses a Symmetric matrix with its uplo triangle.
LinearAlgebra.BLAS.her2k! — Functionher2k!(uplo, tAB, α, A, B, β, C)BLIS-based HER2K with generic strides & mixed precision directly supported. Performs rank-2k update on Hermitian matrix C (expressed by uplo-triangle):
\[C = β C + (α A B^† + \bar α B A^†)^{tAB}\]
LinearAlgebra.BLAS.syr2k! — Functionsyr2k!(uplo, tAB, α, A, B, β, C)BLIS-based SYR2K with generic strides & mixed precision directly supported. Performs rank-2k update on Symmetric matrix C (expressed by uplo-triangle):
\[C = β C + (α A B^T + \bar α B A^T)^{tAB}\]
LinearAlgebra.BLAS.herk! — Functionherk!(uplo, tA, α, A, β, C)BLIS-based HERK with generic strides & mixed precision directly supported. Performs rank-k update on Hermitian matrix C (expressed by uplo-triangle).
LinearAlgebra.BLAS.syrk! — Functionsyrk!(uplo, tA, α, A, β, C)BLIS-based SYRK with generic strides & mixed precision directly supported. Performs rank-k update on Symmetric matrix C (expressed by uplo-triangle).
LinearAlgebra.BLAS.trmm! — Functiontrmm!(side, uplo, tA, dA, α, A, B)BLIS-based TRMM with generic strides & mixed precision directly supported.
LinearAlgebra.BLAS.trsm! — Functiontrsm!(side, uplo, tA, dA, α, A, B)BLIS-based TRSM with generic strides & mixed precision directly supported.