Linear algebra and parallelized linear algebra (using BLAS)

Linux

The openBLAS threaded BLAS is installed on all the compute servers, while ACML's threaded BLAS is installed on the Linux cluster. These allow 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):
 
export OMP_NUM_THREADS=1
or in tcsh, "setenv OMP_NUM_THREADS 1".
 
On the Linux cluster, this is set by default but see the cluster instructions about modifying this if you want to use threaded BLAS.
 
In addition, the threaded openBLAS can conflict with R's foreach parallelization functionality and with R profiling via Rprof(), so users making use of these functionalities will want to restrict to a single thread as above. Or in the case of foreach, there are other ways to get around this.
 

Mac

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.