Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

Technical Solutions

How can I set MATLAB 7.3 (R2006b) to run the Intel BLAS in multi-threaded mode, and what is the associated performance improvement?


Date Last Modified: 03 Apr 2009
Solution ID:   1-34HE9M
Product:   MATLAB
Reported in Release:   R2006b
Platform:   All Platforms
Operating System:   All OS
 

Subject:

How can I set MATLAB 7.3 (R2006b) to run the Intel BLAS in multi-threaded mode, and what is the associated performance improvement?

Problem Description:

I have a PC that runs on a multi-core processor, and I would like one session of MATLAB to take advantage of the multiple processors.

Solution:

For MATLAB 7.3 (R2006b) and previous releases:

MATLAB is a single threaded application. However, multiple processors can be utilized by the BLAS (Basic Linear Algebra Subroutines) if the BLAS version being used supports multi-threading. In this case, significant performance improvement may be observed when running linear algebra intensive applications. This can be achieved on MATLAB 7.3 (R2006b) for both the Intel and AMD family of multiple core processors.

In order to enable BLAS multi-threading, the environment variables for the BLAS need to be set before running MATLAB. The method for doing this is different for each operating system.

On Windows XP, the environment variables can be set using the following steps:

1. Right click on “My Computer” and select “Properties”.
2. Click on the “Advanced” tab.
3. Click on the “Environment Variables” button.
4. Create or edit the following "System variables":


Variable Value
---------- -------
BLAS_VERSION mkl.dll (for Intel® BLAS)
OMP_NUM_THREADS 2
On Linux machines, the environment variables can be set using the “setenv” or “export” commands:

setenv BLAS_VERSION libmkl.so:libguide.so
setenv OMP_NUM_THREADS 2
or

export BLAS_VERSION=libmkl.so:libguide.so
export OMP_NUM_THREADS=2
Note: On the Linux OS, MATLAB has to be run with the "-nojvm" option for multi-threading to work.

After setting the appropriate environmental variables, start MATLAB and ensure that the BLAS version and the number of threads have been set correctly. To do this, execute the following code at the MATLAB Command Prompt:
getenv BLAS_VERSION

ans =

mkl.dll
getenv OMP_NUM_THREADS

ans =
2

As of MATLAB 7.4 (R2007a), MATLAB can be multi-threaded for certain applications. Multi-threading in MATLAB 7.4 (R2007a) can be set via MATLAB's preferences. For more information, see the Related Solution below, or enter the following at the MATLAB command prompt:

web([docroot,'/techdoc/matlab_env/f1-94809.html#bq35sqs'])

 

Related Solutions:

  Provide feedback to help us improve this solution!
Contact support
E-mail this page
Print this page