Context

The DPCE where statement can be used to define a context. In the execution of a where block, the context is associated with the shape of the parallel variable(s) used in the where expression. The context associated to the shape applies to all parallel variables of the same shape that are used within the execution of the where block.

shape [10]S;
int:S a;

where ( a > 5 )
{
  ...
  function(a);
}
In this example, the where statement makes "active" those positions where the condition (a>5) evaluates to true, all other positions are made inactive. Any statements that are executed within the where block, either locally or externally and involve parallel variables of shape S are effected by this context. For example:

function( int:S a )
{
   a += 1;
}
Here, with function referenced inside a where block, the parallel variable is only incremented by 1 in the "active" positions. Nothing is done on the "inactive" positions. In other words, the code may be executing conditionally depending on the circumstances in which it was referenced.

If the programmer knows that a function will never be executed conditionally, or if the programmer wishes to override the effects of the where block, then an everywhere block can be used:

function (int:S a)
{
  everywhere {
     a += 1;
  }
}
Depending on the DPCE compiler, the use of the everywhere statement may greatly improve run-time efficiency.

Options:

©1995 Pacific-Sierra Research Corporation. All rights reserved.

Send comments or suggestions to dpce2 at crescentbaysoftware.com.