New fast basic random number generator SFMT19937 in Intel MKL



Intel MKL 10.3 introduced a new basic generators: a SIMD friendly Fast Mersenne Twister pseudorandom number SFMT19937 generator.

SFMT19937 is analogous to Mersenne Twister (MT) basic generators. But it can take the advantage of SIMD instructions and provide the fast implementation in the processors.


To learn more information on SFMT algorithm, please check the bellow article.

Saito, M., and Matsumoto, M. SIMD-oriented Fast Mersenne Twister: a 128-bit Pseudorandom Number Generator. Monte Carlo and Quasi-Monte Carlo Methods 2006, Springer, Pages 607 – 622, 2008.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/earticles.html


The following is an example application using Intel MKL SFMT19937


#include <stdio.h>
#include “mkl_vsl.h”
 
int main()
{
   double r[1000]; /* buffer for random numbers */
   double s; /* average */
   VSLStreamStatePtr stream;
   int i, j;
    
   /* Initializing */        
   s = 0.0;
   vslNewStream( &stream, VSL_BRNG_SFMT19937, 777 );
    
   /* Generating */        
   for ( i=0; i<10; i++ )
   {
      vdRngGaussian( VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, 1000, r, 5.0, 2.0 );
      for ( j=0; j<1000; j++ );
      {
         s += r[j];
      }
   }
   s /= 10000.0;
    
   /* Deleting the stream */        
   vslDeleteStream( &stream );
    
   /* Printing results */        
   printf( “Sample mean of normal distribution = %fn”, s );
    
   return 0;
}





Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.