R and BLAS Libraries

R uses BLAS (Basic Linear Algebra Subprograms) to perform many of its operations. There are several different implementations of BLAS each having different performance characteristics in different situations.

The default BLAS on the cluster is Atlas (Automatically Tuned Linear Algebra Software). The Atlas libraries on the cluster use a single thread to perform all operations.

If you suspect that your jobs would benefit from a multi-threaded BLAS library you can try OpenBLAS (which is already installed on the cluster). To do this you would set the dynamic library load path before you start R. For instance:

export LD_LIBRARY_PATH=/usr/lib/openblas-base
R --slave --vanilla -f my_r_script.r

These OpenBLAS libraries will use multiple threads for some operations. You can control how many threads OpenBLAS will use by setting the OPENBLAS_NUM_THREADS environment variable before starting your program.

export OPENBLAS_NUM_THREADS=4

If you use a lot of threads you should increase the number of cores you tell slurm that you job requires (or run your job with exclusive use of a compute node).

You can also download and compile other BLAS libraries in your own home directory and update the dynamic library to match.