3.6 Configure Oracle R Distribution to Use MKL on the Client

Instructions for configuring Oracle R Distribution to use MKL on a Linux or Windows client.

With this simple configuration step, Oracle R Distribution dynamically uses MKL if it is installed on your system.

This topic contains these sections:

3.6.1 Enable MKL Support for Oracle R Distribution on a Linux Client

Follow these steps to enable MKL for Oracle R Distribution on a Linux Client.

  1. Install MKL. You can download MKL from the Intel® Math Kernel Library website.

    Note: To install MKL on your computer, you must have an MKL license.

  2. Add libmkl_rt.so, $RHOME/lib, and $ORACLE_HOME/lib to the LD_LIBRARY_PATH system environment variable. For example, in the Bash shell:

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:
                             /path_to/libmkl_rt.so:
                             ${RHOME}/lib:
                             ${ORACLE_HOME}/lib
    
  3. Start R and execute the Sys.BlasLapack function:

    Sys.BlasLapack()
         $vendor
         [1] "Intel Math Kernel Library (Intel MKL)"
         $nthreads
         [1] -1
    

The returned value of $vendor indicates that MKL has replaced the BLAS and LAPACK that are native to R.

The returned value of nthreads indicates the number of threads to be used by MKL. By default all available threads are used ($nthreads= -1).

3.6.1.1 Modifying the Number of Threads for MKL on Linux

You can change the number of threads to be used by MKL by editing the system environment variable MKL_NUM_THREADS. For example, the following statement in the Bash shell, causes MKL to use 3 threads:

export MKL_NUM_THREADS=3

After setting MKL_NUM_THREADS to 3, the output of Sys.BlasLapack shows a value of 3 for $nthreads.

R> Sys.BlasLapack()
     $vendor
     [1] "Intel Math Kernel Library (Intel MKL)"
     $nthreads
     [1] 3

3.6.2 Enable MKL Support for Oracle R Distribution on a Windows Client

Follow these steps to enable MKL for Oracle R Distribution on a Windows client (64-bit).

  1. Install MKL. You can download MKL from the Intel® Math Kernel Library website:

    Note: To install MKL on your computer, you must have an MKL license.

  2. Add the location of libOrdBlasLoader.dll and mkl_rt.dll to the PATH system environment variable.

    Note:

    In a typical installation of Oracle R Distribution, libOrdBlasLoader.dll is located in the R home directory:

    C:\Program Files\R\R-version\bin\x64
    

    In a full installation of MKL 11.1, mkl_rt.dll is located in the Intel MKL Composer XE directory:

    C:\Program Files (x86)\Intel\Composer XE 2013 SP
  3. Start R and execute the Sys.BlasLapack function:

    R> Sys.BlasLapack()
         $vendor
         [1] "Intel Math Kernel Library (Intel MKL)"
         $nthreads
         [1] -1
    

The returned value of $vendor indicates that MKL has replaced the BLAS and LAPACK that are native to R.

The returned value of nthreads indicates the number of threads to be used by MKL. By default all available threads are used ($nthreads= -1).

3.6.2.1 Modify the Number of Threads for MKL on Windows

You can change the number of threads to be used by MKL by editing the system environment variable MKL_NUM_THREADS.

If MKL_NUM_THREADS does not exist, then you must create it as described in:

After setting MKL_NUM_THREADS to 3, the output of Sys.BlasLapack shows a value of 3 for $nthreads.

R> Sys.BlasLapack()
     $vendor
     [1] "Intel Math Kernel Library (Intel MKL)"
     $nthreads
     [1] 3