shape [10][100]S; /* fully defined, 2 dimensional, 10 by 100 shape */ float:S a; /* parallel variable, is 2 dimensional, 10 by 100 elements */Typically, any variable of Standard C type may be declared as a parallel variable:
shape [10]S; typedef int:S Pi; /* Type Pi is a parallel int of shape S */ extern int:S b; /* b is an extern parallel int of shape S */ int:S y[5]; /* y is an array of 5 parallel ints of shape S */ struct date { int month; int day; int year; }; struct date:S hire_date; /* hire_date is a parallel structure of shape S */One can also declare pointers to parallel variables, such as:
float:S *pa; /* pa is a pointer to a parallel float of shape S */A parallel variable of shape "void" is a special type of parallel variable that can be used for declaring prototypes and actual arguments. A parallel variable of shape "void" is useful for functions which will accept a parallel variable of different types of shapes depending on the arguments that it is referenced with:
shape [10]S; shape [10][10]T; int:S a; int:T b; ... func(a); func(b); ... func ( int:void pvar ) ... pvar = 1; ...When func is referenced with parallel variable "a", the assignment is a 1-d assignment of size 10. When referenced with "b", the assignment is a 2-d assignment of 10 x 10.
As noted earlier, the use of fully unspecified shapes may impede performance, this applies to void shapes. The temptation to use void shapes for flexibility in calling a function with varying types of shapes should be avoided if they flexibility is not needed. Remember, the trade-off with flexibility is often run-time performance.
©1995 Pacific-Sierra Research Corporation. All rights reserved.
Send comments or suggestions to dpce2 at crescentbaysoftware.com.