cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

Random number in the OpenCL Kernel ?

Hi,

I would like to know if there is a way to get the time in an OpenCL kernel ?

What I need is one or several good 'random number' to use in my kernel. So, if you have some proposals ?

0 Likes
5 Replies
himanshu_gautam
Grandmaster

hi viewon01,

There are no built-in random number generator functions in OpenCL. Although you can create one for you if it is necessary.As a seed i would suggest you to take the times returned by clGetProfilingInfo.You can use any of the 4 timestamps.The value is represented in nanoseconds so i think it would be quite random and suitable as seed.

Thanks

0 Likes

Random number generation is not so simple 😛

I have see several implementations in OpenCL, none is 'perfect' and 100% GPU !

I have see severals OpenCL random sequences generations like ;

- Mersenne

- Tausworthe

- ... other ...

Each method procude different quality of sequences !

0 Likes
dravisher
Journeyman III

I posted some code that I made for my own use here, which I believe is one of the simpler ones to start using in your own code.

0 Likes

Thanks,

It looks very interesting, I have to do some tests too.

I have also find this page : http://inst.cs.berkeley.edu/~ianh/proj1.html

Where he has a 'simple' random generator... code is provided too.

0 Likes
nan
Adept II

Hi,

in this post I've linked another alternative: Re: Random numbers in OpenCL

-- NaN

0 Likes