19#include <owl/common/math/vec.h>
25 inline int linear(
const vec2i &ID,
const vec2i &dims)
26 {
return ID.x + dims.x*ID.y; }
28 template<
typename Lambda>
29 inline void for_each(
const vec2i &dims,
const Lambda &lambda)
31 for (
int iy=0;iy<dims.y;iy++)
32 for (
int ix=0;ix<dims.x;ix++)
36 template<
typename Lambda>
37 inline void for_each(
const vec2i &begin,
41 for (
int iy=begin.y;iy<end.y;iy++)
42 for (
int ix=begin.x;ix<end.x;ix++)
47 template<
typename Lambda>
48 inline void parallel_for(
const vec2i &dims,
const Lambda &lambda)
50 owl::common::parallel_for(dims.x*dims.y,[&](
int index){
51 lambda(vec2i(index%dims.x,index/dims.x));
55 template<
typename Lambda>
56 inline void serial_for(
const vec2i &dims,
const Lambda &lambda)
58 owl::common::serial_for(dims.x*dims.y,[&](
int index){
59 lambda(vec2i(index%dims.x,index/dims.x));
63 template<
typename Lambda>
64 inline void parallel_for_blocked(
const vec2i &dims,
65 const vec2i &blockSize,
68 const vec2i numBlocks = divRoundUp(dims,blockSize);
70 (numBlocks,[&](
const vec2i &block){
71 const vec2i begin = block*blockSize;
72 const vec2i end = min(begin+blockSize,dims);