Generating random numbers: CPU vs GPU, which currently wins?

后端 未结 2 1014
猫巷女王i
猫巷女王i 2021-01-12 08:26

I\'ve been working on a physics simulations requiring the generation of a large amount of random numbers (at least 10^13 if you want an idea). I\'ve been using the C++11 imp

2条回答
  •  孤街浪徒
    2021-01-12 08:59

    If you have a new enough Intel CPU (IvyBridge or newer), you can use the RDRAND instruction.

    This can be used via the _rdrand16_step(), _rdrand32_step() and _rdrand64_step() intrinsic functions.

    Available via VS2012/13, Intel compiler and gcc.

    The generated random number is originally seeded on a real random number. Designed for NIST SP 800-90A compliance, its randomness is very high.

    Some numbers for reference:

    On an IvyBridge dual core laptop with HT (2.3GHz), 2^32 (4 Gigs) random 32bit numbers took 5.7 seconds for single thread and 1.7 seconds with OpenMP.

提交回复
热议问题