I’m looking for a simple way to generate a random floats between 0.0 and 1.0 for multiple threads in parallel. This is my kernel so far..
attributes(global) subroutine rand_kernel()
implicit none
integer :: tid
real :: r
! Thread ID
tid = threadIdx%x
! Generate random number
call <some random number generator> (r)
! Randomise array
d_array(tid) = r
end subroutine rand_kernel
I’ve been looking around in forums and reading the CURAND manual, but I still can’t figure out what to do. I’m not even sure if there are any random number libraries for CUDA FORTRAN.
I just need a push in a right direction then I can write myself a decent random number generator.
Thanks for the help
I found an article explaining how to call a CUDA C implemented pseudo-random number generator (the Mersenne Twister implementation from the CUDA SDK) from a CUDA Fortran code.
Details can be found in the section “Calling a CUDA C Random Number Generator” of this article:
http://www.pgroup.com/lit/articles/insider/v2n1a4.htm