Search code examples
rlapackblasamd-processor

Using AMD BLIS / Lapack in R


I'm a lucky owner of AMD Ryzen 5950x processor. I use R for different calculations, so, earlier I had an Intel processor and a simpliest solution of starting using Intel BLAS / Lapack was a copying and renaming of some libraries (dll) in R directory. I have AOCL libraries installed on my computer, but still have no information how to get married R with AOCL. Could anyone explain what should I do or (it will be the best variant) someone has an instruction how to add AOCL libraries directly in R or, maybe, build R with these libraries?

Thank you.

P.S. I use gcc 12.2.0 on Windows 11. P.P.S. Do not say me to use OpenBLAS, because OpenBLAS has a big problem with freezing execution in parallel calculations, unfortunately.


Solution

  • Dmitriy's method didn't work for me (I didn't know where to find the omp libraries), but an updated version of this one (https://docs.google.com/presentation/d/1mrrE8nLx1Morsy0CSejSWSavatS-PyxNJMWSxZ5M_MI/edit#slide=id.gf104e05a_048) did:

    1. download AMD's AOCL and install (https://www.amd.com/en/developer/aocl.html#downloads)
    2. copy all the files in these directories (or wherever you installed AOCL):
    • C:\Program Files\AMD\AOCL-Windows\amd-blis\lib\LP64
    • C:\Program Files\AMD\AOCL-Windows\amd-libflame\lib\LP64

    to the folder where R's Rblas is. In my case:

    • C:\Program Files\R\R-4.3.1\bin\x64
    1. in that destination folder, rename these two to ...old (or similar) so you can easily change back:
    • Rblas.dll
    • Rlapack.dll
    1. use those two names (Rblas.dll and Rlapack.dll) to rename these two files which you've just put in the folder:
    • AOCL-LibBlis-Win-MT-dll.dll
    • AOCL-LibFlame-Win-MT-dll.dll
    1. download and install vcredist_x64.exe (https://aka.ms/vs/17/release/vc_redist.x64.exe) [note: I didn't need this step, as I already had MS Visual Studio installed]
    2. in Windows Settings, search for 'Edit environment variables for your account'; click 'New' in the dialogue box that appears (top panel); add:
    • OMP_NUM_THREADS

    and

    • x

    (where x is the number of cores) in the input boxes.

    1. restart and use R

    I don't know whether steps 5) and 6) are crucial but I did them and it worked. I have a AMD Ryzen 9 3900X with 12 cores and 24 threads. For x (step 6), I used the number of cores (=12), as it was actually slower when I tried with the number of threads. The explanation seems to be here: https://illposed.net/r-on-linux.html.

    I haven't done any speed testing but, at the times all cores are activated, it seems to be about 30% faster than it was before.