clRNG
An OpenCL library for random number generators (RNG)
 All Data Structures Files Functions Typedefs Enumerations Pages
WorkItem/workitem_kernel.cl

Very simple example of a kernel that uses the clRNG device API

See also
workitem.c
/* optional definitions
#define CLRNG_SINGLE_PRECISION
#define CLRNG_ENABLE_SUBSTREAMS
*/
#include <mrg31k3p.clh>
__kernel void example(__global clrngMrg31k3pHostStream* streams, __global float* out) {
int gid = get_global_id(0);
clrngMrg31k3pStream private_stream_d; // This is not a pointer!
clrngMrg31k3pCopyOverStreamsFromGlobal(1, &private_stream_d, &streams[gid]);
out[gid] = clrngMrg31k3pRandomU01(&private_stream_d) +
clrngMrg31k3pRandomU01(&private_stream_d);
}