Using Intel MKL with MATLAB

1. Overview

This guide is intended to help Intel® Math Kernel Library (Intel® MKL) customers use the latest version of Intel® MKL for Windows* with The MathWorks* MATLAB*.
MATLAB is an interactive software program that performs mathematical computations and visualization. For more information about MATLAB visit www.mathworks.com/products/matlab.

Version Information
This note was created to help users of MATLAB R20010a make use of Intel MKL 10.3.x.


2. Dependencies

Software
This note applies to MATLAB R2010a and Intel MKL 10.3.x

Hardware
The note should work for all hardware configurations that meet the system requirements for both MATLAB R2010a and Intel MKL 10.3.x.  This note has been tested on Intel® Core®2 Duo processors.

Operating System
This note should work for Windows* users of MATLAB.


3. Obtaining the Latest Version of Intel MKL

The latest release of the Intel Math Kernel Library is available at www.intel.com/software/products/mkl.  You can download the latest  Intel MKL if you have a valid license.  You can also obtain the latest version by renewing your current license or registering for a free 30-day evaluation.


4. Building a Custom DLL

By default, MATLAB R2010a uses the Intel MKL 9.1 Basic Linear Algebra Subroutines (BLAS) libraries to perform computations. To upgrade to the Intel MKL 10.3.x release, you need to create a DLL using the Intel MKL 10.3.x or later custom DLL builder located in ${MKL}\tools\builder:

  • Scroll to the bottom of this page and download the attached file matlab_custom_dll.zip.
  • Extract and copy the files from matlab_custom_dll.zip and copy them to ${MKL}\tools\builder. It may be preferrable to save the old ones by renaming them or moving them to a temporary folder.
  • The custom DLL is built from the command line via a makefile. Set the command environment as appropriate for your compiler.

To start the Intel® Compiler Command Line Windows, from the Start Menu select  Programs>> Intel®   Software Development Tools >> Intel® Compiler [version] >> Build Environment for...

To Start the Microsoft® Compiler, from the Start Menu select Programs>>Microsoft Visual Studio 2005(8,10)>> Visual Studio Tools>> Visual Studio 2005 Command Prompt

Build the custom DLL with the following command nmake ia32. For additional options such as customizing the name of the DLL, please refer to the Intel MKL User Guide (located at

${ComposerXE-2011}\Documentation\en_US\mkl\mkl_userguide) section "Building Custom DLL".

  • You will find the resulting file at ${MKL}\10.3.x\tools\builder\mkl_custom.dll.


5. MATLAB Configuration

Modify the system environment so that MATLAB uses the Intel MKL BLAS functions from the custom DLL. Set the BLAS_VERSION environment variable by following the steps on Windows XP:

  • Click Start, go to the Settings menu and select Control Panel.
  • Select System to open the System Properties dialog box.
  • Click the Advanced tab.
  • Click the Environment Variables button to open the Environment Variables dialog box.
  • Under the User variables section, click the New button to open the New User Variable dialog box.
  • Set the name of the variable to BLAS_VERSION and set the value of the variable to mkl_custom.dll.

6. Running MATLAB

Start MATLAB R2010a as you normally would and the Intel MKL BLAS library will be called.


7. Verifying Correctness

From MATLAB, run the command version -modules and check the output list to verify that the custom DLL is loaded.


8. Troubleshooting

The error "The specified module could not be found." occurs for two cases:

  1. One or more of the required interfaces is missing from the custom DLL
    Solution: Follow the steps in section 4 and rebuild the custom DLL.
  2. The custom DLL is not found.
    Solution: Verify that the path to and the name of the custom DLL is correct (see section 5).


Appendix A - References

Tags:
AttachmentSize
Download matlab-custom-dll.zip1.11 KB
For more complete information about compiler optimizations, see our Optimization Notice.

Comments

eliosh's picture

Can you, please, expand this article by adding instructions for Linux.
Thank you.

's picture

Can you, please, expand this article by adding instructions for models the canal.
Thank you.