Quantcast
Channel: AMD Developer Forums: Message List
Viewing all articles
Browse latest Browse all 4104

Re: Random numbers in OpenCL

$
0
0

you're welcome. yup, its park miller.

 

i am not sure if you want to write your own or not, but using TinyMT is trivial. once you get the download here http://www.math.sci.hiroshima-u.ac.jp/~%20m-mat/MT/TINYMT/OPENCL/index.html

sample is here http://www.math.sci.hiroshima-u.ac.jp/~%20m-mat/MT/TINYMT/OPENCL/sample32_jump.cl

 

what i do in my kernels is

include the file (i put the sources in tinymt-opencl relative to the .cl file)

#include "tinymt-opencl/tinymt32_jump.clh"

 

inside the kernels

tinymt32j_t tinymt;

tinymt32j_init_jump(&tinymt, (get_global_id(0) + 1 )); //init the rng to to something somewhat random within each thread

 

to generate value between 0-1

float val = tinymt32j_single01(&tinymt));

for a uint32

uint32 val = tinymt32j_uint32(&tinymt));

 

the documentation of individual functions is a bit sparse but you might get some idea from the tinymt32_jump.clh and you can generate values between a bunch of float ranges and also returns integers


Viewing all articles
Browse latest Browse all 4104

Trending Articles