How to get a “random” number in OpenCL

后端 未结 9 869
悲&欢浪女
悲&欢浪女 2020-12-07 22:59

I\'m looking to get a random number in OpenCL. It doesn\'t have to be real random or even that random. Just something simple and quick.

I see there is a ton of rea

9条回答
  •  再見小時候
    2020-12-07 23:16

    GPU don't have good sources of randomness, but this can be easily overcome by seeding a kernel with a random seed from the host. After that, you just need an algorithm that can work with a massive number of concurrent threads.

    This link describes a Mersenne Twister implementation using OpenCL: Parallel Mersenne Twister. You can also find an implementation in the NVIDIA SDK.

提交回复
热议问题