Device code for Example 4: Poisson variate generation on the device
#include <clRNG/mrg31k3p.clh>
#ifndef NULL
#define NULL ((void*)0)
#endif
double simulateOneRun(__global
const clprobdistPoisson* dist, clrngMrg31k3pStream* stream)
{
double output = 0.0;
for (int i = 0; i < 100; i++) {
double u = clrngMrg31k3pRandomU01(stream);
}
return output;
}
__kernel void my_kernel(
__global const clrngMrg31k3pHostStream* host_streams,
__global double* output)
{
size_t gid = get_global_id(0);
clrngMrg31k3pStream stream;
clrngMrg31k3pCopyOverStreamsFromGlobal(1, &stream, &host_streams[gid]);
output[gid] = simulateOneRun(dist, &stream);
}