Linear algebra and parallelized linear algebra (using BLAS)

Linear algebra and parallelized linear algebra (using BLAS)


The openBLAS threaded BLAS is installed on all the compute servers, including the cluster. This allows parallelization of linear algebra routines, in particular any linear algebra done in R, via a mechanism known as threading.

In some cases using multiple threads can actually slow down a job, or more commonly, can give negligible speed-up. It's worth testing your job using a single thread vs. multiple threads to see what the speed-up is.

You can restrict your job to a single thread by setting the OMP_NUM_THREADS environment variable before starting your job. To restrict to a single thread, do the following at the command line (in bash):


or in tcsh, "setenv OMP_NUM_THREADS 1".

To enable openBLAS for R on your own Linux machine, see Section A.3 of the R Installation and Administration Manual.


The SCF Macs use the fast, threaded BLAS from Apple's Accelerate framework. To enable this on your own Mac, you can do the following to replace R's default BLAS with the Accelerate version. You'll need administrative privileges.

cd /Library/Frameworks/R.framework/Versions/Current/Resources/lib
mv libRblas.dylib libRblas.dylib.bak
ln -s /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/libBLAS.dylib libRblas.dylib

To change the number of threads used, follow the instructions above for Linux but use VECLIB_MAXIMUM_THREADS rather than OMP_NUM_THREADS.


To enable openBLAS with R on your own Windows machine, see here.