UlmBLAS.jl makes ulmBLAS the BLAS of Julia:
using Pkg; Pkg.add("UlmBLAS")
using LinearAlgebra, UlmBLAS
UlmBLAS.forward() # BLAS calls, lu and cholesky now go to ulmBLAS
UlmBLAS.forward() loads ulmBLAS into libblastrampoline on top of OpenBLAS: A * B, BLAS.gemm!, triangular solves, lu, cholesky, inv and \ then run on ulmBLAS, the rest of LAPACK stays with OpenBLAS. Prebuilt libraries come with ulmBLAS_jll for macOS on Apple silicon, Linux on x86-64 and, new in 0.2, Windows on x86-64.
The idea. ulmBLAS collects the open-source micro kernels of OpenBLAS and BLIS, measures them on a machine, and uses for each problem size the kernel and algorithm that is (by measurement) the fastest. For Apple M4/M5 ulmBLAS also has SME2 micro kernels: the one for double comes from BLIS, the ones for float and complex I contributed (tested on an M5 only). getrf and potrf are multithreaded with tasks on tiles, as in PLASMA, but in place: they never copy the whole matrix.
Benchmarks. cholesky! against Julia’s default OpenBLAS (full tables in the README), time of OpenBLAS / time of ulmBLAS on all cores:
| n | Apple M5 (10 cores) | Ice Lake (64 cores) | Zen 4 (96 cores) | i5-12500 (6 cores) |
|---|---|---|---|---|
| 100 | 1.07 | 0.89 | 0.99 | 0.78 |
| 200 | 0.83 | 1.24 | 1.92 | 1.43 |
| 500 | 1.17 | 2.24 | 1.97 | 1.41 |
| 1000 | 1.36 | 2.72 | 2.74 | 1.40 |
| 2000 | 1.68 | 2.20 | 2.54 | 1.10 |
| 4000 | 1.68 | 1.77 | 1.80 | 1.11 |
On 1 thread ulmBLAS is up to 3.9× faster on the M5 and 1.5× on Ice Lake, on par on Zen 4, but 0.8–0.9× on the i5-12500 (AVX2 dtrsm, open). For small matrices it is behind: n ≤ 200 on 1 thread on all four machines, n = 100 on all cores on three of them. My background is numerical methods for PDEs, where small matrices mattered less; the small-matrix paths in ulmBLAS are new and not as mature as the rest.
Help wanted. These four CPUs are about all I have access to, and choosing kernels by measurement only works where someone measures. Two ways to help:
- A few minutes: run
bench/potrf.jlof UlmBLAS.jl (cd UlmBLAS.jl/bench; julia --project=. -e "using Pkg; Pkg.instantiate()"; julia --project=. potrf.jl) and post the output here. That alone tells me where ulmBLAS stands on CPUs I cannot test. - More time: ulmBLAS has
make tune, which measures all candidate kernels on an idle machine and generates the selection table for that CPU (tune/README.md). Tables from measurements exist so far only for Zen 4, Ice Lake, Alder Lake and the M5; every other CPU uses a default table. If you have access to other x86-64 CPUs (Zen 2/3/5, recent Intel) or an Apple M4, and some time and interest in BLAS internals, I would be glad to hear from you: a pull request with a table, an issue, or an email to michael.lehn@uni-ulm.de. Arm CPUs without SME (Apple M1–M3, Graviton, Grace) are not covered bymake tuneyet; numbers frombench/potrf.jlhelp there too.
Also new in 0.2: UlmBLAS.mul! for matrices with arbitrary strides (e.g. every second row, no copies), now also for Int8/UInt8, all integer types, Float16 and BFloat16. Julia 1.10 or later.
The larger aim. UlmBLAS.jl is one half of making Julia the place where linear algebra written as a formula runs as fast as hand-tuned code. The other half is ulm.lam, an early research prototype: write inv(X' * inv(M) * X) * X' * inv(M) * y, declare what you know about the matrices, and it derives the BLAS/LAPACK calls an expert would write (here potrf, trsm, syrk, …), which then run on ulmBLAS.
Feedback, bug reports and benchmark numbers are welcome.