Skip to content

R-OneMKL/oneMKL

Repository files navigation

oneMKL

The oneMKL package establishes the connection between the R environment and Intel oneAPI Math Kernel Library (oneMKL), a prerequisite of using oneMKL.MatrixCal package. Specifically, oneMKL provides necessary header files and dynamic library files to R, and imports files from the packages mkl, mkl-include, and intel-openmp from Anaconda. The oneMKL and oneMKL.MatrixCal packages are only compatible with Windows and Linux operating systems due to Intel oneMKL limitations.

Installation

  1. To build the package from source, Windows users will need to have Rtools installed.

  2. You can install this package through our drat repository:

install.packages(c("oneMKL", "oneMKL.MatrixCal"), repos=c("https://cloud.r-project.org/", "https://R-OneMKL.github.io/drat"), type = "source")

Or, to get this package from github:

# install.packages('remotes')
remotes::install_github("R-OneMKL/oneMKL")
remotes::install_github("R-OneMKL/oneMKL.MatrixCal") # install oneMKL.MatrixCal to resolve `solve` issue

Speed-Up Performance for the Matrix Multiplication

You may get the following results by running inst/example/link_mkl_cblas.cpp.

Unit: milliseconds
    expr     min       lq      mean   median       uq     max neval
 default 22.2112 22.39580 24.531914 22.56680 25.16425 42.7146   100
    arma  2.1251  2.48840  3.397931  2.62585  2.77550 18.7268   100
   cblas  1.5832  1.74695  2.174011  1.89105  2.01385 13.1898   100
   
# This results are run on R-4.2.3 (Windows 11) with AMD 2990WX.

Hacking for Ubuntu

Since MKL .so files are unable to load in R with dyn.load, you will need to modify .Renviron to add the path to LD_LIBRARY_PATH with the following script.

# install oneMKL, then run below shell script
oneMKLPath=$(Rscript -e 'cat(system.file("lib", package = "oneMKL"))')
# append oneMKL package location to .Renviron
tee -a ~/.Renviron << EOF
LD_LIBRARY_PATH=${oneMKLPath}:\${LD_LIBRARY_PATH}
EOF

Hacking for CentOS and RedHat

dyn.load and .Renviron are not working for CentOS and RedHat, you need LD_PRELOAD to do the trick.

# install oneMKL, then run below shell script
oneMKLPath=$(Rscript -e 'cat(system.file("lib", package = "oneMKL"))')
# Use below command to start R or Rscript
LD_PRELOAD="${oneMKLPath}/libmkl_core.so:${oneMKLPath}/libmkl_intel_thread.so:${oneMKLPath}/libmkl_intel_lp64.so" R
LD_PRELOAD="${oneMKLPath}/libmkl_core.so:${oneMKLPath}/libmkl_intel_thread.so:${oneMKLPath}/libmkl_intel_lp64.so" Rscript

License

The oneMKL package is made available under the GPLv3 license.

The Intel MKL Library is licensed under the (Intel Simplified Software License)[https://www.intel.com/content/www/us/en/developer/articles/license/end-user-license-agreement.html], as described at (Intel MKL License FAQ)[https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html].

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •