Title: CUDA random numbers for threads Post by: kubinator4321 on January 16, 2015, 10:54:57 PM Hello,
I don't know, if this is the right place to ask. If it is, I'm kindly asking the moderators to move it to the proper category. I'm currently trying to use the knowledge I got from making a mandelbrot renderer in CUDA to make a buddhabrot in CUDA. However, I came across a problem - random numbers. The very basic of a buddhabrot is iterating random numbers. In my CPU inplementation, I used the Mersenne Twister, which is included in the standard C++ libraries and has a huge period. On the GPU, however, things start getting complicated. I haven't yet figured out how to use them, and how to use them PROPERLY and EFFICIENTLY. And thus, I'm kindly asking anybody here, who has experience with that in CUDA on C++ to help me understand how to use the random numbers. Also, if anybody here can tell me the best way to sum up the results of operations from many threads (atomic operations are slow AFAIK), or if I shouldn't bother myself with it, I'd appreciate it too. Title: Re: CUDA random numbers for threads Post by: claude on January 16, 2015, 11:45:18 PM You need one random number generator for each thread, all uncorrelated / independent. I think the term for generating uncorrelated RNG states is called "splitting", at least that's what the Haskell random package calls it:
http://hackage.haskell.org/package/random-1.1/docs/System-Random.html#v:split For accumulation, maybe look into interoperability with OpenGL: collect all the points into a buffer, then draw them as points with additive blending into a floating point frame buffer (to avoid overflow issues). Anyway, in my personal experiments with Buddhabrot I've avoided random numbers: http://mathr.co.uk/blog/2013-12-30_ultimate_anti-buddhabrot.html Title: Re: CUDA random numbers for threads Post by: kubinator4321 on January 17, 2015, 12:00:21 AM Anyway, in my personal experiments with Buddhabrot I've avoided random numbers: I'm sorry, but I'll need to study a bit more to understand all the maths language, but do you simply go through points in rows and columns and calculate the buddhabrot for them? Because when I used to do it in C++, I got color discontinuities, as visible in these screenshoots: http://puu.sh/dGkCK/986645bfb5.jpg http://puu.sh/dGCSA/92bd101652.jpg Title: Re: CUDA random numbers for threads Post by: claude on January 17, 2015, 12:14:21 AM basically yes, but note that if you zoom into the buddhabrot, you still have to calculate iterates from across the whole mandelbrot set because the iterates jump around a lot. i saw this about fast zooming, but the maths is even more intense than my blog post :D http://www.moleculardensity.net/buddhabrot/appendix/1
Title: Re: CUDA random numbers for threads Post by: kubinator4321 on January 17, 2015, 10:45:17 AM if you zoom into the buddhabrot, you still have to calculate iterates from across the whole mandelbrot set Actually, maybe I should precalculate many starting points and small random numbers, and assign a starting point+random number for each thread? This theoretically should give nice results... Title: Re: CUDA random numbers for threads Post by: ker2x on January 29, 2015, 04:10:13 PM I use Mersenne twister, it's fast (non-crypto) and "good enough for me". You can find my openCL code here : https://github.com/ker2x/WinBuddhaOpenCL/blob/master/WinBuddhaOpenCL/BuddhaCloo.cs |