Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

# Intel Vector Math Library

The Intel Vector Math Library, also known as VML, is an integral part of the Intel Math Kernel Library. VML provides vector implementations of certain computationally intensive core mathematical functions. Thus, you can use high-level VML vector functions when you want to take full advantage of most modern SIMD instructions without having to write specific SIMD calls.

VML uses the most convenient SIMD instruction set to achieve the best performance according to the underlying hardware: You don't have to worry about which is the most convenient SIMD instruction set, you just have to call the appropriate high-level VML function. Developers usually complain about the complexity of SIMD instruction sets. Once you start using the VML, it is really easy to achieve superscalar speedups without having to learn each new SIMD instruction set that microprocessor manufacturers introduce.

VML provides functions to perform computations on real vector elements grouped in the following categories:

• Arithmetic
• Exponential and logarithmic
• Hyperbolic
• Power and root
• Rounding
• Special
• Trigonometric

In addition, VML provides functions to perform computations on complex vector elements grouped in the following categories:

• Arithmetic
• Exponential and logarithmic
• Trigonometric
• Hyperbolic
• Power and root

Certain VML functions can work in three different modes:

1. HA — High Accuracy. This mode provides better accuracy at the cost of performance. It is the default mode.
2. LA — Low Accuracy. This mode provides a slight reduction in accuracy, which causes 1 or 2 least significant bits to be inaccurate. However, LA mode provides higher performance than the HA mode. In most cases, this mode is more than sufficient.
3. EP — Enhanced Performance. This mode provides a significant reduction in accuracy because you can expect only about half of the significant bits to be correct. However, if your application can accept the reduced accuracy, the mode provides the best performance.

The Intel Math Kernel Library includes dozens of examples that demonstrate how to use the VML functions with C in the examples\vmlc\source folder, within the main MKL folder. For example, if you installed Intel Composer XE 2011 in Windows 7 64-bit, by default, that folder will be located in C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\examples\vmlc\source. Intel Composer XE 2011 includes the Intel Math Kernel Library.

When you work with the VML, you have to include "mkl_vml.h" and "_rms.h" to have access to the functions and call them with the necessary parameters. You don't have to worry about SIMD because VML solves that for you. For example, you can call the `vdMul` function to perform element-by-element multiplication of real vector `a` and real vector `b` with double precision. The `vsMul` function performs the same operation with single precision. If you want to calculate the absolute values for real vector elements with double precision, you can call the `vdAbs` function.

The examples included with the VML are easy to grasp and, if you have a good understanding of the advantages of SIMD, you will be able to start utilizing the VML within a few minutes. If you want the best performance without having to make specific SIMD calls, VML is an excellent choice. In addition, your code will scale as new microprocessors add new SIMD instructions. Intel MKL is a commercial product, but you can download a free trial version here.

### More Insights

 To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.