This results in each component of x being assigned the number of its virtual PE, always starting with `1' (independent of the configuration range and number of dimensions):
The second way of determining the position of a virtual PE, now with respect to its configuration declaration, is to use the standard function DIM. This function takes the configuration name and the number of the dimension as arguments and returns the position of a PE within this dimension. Dimensions are numbered from right to left, that is, the highest dimension is at the leftmost position.
The position values returned by function DIM depend on the ranges of the configuration definition. The DIM function will return exactly this range of values as position data. In the following, position data for rows and columns of the grid example above are shown:
Both functions, ID and DIM, do not depend on any PE connections. Further functions working on configuration data are shown below. These functions take either configurations or vector variables as arguments.
LEN(grid) = 20 returns the total number of PEs in a configuration LEN(grid,1) = 5 returns the size of a dimension (here dim. 1) LEN(grid,2) = 4 returns the size of a dimension (here dim. 2) RANK(grid) = 2 returns the number of dimensions LOWER(grid,1) = -2 returns the lower bound of a dimension (here dim.1) UPPER(grid,1) = 2 returns the upper bound of a dimension (here dim. 1)A function and a procedure are provided to transfer ID values into DIM values and vice versa. An array is used for DIM values. Both routines may be used with scalar or vector parameters. These routines are especially useful for converting ID and DIM values of multiple configurations.
VAR dims: ARRAY[1..2] OF INTEGER; s : INTEGER; ... dims[1] := 1; dims[2] := 2; s := DIM2ID(grid,dims); s becomes 9 ... ID2DIM(grid,12,dims); dims[1] becomes -1 dims[2] becomes +3An individual PE may be selected by using an IF-selection involving parallel position data like ID and DIM. However, supplying the position values directly for a vector is also possible and gives a simpler way of selecting PEs. A single PE may be selected using a component expression with scalar arguments after the identifier of a vector variable:
VAR x : grid OF INTEGER; (* 2-dim. *) s,t: INTEGER; (* scalar *) ... s := x <<101>> ; get the value of the PE with ID 101 x <<101>> := s ; set the value of the PE with ID 101 s := x <:5,t+1:> ; get the value of the PE in row 5 and column t+1, according to the CONNECTION ranges specified x <:t,11:> := s ; set the value of the PE in row t and column 11