raytracing - Optimal way to record ray intersection data for ray tracing using OpenCL -
i developing monte carlo ray tracer in opencl calculating 'view factors' radiative heat transfer analysis , wish know optimal way collate number of times object x intersected rays fired object i.
now basic algorithm follows :
- fire random ray, r, off surface of object i
- test intersection of ray r objects 0 - n
- determine first object intersected r, let object x
- record first intersection incrementing array of int's such array[i][x] +=1
- repeat total number of rays
- divide each value in ith row of array total number of arrays fired object i.
now typically in parallel implementation on cpu each thread maintain own copy of array[n] , when rays have been fired object i, master thread sum individual arrays results.
in opencl on gpu not practical solution when n increases there becomes shortage of local memory , using single array barriers cripple performance.
what best practical preforming reduction of results array or a memory barrier practical solution?
kernel a) described, writing own copies of array[n] global memory @ end.
kernel b) kernel reduction (that "master thread" in description).
make invocations of kernel set events upon completion. make invocation(s) of kernel b depend on events. use multiple invocations of kernel b pyramid reduction, taking 2 (or more, tuning may needed) arrays , writing out 1 sum. chain of events resolve dependencies , allow deep queuing.
Comments
Post a Comment