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

Technical Solutions

What is BLAS and how can I change the BLAS version MATLAB uses?


Date Last Modified: Friday, June 26, 2009
Solution ID:   1-18QUC
Product:   MATLAB
Reported in Release:   R12.1
Platform:   All Platforms
Operating System:   All OS
 

Subject:

What is BLAS and how can I change the BLAS version MATLAB uses?

Problem Description:

I would like to know how MATLAB uses the BLAS, and what I would do if I want to use a different version of BLAS.

Solution:

BLAS stands for Basic Linear Algebra Subroutines. It provides the key foundations for performing mathematical computations in MATLAB. Everything which works with vectors or matrices, from simple matrix-vector multiplication to solving large systems of linear equations, depends on the BLAS routines.

In some cases MATLAB will choose to use a version of BLAS different than one you may want or need to use. Each version is specifically optimized for a specific processor, but sometimes (for newer processors or various tasks) you may want to choose to use a different version of BLAS.

The way MATLAB works on selecting which BLAS to use is to first check the BLAS_VERSION environment variable. If the variable is defined, MATLAB will use the specified file. If it is not defined, MATLAB will use the information in $MATLABROOT\bin\$(ARCH)\blas.spec (where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB Command Prompt) to determine which version of our pre-shipped BLAS to load.

Hence if there is no BLAS_VERSION environmental variable on your system you may do the following: Edit blas.spec yourself to make your processor call any of the other MathWorks supplied BLAS in the bin\$(ARCH) directory.

To change the BLAS using the environmental variables, you need to set them. The method for doing this is different for each operating system.

On Windows XP, you can set the environment variables 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. Set the variables under “System variables”.

On UNIX/Linux machines, you can set the environment variables using the “setenv” or “export” commands:

From csh:

setenv <environment_variable> <new_value>

or from bash / ksh:

export <environment_variable>=<new_value>

On Apple machines that have Intel processors, follow the instructions for UNIX/Linux machines. For Apple machines that have a PowerPC processors, there is no blas.spec file.

Consult your OS User's Guide for more information about your system in particular.

The environment variables you need to set are:

BLAS_VERSION
--------------------------
This sets which BLAS version you use; look in your $MATLAB\bin\<arch> directory for files corresponding to different BLAS versions. $MATLAB is your MATLAB root directory, and <arch> is the architecture type for your processor. For example, Atlas BLAS files have names beginning with "atlas_", MKL BLAS files have names beginning with "MKL_", Sun Performance Library BLAS files starts with "libsunperf", etc.

Set this environmental variable to the name of the file in the $MATLAB\bin\<arch> directory you want to use; for example, on Windows or Linux, to use the Atlas BLAS optimized for a Pentium 2 processor, set BLAS_VERSION to atlas_PII.dll. The blas.spec file in $MATLAB\bin\<arch> lists the default BLAS version used for various processors.

LAPACK_VERBOSITY
-----------------------------------
To display which LAPACK library is used set this equal to 1.


The following is a list of some BLAS vendors:

Intel MKL: http://www.intel.com/software/products/mkl/

AMD ACML: http://www.amd.com/us-en/Processors/DevelopWithAMD/0,,30_2252_2282,00.html

The AMD ACML BLAS is not supported on MATLAB 7.3 (R2006b) and on previous releases of MATLAB on the Windows platform.

HP MLIB: http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,,1204,00.html

Sun Performance Library: http://wwws.sun.com/software/sundev/news/features/sunperf.html

Apple Mac:http://developer.apple.com/hardwaredrivers/ve/vector_libraries.html

 

Related Solutions:

Please provide feedback to help us improve this Solution
Contact support
E-mail this page
Print this page