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.

Channels ▼


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.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips 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.