Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
7234 Discussions

Is the GNU GSL Mersenne twister PRNG faster than the MKL VSL version?

oscar_m_
Beginner
2,230 Views

Hello everybody

I would like to perform some montecarlo simulations using the well-known Mersenne Twister PRNG. Before to start to write my code I decided to test the performance of this PRNG using the GSL and MKL libraries, so I wrote a small code for such comparison. The results I got suggested that the GSL version is faster.  May it be possible or am I doing something wrong?. I am compiling using

[]$icpc benchmark.c -O3 -c

[]$icpc benchmark.o -o benchmark -L/opt/intel/parallel_studio_xe_2017/compilers_and_libraries_2017/linux/mkl/lib/intel64 -mkl:parallel -lgsl -lgslcblas

Do you have a feeling about what is happening? The code is in attachment. It takes as argument the number of random variables to be generated.

Thanks

0 Kudos
1 Solution
Gennady_F_Intel
Moderator
2,230 Views

Oscar,  i didn't noticed at the attached the example of you benchmark. The picture is clear now -  we don't recommend to use MKL RNG on the vectore size 1 like you did. 

View solution in original post

0 Kudos
5 Replies
Gennady_F_Intel
Moderator
2,230 Views

This is an unexpected perf results. could you try the latest mkl 2018? what the performance numbers do you obtain?

0 Kudos
Gennady_F_Intel
Moderator
2,231 Views

Oscar,  i didn't noticed at the attached the example of you benchmark. The picture is clear now -  we don't recommend to use MKL RNG on the vectore size 1 like you did. 

0 Kudos
oscar_m_
Beginner
2,230 Views
If I create a buffer with size equal to the number of random variables e.g. 10^8 will the mersenne twister from MKL be faster than the GNU version? Can you try and confirm it please.
0 Kudos
Gennady_F_Intel
Moderator
2,230 Views

yes, it will. The performance difference will depend on system where you will execute this code.

0 Kudos
oscar_m_
Beginner
2,230 Views

Thanks Gennady. Luckily, that was the trick, BTW my application will use MPI so I will have to use the MT2203 generator to obtain different sequences for each MPI task. Do you know about a toy code showing how to use the MT2203? May be a link.

0 Kudos
Reply