Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

MT2203 PRNG

jyothiadibatti
Beginner
622 Views
Hi,

I am trying to compare MT2203 PRNG(C code) results with Intel VSL MT2203.

I use DCMT library(version 4.0) to calculate parameter for MT2203.

Below is how i use VSL functions:
#########################
#include
#include
#include "mkl_vsl.h"
#include "mkl_vsl_functions.h"

#define BasicRNG (VSL_BRNG_MT2203)

#define samples 50
#define nstreams 2

int main()
{
unsigned int init[4]={0x123, 0x234, 0x345, 0x456};
int n=4,i=0;
float r[samples]; /* buffer for random numbers */

VSLStreamStatePtr stream[nstreams];

/* Initializing */
for(int k =0;k< nstreams;k++)
vslNewStreamEx( &stream, VSL_BRNG_MT2203+k, n, init );


/* Generating */
for(int k =0;k< nstreams;k++)
vsRngUniform( VSL_METHOD_SUNIFORM_STD,stream, samples, r, 0.0f, 1.0f );

printf(" Numbers are \n");
for (i=0; iprintf("%10.8f ",r);
if (i%5==4) printf("\n");
}
/* Deleting the streams */
for(int k =0;k< nstreams;k++)
vslDeleteStream( &stream );

return 0;
}

###############
I have attached dcmt.h file which contains the parameters for 1024 MT2203 generators.
The file includes the data as {matrixa,masb,maskc,seed } for all 1024 generators.

My C code results doen't match with VSL results.
Can any one let me know whether i am using VSL functions properly?
OR is there any thing wrong in generating MT2203 parameters?

Thanks in advance.

Regards,
Jyothi

0 Kudos
4 Replies
Andrey_N_Intel
Employee
622 Views

Hello Jyothi,

You correctly use VSL library.
The difference between your C code for MT2203 and VSLversion should be in different sets of the parameters.We made choice of the parameters using DCMT library. Additionally, among the generated parameter sets we selected those that provided the gap between realized k-distribution and theoretical upper bound as small as possible. Please, let me know if this answers your question.

Thanks,
Andrey

0 Kudos
jyothiadibatti
Beginner
622 Views

Hello Jyothi,

You correctly use VSL library.
The difference between your C code for MT2203 and VSLversion should be in different sets of the parameters.We made choice of the parameters using DCMT library. Additionally, among the generated parameter sets we selected those that provided the gap between realized k-distribution and theoretical upper bound as small as possible. Please, let me know if this answers your question.

Thanks,
Andrey

Hello Andrey,

Thanks a lot for your reply.
Pleaselet me know how can i proceed further to verify my results.
If you can give some pointers will be very much useful.

Thanks,
Jyothi
0 Kudos
Andrey_N_Intel
Employee
622 Views

Hello Jyothi,

It makes sense to use open source code for Mersenne Twister RNG with your parameters to test output of the implementation. Do you have chance to verify your implementation using the codes of DCMT library available on the Mersenne Twsiter site? You also could do statistical testing of your generator using one of suites like DieHard.
Can I know the reasons for which you can not use VSL version of MT2203 in your application?

Best,
Andrey
0 Kudos
Whit_D_
Beginner
622 Views
I'm migrating a Fortan project that uses the Intel MKL MT2203 family of generators to an ARM platform. Since MKL is not available for ARM, I've written a Fortan implementation of MT2203 for direct implementation on my target platform. I can use DCMT to generate parameters for my MT2203, but as pointed out above, these won't be the same parameters implemented in the VSL version of MT2203 which I would prefer for reproducibility. Is it possible to get a listing of the actual 6024 sets of parameters for the VSL MT2203 that are implemented by Intel MKL? Cheers.
0 Kudos
Reply