Linking Intel's Math Kernel Library (MKL) to R on Windows

前端 未结 3 821
抹茶落季
抹茶落季 2020-12-04 16:03

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

3条回答
  •  感情败类
    2020-12-04 16:35

    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.


    Method 2

    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.

提交回复
热议问题