5,337
edits
Line 6: | Line 6: | ||
* Spawn creates threads | * Spawn creates threads | ||
* Threads expire at Join | * Threads expire at Join | ||
* <code>$</code> represents the number of the thread | |||
* <code>PS Ri Rj</code> is an atomic prefix sum | |||
** Stores Ri + Rj in Ri | |||
** Stores the original value of Ri in Rj | |||
<pre> | |||
int x = 0; | |||
// Spawn n threads | |||
spawn(0, n-1) { | |||
int e = 1; | |||
if (A[$] != 0) { | |||
// Sets e=x and increments x | |||
ps(e,x); | |||
} | |||
} | |||
</pre> | |||
==Models== | ==Models== |