Files
ispc/tests/foreach-11.ispc
Matt Pharr 8bc7367109 Add foreach and foreach_tiled looping constructs
These make it easier to iterate over arbitrary amounts of data
elements; specifically, they automatically handle the "ragged
extra bits" that come up when the number of elements to be
processed isn't evenly divided by programCount.

TODO: documentation
2011-11-30 13:17:31 -08:00

23 lines
529 B
Plaintext

export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float val[programCount];
for (uniform int i = 0; i < programCount; ++i)
val[i] = 0;
foreach_tiled (i = 0 ... programCount)
val[i] += aFOO[i] - 1;
uniform float sum = 0;
for (uniform int i = 0; i < programCount; ++i)
sum += val[i];
RET[programIndex] = sum;
}
export void result(uniform float RET[]) {
RET[programIndex] = reduce_add(programIndex);
}