- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
How do I access RDRAND from Fortran? Will it work on Zen processors as well as Intel?
Thanks,
Bruce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you could access to this true generates from Fortran API of MKL.
First check (lspu | grep rdrand) if thins instruction available on this particular system.
Look at the MKL Developer Reference follow this link: https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/statistical-functions/random-number-generators/basic-generators.html where listed all mkl’s basic generators and rdrand as well.
Unfortunately, MKL doesn’t provide an RNG examples show how to make the call for this particular Basic generators, but the calling pipeline would very similar with C code:
#define SEED VSL_BRNG_RDRAND
#define BRNG VSL_BRNG_NONDETERM
//Create and Initialize stream:
VSLStreamStatePtr stream;
//Initialize stream
vslNewStream( &stream, BRNG, SEED );
//generate RNG
vsRngUniform( VSL_RNG_METHOD_UNIFORM_STD, stream, N_GEN_VALS, r, a, b ) // see reference for more details…
-Gennady
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MKL has that I think. I also believe it is the VS C++ libraries so you you write and interface and wrapper function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RDRAND and RDSEED are available on most X86/X64 processors, including Zen. They can be useful during seed generation, and in crypto- applications.
However, a good RNG in the compiler RTL can be an order of magnitude faster, so there is little motivation for using RDRAND instead of an RNG in, say, Monte-Carlo simulations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you could access to this true generates from Fortran API of MKL.
First check (lspu | grep rdrand) if thins instruction available on this particular system.
Look at the MKL Developer Reference follow this link: https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/statistical-functions/random-number-generators/basic-generators.html where listed all mkl’s basic generators and rdrand as well.
Unfortunately, MKL doesn’t provide an RNG examples show how to make the call for this particular Basic generators, but the calling pipeline would very similar with C code:
#define SEED VSL_BRNG_RDRAND
#define BRNG VSL_BRNG_NONDETERM
//Create and Initialize stream:
VSLStreamStatePtr stream;
//Initialize stream
vslNewStream( &stream, BRNG, SEED );
//generate RNG
vsRngUniform( VSL_RNG_METHOD_UNIFORM_STD, stream, N_GEN_VALS, r, a, b ) // see reference for more details…
-Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have not heard back from you. This is to kindly inform you that this thread will no longer be monitored by Intel. If you need further assistance, please post a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks all. Especially Gennady; I hope to try that out this weekend. I use an inordinate number of random numbers: 90 threads running for a couple weeks using about 3e6 random numbers/20 minutes each. I'm starting to be concerned about the twister so I want to compare the results with true random numbers. Hopefully, it will show that the Twister is good enough for what I'm trying to do. If not, I'll have to figure out how to get around the time issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bruce,
>>I use an inordinate number of random numbers: 90 threads running for a couple weeks using about 3e6 random numbers/20 minutes each.
Are you aware that the referenced random number generators can produce a harvest of random numbers in one call as opposed to a single random number per call?
Some of the RNGs are independent per thread and do not internally use a critical section while other RNGs internally use a critical section per call. By electing an RNG that uses a critical section, then in a multi-threaded application you can reduce the logjam at the critical section through the use of harvesting many random numbers for subsequent use by the calling thread.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jim,
I do call a whole bucket full of random numbers at a time. I seed my threads independently & they each have their own (identical) random number calling routine.
thanks
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page