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
- 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:
- Create and initialize one or more streams. There are just six functions related to this task.
- Call one or more random number generators.
- Process the output generated by the random number generators.
- 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.