Compiler Support
Directory Structure
Linking with the Intel® Math Kernel Library (Intel® MKL)
Using Intel MKL Parallelism
Memory Management
Performance
Precision and Rounding Control
Obtaining Version Information
Intel does not support the Intel® Math Kernel Library (Intel® MKL) for use with any compilers other than those identified in the release notes. However, Intel MKL has been successfully used with other compilers.
In the following discussion, "stdcall" is actually the Compaq* Visual Fortran (CVF) compiler default compilation, which differs from stdcall in the way strings are passed to the routine.
There are both cdecl (default Microsoft* Visual C (MSVC) interface) and stdcall (default CVF interface) versions of the library. The cdecl version is called "mkl_c.lib" and the stdcall version is called "mkl_s.lib". Whether you choose to link with cdecl or stdcall depends on factors that only you can determine. Calling routines in mkl_s.lib from C requires that you use a statement like "extern __stdcall name( <prototype variable1>, <prototype variable2>, .. );". However, because the default CVF format is not identical with stdcall, you will need to handle strings in the calling sequence specially. Dealing with this issue is complex and the user is advised to refer to sections on interfaces in the CVF documentation.
Calling routines in mkl_c.lib requires a similar declaration, such as "<type> name( <prototype variable1>, <prototype variable2>, .. );".
Similarly, the CVF compiler will link with mkl_s.lib if routines are compiled with the default interface, but if the user compiles with the switch /iface=(cref,nomixed_str_len_arg), the appropriate library to use is mkl_c.lib.
When using the cblas interface, the header file mkl.h will simplify the program development since it specifies enumerated values as well as prototypes of all the functions. The header determines if the program is being compiled with a C++ compiler, and if it is, the included file will be correct for use with C++ compilation.
There is currently no support for compilers that require OMF file format.
Intel MKL separates IA-32 versions of the library and versions for Intel® Itanium® and Itanium® 2 processors. The IA-32 versions are located in the ia32 directory and the Itanium processor version is located in the ia64 directory. Intel MKL consists of three parts: interface, LAPACK, and processor specific kernels in mkl_ia32.lib. There are currently two libraries for the IA-32 versions that support interface: mkl_c.lib - for cdecl interface, and mkl_s.lib - for CVF default interface. There is not an interface library for the Itanium processor version as there is only one standard for the function calls. The LAPACK library contains LAPACK routines and drivers that are optimized without regard to processor so that it can be used effectively on processors from Intel® Pentium® through the Pentium® 4 processor. Processor specific kernels contain BLAS, FFTs, DFTs, VSL, cblas, and VML routines that were optimized for each specific processor. Also, threading software is supplied as a separate library, libguide.lib, for static linking (first introduced with this release), and dynamic link library, libguide40.dll, when linking dynamically to Intel MKL.
The information below indicates the library's directory structure.
| mkl60\ia32 | Contains all libraries for 32-bit applications | |
| mkl60\ia32\bin | Contains DLLs for 32-bit applications | |
| mkl_lapack32.dll | LAPACK routines and drivers, single precision data types | |
| mkl_lapack64.dll | LAPACK routines and drivers, double precision data types | |
| mkl_def.dll | default kernel (Intel® Pentium®, Pentium® Pro, and Pentium® II processors) | |
| mkl_p3.dll | Intel® Pentium® III processor kernel | |
| mkl_p4.dll | Pentium 4 processor kernel | |
| mkl_vml_def.dll | VML part of default kernel (Pentium, Pentium Pro, Pentium II processors) | |
| mkl_vml_p3.dll | VML part of Pentium III processor kernel | |
| mkl_vml_p4.dll | VML part of Pentium 4 processor kernel | |
| libguide40.dll | Threading library | |
| mkl60\ia32\lib | Contains static libraries and static interfaces to DLLs for 32-bit applications | |
| mkl_c.lib | cdecl interface library | |
| mkl_s.lib | CVF default interface library | |
| mkl_c_dll.lib | cdecl interface library for dynamic library | |
| mkl_s_dll.lib | CVF default interface library for dynamic library | |
| mkl_lapack.lib | LAPACK routines and drivers | |
| mkl_ia32.lib | Optimized kernels for Intel® Pentium®, Pentium® III, and Pentium® 4 processors | |
| libguide.lib | Threading library | |
| mkl60\ia64 | Contains all libraries for Itanium®-based and Itanium® 2-based applications | |
| mkl60\ia64\bin | Contains DLLs for Itanium®-based and Itanium® 2-based applications | |
| mkl_lapack32.dll | LAPACK routines and drivers, single precision data types | |
| mkl_lapack64.dll | LAPACK routines and drivers, double precision data types | |
| mkl_itp.dll | Itanium processor kernel | |
| mkl_vml_itp.dll | VML part of Itanium processor kernel | |
| mkl_i2p.dll | Itanium 2 processor kernel | |
| mkl_vml_i2p.dll | VML part of Itanium 2 processor kernel | |
| libguide40.dll | Threading library | |
| mkl60\ia64\lib | Contains static libraries and static interfaces to DLLs for Itanium®-based and Itanium® 2-based applications | |
| mkl_lapack.lib | LAPACK routines and drivers | |
| mkl_ipf.lib | Processor kernels for the Intel® Itanium® processor family which includes both the Intel® Itanium and Itanium® 2 processors | |
| mkl_dll.lib | Interface library to DLL | |
| libguide.lib | Threading library | |
Linking to Intel MKL has been simplified with Intel MKL 6.0. Only the interface file needs to be linked into your program. The other libraries are identified as default libraries within the interface library and cause the linker to automatically link in the other libraries. For Itanium-based applications you must link library mkl_ipf.lib.
Some possible variants:
link myprog.obj mkl_c.lib
link myprog.obj mkl_s.lib
link myprog.obj mkl_c_dll.lib
link myprog.obj mkl_s_dll.lib
link myprog.obj mkl_ipf.lib
link myprog.obj mkl_dll.lib
Intel MKL is threaded in a number of places: LAPACK (*GETRF, *POTRF, *GBTRF, DGEQRF routines), all Level 3 BLAS, all DFTs (except 1D transformation), and all FFTs. Intel MKL uses OpenMP* threading software.
There are situations in which conflicts can exist in the execution environment that make the use of threads in Intel MKL problematic. We list them here with recommendations for dealing with these. First, a brief discussion of why the problem exists is appropriate.
If the user threads the program using OpenMP directives and uses the Intel® compilers to compile the program, Intel MKL and the user program will both use the same threading library. Intel MKL tries to determine if it is in a parallel region in the program, and if it is, it does not spread its operations over multiple threads. But Intel MKL can be aware that it is in a parallel region only if the threaded program and Intel MKL are using the same threading library. If the user program is threaded by some other means, Intel MKL may operate in multithreaded mode and the computations may be corrupted. Here are several cases and our recommendations for the user:
OMP_NUM_THREADS=1 in the environment. This is the default with Intel MKL 6.1.
OMP_NUM_THREADS in
the environment affects both the compiler's threading library and the
threading library with Intel MKL. At this time, the safe approach is to set
MKL_SERIAL=YES (or MKL_SERIAL=yes) which forces Intel MKL to serial mode regardless of OMP_NUM_THREADS value.
OMP_NUM_THREADS should be set to 1.
Setting the number of threads: The OpenMP* software responds
to the environmental variable OMP_NUM_THREADS. The
number of threads can either be set as an environmental variable in
the Environment panel of the System Properties box of the Control
Panel on Microsoft* Windows NT*, or it can be set in the shell the
program is running in. To change the number of threads, in the command
shell in which the program is going to run, enter:
set OMP_NUM_THREADS=<number of threads to use>.
Some other shells require the variable and its value to be exported:
export OMP_NUM_THREADS=<number of threads to use>.
Setting the variable when running on Microsoft* Windows* 98 or Windows* ME is meaningless, since multiprocessing is not supported.
To force Intel MKL to serial mode, environment variable MKL_SERIAL should be set to YES (set MKL_SERIAL=YES). It works regardless of OMP_NUM_THREADS value. MKL_SERIAL is not set by default.
If the variable OMP_NUM_THREADS is not set, Intel MKL
software will run on the number of threads equal to 1. We recommend always setting
OMP_NUM_THREADS to the number of processors you wish to use in your application.
MKL_FreeBuffers(). If another call is made to an Intel MKL function that
needs a memory buffer, then the memory manager will again allocate the
buffers and they will again remain allocated until either the end of the program or the program deallocates the memory.
This memory management software is turned on by default. To disable
it, set the environment variable MKL_DISABLE_FAST_MM to any value,
which will cause memory to be allocated and freed from call to call.
Disabling this feature will negatively impact performance of routines
such as the level 3 BLAS, especially for small problem sizes.
To obtain the best performance with Intel MKL, make sure the following conditions are fulfilled: arrays must be aligned on a 16-byte boundary, and the leading dimension values (n*element_size) of two-dimensional arrays must be divisible by 16. There are additional conditions for the FFT functions. The addresses of first elements of arrays and the leading dimension values (n*element_size) of two-dimensional arrays should be divisible by cache line size (32 byte for Pentium III processor and 64 byte for Pentium 4 processor). Furthermore, for the C-style FFTs on the Pentium 4 processor, the distance L between arrays that represent real and imaginary parts should not satisfy the following inequality:
k*2**16 <= L < k*2**16+64
These conditions are needed due to the use of Streaming SIMD Extensions (SSE).
To obtain the best performance with Intel MKL on Itanium-based applications the following conditions are desirable.
For the C-style FFT a sufficient condition is for the distance L between arrays that represent real and imaginary parts is not divisible by 64. The best case is if L=k*64 + 16.
For DGEMM it is desirable that the leading dimension values (n*element_size) of two-dimensional arrays are divisible by 16, but not divisible by 32.
For DFTs it is desirable that the leading dimension values (n*element_size) of two-dimensional arrays are not power-of-two.
On input to Intel MKL, precision is set to 80-bit for x87 instructions and rounding is set to "the nearest". On output, user's settings are restored.
Intel MKL provides a facility by which you can obtain information about
the library (e.g., the version number). Two methods are provided for
extracting this information. First, you may extract a version string
using the function MKLGetVersionString. Or, alternatively, you can use
the MKLGetVersion function to obtain an
MKLVersion structure that contains the version
information. Example programs for extracting this information are
provided in the mkl60\examples\versionquery
directory. Batch files are also provided to automatically build the
examples and output summary files containing the version information
for the current library. An example summary file can be found in the
readme.htm file in the same directory.
Celeron, Dialogic, i386, i486, iCOMP, Intel, Intel logo, Intel386,
Intel486, Intel740, IntelDX2, IntelDX4, IntelSX2, Intel Inside, Intel Inside logo, Intel NetBurst,
Intel NetStructure, Intel Xeon, Intel XScale, Itanium, MMX, MMX logo, Pentium, Pentium II Xeon,
Pentium III Xeon, and VTune are trademarks or registered trademarks
of Intel Corporation or its subsidiaries in the United States and other countries.
* Other names and brands may be claimed as the property of others.
Copyright © 2000-2003 Intel Corporation.