Files
ispc/tests/rand-distrib.ispc
Matt Pharr 8fd9b84a80 Update seed_rng() in stdlib to take a varying seed.
Previously, we were trying to take a uniform seed and then shuffle that
around to initialize the state for each of the program instances.  This
was becoming increasingly untenable and brittle.

Now a varying seed is expected and used.
2012-05-30 10:35:41 -07:00

18 lines
463 B
Plaintext

export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RNGState state;
seed_rng(&state, programIndex);
float sum = 0;
uniform int iters = 40000;
for (unsigned int i = 0; i < iters; ++i)
sum += frandom(&state);
float avg = sum / iters;
RET[programIndex] = (avg > 0.495 && avg < 0.505) ? 1 : 0;
}
export void result(uniform float RET[]) {
RET[programIndex] = 1;
}