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 Statistical Library

Intel Vector Statistical Library, also known as "VSL," is a powerful integral part of the Intel Math Kernel Library. VSL provides optimized routines that implement pseudo-random and quasi-random number generators with continuous and discrete distributions. Thus, you just have to think about the necessary type of distribution and the desired mode of random number generation, accurate or fast. Once you make the first call to one of the VSL optimized routines, you'll never have to write your own generation routines.

Simulations usually require random number generation. When running simulations, you need to ask yourself a few questions. Do you really want to design your own optimized algorithm to create a normal (Gaussian) distribution generator? Are you going to take full advantage of the most modern SIMD instructions? Are you going to create a thread-safe optimized algorithm? Is your optimized algorithm going to take advantage of the forthcoming micro-architectures? Is your optimized algorithm scale as the number of available cores increase?

If you just want to consume the results of an optimized and scalable generator, then the VSL routines included in MKL are for you. VSL implements all the random number generators with vector types. In fact, VSL uses Intel Vector Math Library vector functions, and therefore, VSL takes full advantage of the most modern SIMD instructions found in modern Intel CPUs. Intel Vector Math Library, also known as "VML," is another integral part of MKL. You can read "Intel Vector Math Library: A Simpler Way to Take Advantage of SIMD Instructions" for more details on VML.

Please note that the optimizations included in the VSL random number generators with MKL 10.3 are more efficient with the latest Intel CPUs. VSL is a thread-safe library and supports parallel execution with many possible configurations. Parallel execution of random number generations is usually a problem for legacy code. Thus, VSL is usually useful for replacing routines that provided you random number generations optimized for sequential execution, but coded in the single-core era.

VSL allows you to execute simultaneous generation of several random number sequences produced by one or more basic generators. In addition, it is possible to split the original sequence into many subsequences. VSL allows you to easily use the leapfrog and block-split methods in order to process many subsequences. Of course, you can also use VSL routines with a sequential execution while still taking advantage of SIMD instructions. However, it is best to select the most convenient parallel execution configuration according to the application requirements and the available hardware. VSL provides a simple interface with a universal mechanism to initialize generators. In fact, there are just two subroutines to initialize any generator.

VSL provides continuous distribution generators with the following types of distributions:

  • Beta distribution
  • Cauchy distribution
  • Exponential distribution
  • Gamma distribution
  • Gumbel (extreme value) distribution
  • Laplace distribution (double exponential distribution)
  • Lognormal distribution
  • Multivariate normal (Gaussian) distribution
  • Normal (Gaussian) distribution
  • Rayleigh distribution
  • Uniform continuous distribution on the interval [a, b]
  • Weibull distribution

In addition, VSL provides discrete distribution generators with the following types of distributions:

  • Bernoulli distribution
  • Binomial distribution
  • Geometric distribution
  • Hyper geometric distribution
  • Negative binomial or Pascal distribution
  • Poisson distribution
  • Poisson distribution with varying mean
  • Underlying BRNG (short for "Basic Random Number Generator") integer recurrence
  • Uniform discrete distribution on the interval [a, b]
  • Uniformly distributed bits in 32-bit chunks
  • Uniformly distributed bits in 64-bit chunks

Intel Math Kernel Library includes a complete set of examples that demonstrate how to use the VSL random generators in both C and Fortran. You will find the examples written in C within the examples\vslc\source folder, in the main MKL folder. For example, in case you installed Intel Composer XE 2011 in Windows 7 64-bit, by default, that folder will be located at C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\examples\vslc\source. Intel Composer XE 2011 includes Intel Math Kernel Library, and therefore, includes VSL random generators.

When you work with VSL you just have to include "mkl_vsl.h" to have access to all the necessary functions that provide access to the generators and call them with the necessary parameters. However, it is also useful to include "errcheck.inc" in order to have a reference to the descriptions for any possible errors.

The typical usage of a VSL random number generator requires following just four steps:

  1. Create and initialize one or more streams. There are just six functions related to this task.
  2. Call one or more random number generators.
  3. Process the output generated by the random number generators.
  4. Delete one or more streams.

The samples included with VSL are very useful for understanding how to create, initialize, and configure the different random generators. Whenever someone tells me about a need for optimized pseudo-random or quasi-random number generators, I suggest the VSL shortcut. It usually takes no more than a day to understand all the examples and start using the generators with the appropriate configuration.

As with many other parts of MKL, VSL makes your code scale as new microprocessors add new SIMD instructions. Intel MKL is a commercial product, but you can download a free trial version.

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.