Double buffering keeps values being read separate from values being written. In each Hillis–Steele scan round, threads read from one buffer and write to the other; the buffers swap roles before the next round. section 6.2
A scan across three rounds
For [3, 1, 7, 0, 4, 1, 6, 3], the scan uses strides 1, 2, and 4. Each round reads the previous round’s values and writes to the alternate buffer, so no thread overwrites a value another still needs. section 6.2
With one array, a thread may read a neighbor’s value while another thread overwrites it, making results depend on execution order. In CUDA, a barrier at the end of each round ensures its writes land before the next round reads; swapping buffer indices needs no separate barrier. section 6.16 section 6.8
buf[pout][tid] = buf[pin][tid]
+ buf[pin][tid - stride]; #AThis assignment shows the essential pattern: read both operands from pin and write the result to pout. section 6.16
