Using alternative BLAS and LAPACK linear algebra routines like Intel oneMKL on Windows, makes R work much faster

The default BLAS ( Basic Linear Algebra Subprogram) of R only uses single thread and relatively slower even on some operations in single thread compared to other available BLAS routines like oneMKL on single thread. Alternative BLAS routines can use multi threaded computing, which can give huge speed boost on multi core processors.

BLAS and LAPACK are located on \R\R-4.2.3\bin\x64\Rblas.dll and \R\R-4.2.3\bin\x64\Rlapack.dll, some alternative also need some additional .dll:s to work.

If you are using Windows, the easiest way to get intelMKL is to download Microsoft R Open and extract those files to your latest R version (just copy those .dll:s and libiomp5md.dll). Microsoft R Open is now abandoned project and the final version of it is equivalent to R 4.0.2 Those dll:s work on R 4.2.3 too, but there can be some problems.

The downsides are that every package that utilize paraller processing on default will work inefficiently when using multithreaded version BLAS, so you need manually set blas_set_num_threads(1) when using those packages and setting it back to blas_set_num_threads(14) when not using those packages.

Also the igraph -package doesn't work.

The speed boost is huge. I measure the speed with R benchmark 2.5 and got following results:

Default BLAS gives 17.89 total time and mean of 0.55 seconds.
Using MKL BLAS it gives 3.36 second total time and mean of 0.16 seconds.

So over five- or threefold increase on that benchmark.

You can also directly combile those DLL:s with oneMKL files from Intel site, but it is quite hard. You need Visual Studio and over 30 gigabytes worth of programs. I have done it, but it doesn't seem to give any benefits speed-wise. DLL sizes are little larger and blas_get_num_procs() function says 1 instead of the real number of procs and igraph -package still doesnt work. I wish there was some documentation how Microsoft compiled those MKL files for their R version.

You can also use OpenBLAS Building R 4.2 for Windows with OpenBLAS | Strange Attractors but I think that MKL is faster atleast on Intel processors.

There is also BLIS, it seems to be pretty fast also, but I have no idea how to get it working on Windows. GitHub - flame/blis: BLAS-like Library Instantiation Software Framework

On linux there are many guides for those, but for Windows I can barely find anything. I just cant figure out why R foundation hasn't made deal with openBLAS or BLIS and integrated it to the official R.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.