The MASM Forum

General => The Workshop => Topic started by: aw27 on June 22, 2019, 01:55:38 AM

Title: CUDA for generation of random floats (REAL4)
Post by: aw27 on June 22, 2019, 01:55:38 AM
As mentioned in another thread,  (http://masm32.com/board/index.php?topic=7916.msg86834#msg86834) CUDA has an extensive library for random number generation. I built a very simple example which does not even need preparing a PTX  :skrewy:
Note 1: I am using rdseed to generate a seed, of course it can be replaced by anything else (even a constant number which will allow us to confirm that the cycle will repeat itself).
Note 2: Source is Uasm code.


CUDA has generated 32 floats in the range ]0,1[

Random 1 =      0.373034
Random 2 =      0.774700
Random 3 =      0.534322
Random 4 =      0.176285
Random 5 =      0.009252
Random 6 =      0.991005
Random 7 =      0.133226
Random 8 =      0.946131
Random 9 =      0.593726
Random 10 =     0.999742
Random 11 =     0.563159
Random 12 =     0.800713
Random 13 =     0.361991
Random 14 =     0.391241
Random 15 =     0.926299
Random 16 =     0.062051
Random 17 =     0.441507
Random 18 =     0.705876
Random 19 =     0.198921
Random 20 =     0.637949
Random 21 =     0.877369
Random 22 =     0.086583
Random 23 =     0.341929
Random 24 =     0.388912
Random 25 =     0.398181
Random 26 =     0.864875
Random 27 =     0.156591
Random 28 =     0.113409
Random 29 =     0.289298
Random 30 =     0.459491
Random 31 =     0.048772
Random 32 =     0.080255

<Press any key to Exit>
Title: Re: CUDA for generation of random floats (REAL4)
Post by: daydreamer on June 22, 2019, 03:53:00 AM
I dont have CUDA hardware :sad:
Title: Re: CUDA for generation of random floats (REAL4)
Post by: Raistlin on June 22, 2019, 04:13:17 AM
And Vulkan/OpenGL ES 3.1 or up ? There is other stuff besides NVIDIA Cuda
Pretty much the same actually when found....  :skrewy:
Title: Re: CUDA for generation of random floats (REAL4)
Post by: aw27 on June 22, 2019, 04:18:46 AM
Quote from: daydreamer on June 22, 2019, 03:53:00 AM
I dont have CUDA hardware :sad:

I understand and you have my sympathy  :thumbsup:,  but once in a while I do things for people that has hardware less than 5 years old (aka, state of the art )  and bleeding edge graphics card brands (aka NVidia,  :badgrin:)  :biggrin:

Quote from: Raistlin on June 22, 2019, 04:13:17 AM
And Vulkan/OpenGL ES 3.1 or up ? There is other stuff besides NVIDIA Cuda
Pretty much the same actually when found....  :skrewy:

Yes I know, but NVidia rules.  :biggrin:
Actually, OpenCL underperforms significantly CUDA and is more complicated. In case of need, of course, lets go with OpenCL.
Title: Re: CUDA for generation of random floats (REAL4)
Post by: daydreamer on June 22, 2019, 03:00:35 PM
Quote from: Raistlin on June 22, 2019, 04:13:17 AM
And Vulkan/OpenGL ES 3.1 or up ? There is other stuff besides NVIDIA Cuda
Pretty much the same actually when found....  :skrewy:
Smartphone can run opengl
but you have to start with make easier apps first
Tried that Rudi?
Title: Re: CUDA for generation of random floats (REAL4)
Post by: aw27 on June 22, 2019, 03:01:47 PM
I should add that the NVidia curand.lib in the attachment above is an "import library". So, you will need to install the NVidia SDK version 10 to have access to the paired curand64_10.dll.
In other words, it is difficult to produce an omelette without eggs.  :skrewy:
Title: Re: CUDA for generation of random floats (REAL4)
Post by: LiaoMi on June 23, 2019, 09:27:36 PM
Hi AW! Thanks for the cool example!