I just searched around a bit for BLAS implementations and was amazed by the sheer amount of libraries around. Does someone know of a benchmark or otherwise rating of the various libraries?

  1. How easy they are to install.
  2. Performance.
  3. How easy they are to get to work with Octave or Matlab.

I realize all of these would depend on OS and hardware and version of the softwares. But any input would be welcome at this point.

  • 5
    $\begingroup$ It's a bit unclear what you mean, because the default linear algebra functionality of any language like octave/matlab is already provided by a blas library included with the distribution. Are you specifically looking for a GPU-accelerated drop-in replacement BLAS, or have I misunderstood? I believe matlab has the proprietary parallel computing toolbox for gpu linear algebra. $\endgroup$
    – Kirill
    Jan 25, 2017 at 20:19
  • $\begingroup$ Yes something like that. $\endgroup$ Jan 25, 2017 at 20:23
  • 5
    $\begingroup$ MATLAB already comes with high performance BLAS libraries, so there's no real point in replacing them. $\endgroup$ Jan 25, 2017 at 21:13
  • $\begingroup$ Maybe not worth it in terms of performance, but there is always a point in learning. $\endgroup$ Jan 25, 2017 at 21:34
  • 1
    $\begingroup$ Octave comes with internal reference BLAS and OpenBLAS. The problem is the default is the vanilla BLAS. You surely need to switch them for decent performance. $\endgroup$
    – Royi
    May 24, 2019 at 7:51

2 Answers 2


Among open-source BLAS, as far as I know, OpenBLAS (http://www.openblas.net/) is the best option. The website has a DGEMM benchmark, comparing against MKL (see below) and the reference Fortran BLAS. The library is threaded and written in C and assembly. For GPUs, there's clBLAS (https://github.com/clMathLibraries/clBLAS) that implements BLAS using OpenCL. Unfortunately I don't know of benchmarks for clBLAS.

If closed-source proprietary BLAS implementations are okay, Intel MKL is a good option for use on multi-core CPUs and Xeon-Phi accelerators. It has more than just BLAS - it also includes many LAPACK functions and FFT, for instance. NVIDIA's CuBLAS is an option for CUDA-enabled GPUs. cuBLAS is compared against MKL here http://developer.download.nvidia.com/compute/cuda/6_5/rel/docs/CUDA_6.5_Performance_Report.pdf.

I don't know about ClBLAS, but the others are pretty easy to install on Linux; the documentation is clear enough. As for interfacing with Octave/MATLAB, I don't know because I don't use them, but hopefully someone else can answer about that.

  • $\begingroup$ If you are working on an IBM Power8 platform there is a special version of the ESSL library which also contains basic offloading to CUDA for several BLAS calls. $\endgroup$ Feb 6, 2017 at 7:39
  • $\begingroup$ Oh I didn't know that, thanks. Anyway, I assumed we were looking at x86 systems since they're the most common; I don't know much about IBM's platform. $\endgroup$ Feb 6, 2017 at 18:41

MATLAB already comes with Intel MKL for its BLAS implementation. There's no reason to replace that.

As for using GPUs, if you make your array a gpuArray (to do that, just do gpuArray(A)), then you can use MATLAB's matrix multiplication and it will use optimized kernals from MAGMA to perform the computation. You can Google around to reason some people saying this outperforms CUBLAS by like 10%, but the comments are usually old (2013) and blablabla: it's fast enough that it's likely the best option if you're in MATLAB (though if you really want performance, you should look at Julia with CUBLAS, which will have a lower interop overhead and faster user-compiled kernals).

The reason why you won't find a BLAS implementation that "has both" is because the implementations have to be completely different to fully leverage the GPU, and so at that point they might as well be different libraries since the reason to bundle code is usually for some form of code reuse. You can try swapping out backend BLAS implementations in MATLAB to learn, but it likely won't cause a performance change it may give difficulties because it's very undocumented. That's just one problem among many with closed-source software. If you want to be able to modify every detail, swap BLAS libraries and libm implementations, etc., you may want to look into using an open-source software instead, which as above I'd recommend Julia (or you may be able to do this with Octave, though I don't know and will refer to whatever documentation they have).

  • $\begingroup$ It's actually very straight forward to swap BLAS/LAPACK libraries with Octave, since they're dynamically linked. In particular, you can use libnvblas.so (the CUDA toolkit drop in replacement BLAS library) with OpenBLAS as the backup for functions not in libnvblas.so. $\endgroup$ Dec 24, 2017 at 4:03
  • $\begingroup$ @BrianBorchers Have you gotten Octave to use github.com/CNugteren/CLBlast? My first attempt at this did not work. $\endgroup$
    – tholu
    Oct 19, 2018 at 12:53
  • $\begingroup$ No, I haven't tried working with this project- cuBLAS works adequately for me on my NVIDIA GPU. $\endgroup$ Oct 19, 2018 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.