Using Intel MKL with MATLAB - Matlab使用多核CPU

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 R2008a make use of Intel MKL 10.0.x.


2. Dependencies

Software
This note applies to MATLAB R2008a and Intel MKL 10.0.x

Hardware
The note should work for all hardware configurations that meet the system requirements for both MATLAB R2008a and Intel MKL 10.0.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 R2008a uses the uses the Intel MKL 9.1 Basic Linear Algebra Subroutines (BLAS) libraries to perform computations. To upgrade to the Intel MKL 10.0.x release, you need to create a DLL using the Intel MKL 10.x or later custom DLL builder located in MKL\10.0\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\10.0\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(R)   Software Development Tools >> Intel(R) Compiler [version] >> Build Environment for...

To Start the Microsoft® Compier, from the Start Menu seletc Programs>>Microsoft Visual Studio 2005(8)>> 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 MKL\10.0\doc\userguide.pdf) section "Building Custom DLL".

  • You will find the resulting file at MKL\10.0\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.

Multiprocessor Performance
Intel MKL multi-threading mode is disabled by default. To benefit from Intel multi-core processors, enable multi-threading mode by following the steps above. Set the name of the environment variable to OMP_NUM_THREADS and set the value of the variable to the number of processors you want to use in your application.


6. Running MATLAB

Start MATLAB R2008a 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).

你可能感兴趣的:(matlab)