tag:blogger.com,1999:blog-17486618.post8486958063949787257..comments2024-03-06T13:46:59.263+01:00Comments on Emergent: CUDA, random numbers inside kernelsAnonymoushttp://www.blogger.com/profile/05265068564407128751noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-17486618.post-6745151581032056522015-10-07T17:03:40.075+02:002015-10-07T17:03:40.075+02:00Yes. In such a case, the number of states is equal...Yes. In such a case, the number of states is equal to N=48*2=96.Anonymoushttps://www.blogger.com/profile/05265068564407128751noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-82829365735174225552015-09-27T12:14:58.157+02:002015-09-27T12:14:58.157+02:00So i basically launch kernel with something like &...So i basically launch kernel with something like <<<48,2>>>, and that will be it, right?sunipkmhttps://www.blogger.com/profile/11126799788375637263noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-60779968785846975732015-09-27T01:46:39.993+02:002015-09-27T01:46:39.993+02:00Whenever you launch a kernel you must specify how ...Whenever you launch a kernel you must specify how many threads per block (i.e., tpb) you want, and how many blocks you want in the grid (i.e., bpg).<br /><br />In this oversimplified and non-compiling example, I create a single block with N threads per block. <br /><br />Naturally, you want to replace N with an arbitrary number of threads, if you really want to compile this example. What is Anonymoushttps://www.blogger.com/profile/05265068564407128751noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-60991069821533232232015-09-26T19:48:10.820+02:002015-09-26T19:48:10.820+02:00Sorry if I am asking a foolish question, but I did...Sorry if I am asking a foolish question, but I did not get the line "dim3 tpb(N,1,1)". Could someone kindly explain? sunipkmhttps://www.blogger.com/profile/11126799788375637263noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-3633079412548837362015-04-25T09:41:50.294+02:002015-04-25T09:41:50.294+02:00Thanks Man!
I've changed the kernel code to: ...Thanks Man! <br />I've changed the kernel code to: <br /> "float RANDOM = curand_uniform( &globalState[idx] );"<br /><br />and the kernel finished it ran 2x faster!<br /><br />However, running the setup_kernel is very slow (miliseconds). Why? Is there any ohter option?Anderson Oliveira Sousahttps://www.blogger.com/profile/07644300575573558129noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-64365352778499436542014-10-21T13:32:40.499+02:002014-10-21T13:32:40.499+02:00You are my hero, dude.
rngStates[id] = localState...You are my hero, dude.<br /><br />rngStates[id] = localState;<br /><br />Thats what i was missing all the time.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-37435402284133194962014-02-19T16:31:37.527+01:002014-02-19T16:31:37.527+01:00can we use seconds as input instead of local state...can we use seconds as input instead of local stateAnonymoushttps://www.blogger.com/profile/09064793228637480487noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-11024906159728403032014-02-19T16:25:40.194+01:002014-02-19T16:25:40.194+01:00can i capture seconds in GPU and can input them as...can i capture seconds in GPU and can input them as seed to generate random numbers in device one by one Anonymoushttps://www.blogger.com/profile/09064793228637480487noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-29908791251799582632014-02-19T16:24:39.707+01:002014-02-19T16:24:39.707+01:00can we capture seconds in GPU and supply it as see...can we capture seconds in GPU and supply it as seed ??<br />Anonymoushttps://www.blogger.com/profile/09064793228637480487noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-11193949953909336952013-12-17T00:23:20.015+01:002013-12-17T00:23:20.015+01:00sure, you can use it twice, it updates the local s...sure, you can use it twice, it updates the local state and you're fine. you can also use different functions for other distributions, exploiting the same local state.Anonymoushttps://www.blogger.com/profile/05265068564407128751noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-27424885813863139892013-12-13T22:39:01.845+01:002013-12-13T22:39:01.845+01:00I am wondering how to generate 2 random numbers pe...I am wondering how to generate 2 random numbers per thread ?<br /><br />can I use curand_uniform( &localState ) twice to get two diff random numbers in the same thread <br />(I don't want to double the threads to init the states)<br /><br />Thanks for the nice post to explain the random number no. generation in gpu.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-74532161891437359572013-10-06T12:36:48.460+02:002013-10-06T12:36:48.460+02:00If you rely on the statistical properties of the R...If you rely on the statistical properties of the RNG, then DON'T use the modulo operator to map the number on to your interval!! This has caused me some headaches in the past :-)Jorennoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-59738308444762964082013-10-06T12:36:48.170+02:002013-10-06T12:36:48.170+02:00If you rely on the statistical properties of the R...If you rely on the statistical properties of the RNG, then DON'T use the modulo operator to map the number on to your interval!! This has caused me some headaches in the past :-)Jorennoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-35171509019044555092013-02-03T18:41:22.952+01:002013-02-03T18:41:22.952+01:00@V. Sumati: It depends on how you have implemented...@V. Sumati: It depends on how you have implemented your code. Can you post an example?<br /><br />@offspring: how did you generate your samples? all inside a single kernel, or by spawning multiple threads in a parallel fashion? RNG is a computationally expensive task, btw.<br /><br />Talking about normally distributed random deviates, you can easily generate them by using<br /><br />curand_normalAnonymoushttps://www.blogger.com/profile/05265068564407128751noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-4829445847418999462013-02-02T12:11:46.051+01:002013-02-02T12:11:46.051+01:00Can you suggest some method to generate normally d...Can you suggest some method to generate normally distributed random numbers on CUDA C device?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-83227358985893053212013-01-15T23:50:52.904+01:002013-01-15T23:50:52.904+01:00Hello and well done for your great Job. I used you...Hello and well done for your great Job. I used your curand code and made some measurements 3 very large data structures (4000000 float numbers) and it almost took one minute to produce the pseudo random numbers! Do you know why is this might happening?<br /><br />Thanks beforehand.offspringnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-33068729537169759752013-01-15T23:50:43.910+01:002013-01-15T23:50:43.910+01:00Hello and well done for your great Job. I used you...Hello and well done for your great Job. I used your curand code and made some measurements 3 very large data structures (4000000 float numbers) and it almost took one minute to produce the pseudo random numbers! Do you know why is this might happening?<br /><br />Thanks beforehand.offspringnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-71086077811978332112012-10-25T09:44:17.563+02:002012-10-25T09:44:17.563+02:00thanks for your help .thanks for your help .Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-85477731366488793122012-09-10T13:19:00.925+02:002012-09-10T13:19:00.925+02:00This is very informative blog. It has solved my pr...This is very informative blog. It has solved my problem of generating RANDOM numbers on device. Do i have to keep this code in a while loop if i need to generate random numbers in each run of the code?Anonymoushttps://www.blogger.com/profile/08006807356141561803noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-21644039403176163132012-08-09T14:18:05.357+02:002012-08-09T14:18:05.357+02:00Nice work, regardsNice work, regardsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-4399751628965175112012-06-08T15:50:21.060+02:002012-06-08T15:50:21.060+02:00Very helpful!!! Thx a lot! :)Very helpful!!! Thx a lot! :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-17486618.post-64085970481256117192012-05-14T21:09:11.335+02:002012-05-14T21:09:11.335+02:00Hi! first of all: sure, you can use curand_init in...Hi! first of all: sure, you can use curand_init in the same kernel.<br /><br />About the sequence number, it ensures that the states in various threads won't have any correlation. If you use the same seed in each thread then the successions will be identical. By specifying a sequence number (here referred to the thread index) your successions "will not have statistically correlated Anonymoushttps://www.blogger.com/profile/05265068564407128751noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-78025856185787663772012-05-13T13:32:52.378+02:002012-05-13T13:32:52.378+02:00Hello dear sir, sorry for my english, there is one...Hello dear sir, sorry for my english, there is one question: can i use curand_init(...) inside same kernel with curand_uniform(...) call? In such way i can save some time instead of spending it to invoke "init" kernel.<br />And one more: what is the meaning of sequence number in curand_init? (may be i am dummy a little but i can't find info for this question)<br />Thx for your FromRussiaWithLowehttps://www.blogger.com/profile/11326422057600472665noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-86120831253907030942011-12-26T09:44:50.423+01:002011-12-26T09:44:50.423+01:00Wow, thx a lot about the example!
It helps me a lo...Wow, thx a lot about the example!<br />It helps me a lot about my gpu implementation~!Anonymoushttps://www.blogger.com/profile/00448304070142657331noreply@blogger.comtag:blogger.com,1999:blog-17486618.post-10547134711071071712011-12-26T09:44:45.801+01:002011-12-26T09:44:45.801+01:00Wow, thx a lot about the example!
It helps me a lo...Wow, thx a lot about the example!<br />It helps me a lot about my gpu implementation~!Anonymoushttps://www.blogger.com/profile/00448304070142657331noreply@blogger.com