clQMC
An OpenCL library for quasi-Monte Carlo methods
DocsTutorial/example3_kernel.cl

Device code for Example 3: Randomized Quasi-Monte Carlo

See also
DocsTutorial/example3.c
/*
* Authors:
*
* David Munger <mungerd@iro.umontreal.ca> (2015)
* Pierre L'Ecuyer <lecuyer@iro.umontreal.ca> (2015)
*
*/
#define StreamType clqmcLatticeRuleStream
#define nextCoordinate clqmcLatticeRuleNextCoordinate
#include <clQMC/DocsTutorial/common.clh>
__kernel void simulateWithRQMC(
__global const clqmcLatticeRule* pointset,
__global const clqmc_fptype* shifts,
uint points_per_work_item,
uint replications,
__global clqmc_fptype* out)
{
uint gsize = get_global_size(0);
uint gid = get_global_id(0);
uint points = clqmcLatticeRuleNumPoints(pointset);
clqmcLatticeRuleStream stream;
for (uint k = 0; k < replications; k++) {
clqmcLatticeRuleCreateOverStream(&stream, pointset, gsize, gid, &shifts[k * DIMENSION]);
clqmc_fptype sum = 0.0;
for (uint i = 0; i < points_per_work_item; i++) {
sum += simulateOneRun(&stream);
}
out[k * gsize + gid] = sum / points_per_work_item;
}
}
/*
vim: ft=c sw=2 expandtab
*/