Measures#
One number, the same on every GPU, to the last bit.
A measure reduces a whole canvas to one number, on the GPU.
measure burning_area = sum(cell * cell) on plant where state == 1
measure room_flux = max(radiation) on plant where kind == rgb(30, 150, 60)
measure hot = count(temperature > 50) on plate
run {
repeat steps { spread radiate burning_area room_flux } // one measurement per step
print burning_area // a series: first, last, minimum and maximum
save burning_area "out/area.csv" // the whole series
}
The reductions are
sum,mean,min,maxandcount(condition).wherefilters the pixels that take part.The value per pixel uses the same language as kernels, including neighbours and other canvases.
Each measurement runs on the GPU and is kept in a series on the GPU; nothing goes back to the host at every step.
The same number on every device#
A measure always combines the pixels in the same order, whatever the device, and never with atomic additions (which sum in a different order on every run, so the result changes from one run to the next).
Sums and means are computed with about 44 bits of precision, although GPUs only have float32: over one million values the error is below 1e-13 (relative), against more than 1e-6 for a plain float32 sum.