1. Convergent attribute is useful for SIMT/SPMD programming model.
2. Intended interpretation is that a convergent operation cannot be move either into or out of a conditionally executed region.
3. If you have a convergent instruction A, it islegal to duplicate it to instruction B if (assuming B is after A in program flow) A dominates B and B post-dominates A.
case:
r1 = texture2D(..., r0, ...)
if (...) {
// r0 used as temporary here
r0 = ...
r2 = r0 + ...
} else {
// only use of r1
r2 = r1 + ...
}
In this example, various optimizations might try to sink the texture2D operation into the else block, like so:
if (...) {
r0 = ...
r2 = r0 + ...
} else {
r1 = texture2D(..., r0, ...)
r2 = r1 + ...
}
In most SPMD/SIMT implementations, the fallout of this races is exposed via the predicated expression of acyclic control flow: pred0 <- cmp ... if (pred0) r0 = ... // thread 1 if (pred0) r2 = r0 + ... // thread 1 if (!pred0) r1 = texture2D(..., r0, ...) // thread 0 if (!pred0) r2 = r1 + ... // thread 0
If thread 0 takes the else path and perform the texture2D operation, but its neighbor thread 1 takes the then branch, then the texture2D will fail because thread 1 has already overwritten its value of r0 before thread 0 has a chance to read it.
沒有留言:
張貼留言