A mask is a region expression that specifies an index set based on the value of a parallel operand. The with operator produces an index set that is the intersection of the region and the true elements (non-zero) of the parallel operand. The without operator intersects with the false elements of the parallel operand. The following code fragment shows how a Red-Black SOR program could be written using masks.
var Mask : [R] integer; . . . -- set mask to checkerboard pattern Mask := ( (Index1 % 2) and (Index2 % 2) or !(Index1 % 2) and !(Index2 % 2)); [R with Mask] Sor(A); [R without Mask] Sor(A);The with and without operators can take one or two operands. The mask operand must always be specified, but the region may be omitted, in which case the existing region scope is used to compute the intersection. Thus, the following two statements are equivalent.
[R] begin [with Mask] Sor(A); [without Mask] Sor(A); end; begin [R with Mask] Sor(A); [R without Mask] Sor(A); end;The mask operand must be a parallel variable with an l-value (see Section 5.5). This restriction simply prevents the use of complicated expressions as the mask operand.
Masks scope the same way that regions do. Thus, the above code could also have been written as follows.
[R] begin [with Mask] begin Sor(A); -- shorthand for [R with Mask] [without Mask] Sor(A); -- shorthand for [R without Mask] end end;