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

Device code for Example 2: Quasi-Monte Carlo

See also
DocsTutorial/example2.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 simulateWithQMC(
__global const clqmcLatticeRule* pointset,
uint points_per_work_item,
__global clqmc_fptype* out)
{
uint gsize = get_global_size(0);
uint gid = get_global_id(0);
clqmcLatticeRuleStream stream;
clqmcLatticeRuleCreateOverStream(&stream, pointset, gsize, gid, (void*)0);
clqmc_fptype sum = 0.0;
for (uint i = 0; i < points_per_work_item; i++) {
sum += simulateOneRun(&stream);
}
out[gid] = sum / points_per_work_item;
}
/*
vim: ft=c
*/