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

BLIS.BLASInterface: Level-2

BLIS.BLASInterface: Level-3

LinearAlgebra.BLAS.gemm!Function
gemm!(tA, tB, α, A, B, β, C)

BLIS-based GEMM with generic strides & mixed precision directly supported:

\[C = β C + α A^{tA} B^{tB}\]

source
LinearAlgebra.BLAS.hemm!Function
hemm!(side, uplo, α, A, B, β, C)

BLIS-based HEMM with generic strides & mixed precision directly supported. A expresses a Hermitian matrix with its uplo triangle.

source
LinearAlgebra.BLAS.symm!Function
symm!(side, uplo, α, A, B, β, C)

BLIS-based SYMM with generic strides & mixed precision directly supported. A expresses a Symmetric matrix with its uplo triangle.

source
LinearAlgebra.BLAS.her2k!Function
her2k!(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}\]

source
LinearAlgebra.BLAS.syr2k!Function
syr2k!(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}\]

source
LinearAlgebra.BLAS.herk!Function
herk!(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).

source
LinearAlgebra.BLAS.syrk!Function
syrk!(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).

source
LinearAlgebra.BLAS.trmm!Function
trmm!(side, uplo, tA, dA, α, A, B)

BLIS-based TRMM with generic strides & mixed precision directly supported.

source
LinearAlgebra.BLAS.trsm!Function
trsm!(side, uplo, tA, dA, α, A, B)

BLIS-based TRSM with generic strides & mixed precision directly supported.

source