using QuasirandomGenerator (for dummies)

坚强是说给别人听的谎言 提交于 2019-12-07 15:41:24

问题


I am a newbi to CUDA and I am struggling to generate random numbers in my kernels.

I know there are different implementations, and, what is more, in the SDK 4.1 there is an example of the Niederreiter Quasirandom Sequence Generator.

I don't know where to start... I am a bit sad and feeling like a dummy...

Could anyone please please make a simple and silly example of using the Niederreiter Quasirandom Sequence Generator (SKD code example)? I would really apreciate it. For example, creating a vector and filling it with random numbers (each thread filling a vector position).

Thank you in advance.


回答1:


The quasirandomGenerator sample in the SDK does pretty much what you're asking, it takes a region of memory and fills it with quasirandom numbers.

That said, I think you'd be better off using cuRAND, it's Sobol' instead of Niederreiter but unless you have a specific reason for preferring the later you will find it easier to use. For examples of how to use it you should look in the MonteCarloCURAND set of samples:

  • EstimatePiQ shows how to allocate a region on GPU memory and fill it with Sobol' numbers
  • EstimatePiInlineQ shows how to generate one number at a time within another kernel

The samples ending in P use pseudo-random generators.



来源:https://stackoverflow.com/questions/9292658/using-quasirandomgenerator-for-dummies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!