Using an alternative BLAS for R has several advantages, see e.g. https://cran.r-project.org/web/packages/gcbd/vignettes/gcbd.pdf.
Microsoft R Open https://mran.revolutionanalytics.com/documents/rro/installation/#sysreq is using Intel's MKL instead of the default Reference BLAS to speed up calculations.
My question is:
What would be the exact steps to link Intel's MKL library **manually to R**'s most recent version on Windows (https://cran.r-project.org/bin/windows/base/)?
UPDATE 20-07-2016: Here is very detailed description on how to build a OpenBLAS-based Rblas.dll for 64-bit R for Windows for R ≥ 3.3.0: http://www.avrahamadler.com/r-tips/build-openblas-for-windows-r64/
I was able to link R 3.6.0 with custom dlls you create using the builder. Basically you have to export the same symbols Rblas.dll
and Rlapack.dll
do. Start the Compiler 19.0 Update 4 for Intel 64 Visual Studio 2017 environment
command prompt:
Get the symbols:
dumpbin /exports Rblas.dll > Rblas_list
dumpbin /exports Rlapack.dll > Rlapack_list_R
Edit both files deleting the "header" and "footer" and have all the lines with the symbol names (ex.: 248 F7 00138CE0 dgeevx_
) be like dgeevx_
(only with the names).
Copy the builder
directory to somewhere in your pc and inside it run:
# blas links fine
nmake libintel64 export=..path..\Rblas_list name=Rblas
# save lapack errors in another list
nmake libintel64 export=..path..\Rlapack_list_R name=Rlapack 1> undefined_symbols_list
Edit undefined_symbols_list
keep only the names in each line and create a new
list with the difference
findstr /v /g:undefined_symbols_list Rlapack_list_R > Rlapack_list
nmake libintel64 export=..path..\Rlapack_list name=Rlapack
With dumpbin /dependents Rlapack.dll
, you can see that they depend on libiomp5md.dll
, which you can find inside the redist
folder in mkl installation.
This method uses more disk space, but it's simpler. Copy all the contents from inside these folders
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\redist\intel64\mkl
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\redist\intel64\compiler
to
C:\Program Files\R\R-3.6.1\bin\x64
Inside the destination folder, create 2 copies of mkl_rt.dll
and rename one of them Rblas.dll
and the other Rlapack.dll
replacing the originals and also keeping mkl_rt.dll
.