# 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!`

— Function`scal!(n, α, x, incx)`

BLIS-based SCAL. This is the same as BLAS' `?scal`

.

`LinearAlgebra.BLAS.blascopy!`

— Function`blascopy!(n, x, incx, y, incy)`

BLIS-based COPY. This is the same as BLAS' `?copy`

.

`LinearAlgebra.axpy!`

— Function`axpy!(α, x, y)`

BLIS-based AXPY.

`LinearAlgebra.axpby!`

— Function`axpby!(α, x, β, y)`

BLIS-based AXPBY.

`BLIS.BLASInterface`

: Level-2

`LinearAlgebra.BLAS.gemv!`

— Function`gemv!(tA, α, A, x, β, y)`

BLIS-based GEMV with strides support & mixed-precision.

`LinearAlgebra.BLAS.hemv!`

— Function`hemv!(ul, α, A, x, β, y)`

BLIS-based HEMV with strides support & mixed-precision.

`LinearAlgebra.BLAS.symv!`

— Function`symv!(ul, α, A, x, β, y)`

BLIS-based SYMV with strides support & mixed-precision.

`LinearAlgebra.BLAS.trmv!`

— Function`trmv!(ul, tA, dA, A, b)`

BLIS-based TRMV with strides support & mixed-precision.

`LinearAlgebra.BLAS.trsv!`

— Function`trsv!(ul, tA, dA, A, b)`

BLIS-based TRSV with strides support & mixed-precision.

`LinearAlgebra.BLAS.ger!`

— Function`ger!(α, x, y, A)`

BLIS-based GER with strides support & mixed-precision.

`LinearAlgebra.BLAS.her!`

— Function`her!(uplo, α, x, A)`

BLIS-based HER with strides support & mixed-precision.

`LinearAlgebra.BLAS.syr!`

— Function`syr!(uplo, α, x, A)`

BLIS-based SYR with strides support & mixed-precision.

`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}\]

`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.

`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.

`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}\]

`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}\]

`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).

`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).

`LinearAlgebra.BLAS.trmm!`

— Function`trmm!(side, uplo, tA, dA, α, A, B)`

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

`LinearAlgebra.BLAS.trsm!`

— Function`trsm!(side, uplo, tA, dA, α, A, B)`

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