I have seen that Intel seems to have included a new assembly function to get real random numbers obtained from hardware. The name of the instruction is RdRand
, but only a small amount of details seem accessible on it on Internet: http://en.wikipedia.org/wiki/RdRand
My questions concerning this new instruction and its use in C++11 are the following:
Are the random numbers generated with RdRand
really random? (each bit generated from uncorrelated white noise or quantum processes? )
Is it a special feature of Ivy Bridge processors and will Intel continue to implement this function in the next generation of cpu?
How to use it through C++11? Maybe with std::random_device
but do compilers already call RdRand
if the instruction is available?
How to check whether RdRand
is really called when I compile a program?
std::random_device
is not required to be hardware driven, and even if it is, it is not required to use rdrand
. You can ask its double entropy() const noexcept
member function whether it is hardware driven or not. Using rdrand
for that is a QoI issue, but I would expect every sane implementation that has it available to do so (I have seen e.g. gcc doing it). If unsure, you can always check assembly, but also other means of hardware randomness should be good enough (there is other dedicated hardware available).entropy
, if interested in rdrand, scan the generated machine code.