Example 2: Use of context

In the example below, notice the use of the "where" operation to selectively process elements of the parallel variable "a".

#include <dpce.h> shape [10]S; void inita( int:void *a); main() { int:S a; int i; a = pcoord(S,0); /* initialize a to the sequence 0,1,2,3,4,5,6,7,8,9 */ where( a > 5 ) inita( &a ); printf(" a: "); for(i=0;i<10;i++) printf(" %d ",[i]a); printf(" \n"); } void inita( int:void *a ) { *a += 1; /* should give 0 1 2 3 4 5 7 8 9 10 */ everywhere(shapeof(a)) *a -= 1; /* should give -1 0 1 2 3 4 6 7 8 9 */ *a += 2; /* should give -1 0 1 2 3 4 8 9 10 11 */ }

Options:

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

Send comments or suggestions to dpce2 at crescentbaysoftware.com.