1.9. Reduction

The reduction of a vector to a scalar is another important operation. The REDUCE operation handles this task in conjunction with a system-defined or user-defined (programmable) reduction operation (see Figure 11). System-defined operators are:

SUM, PRODUCT, MAX, MIN, AND, OR, FIRST, LAST

The operators FIRST and LAST return the value of the first or last currently active PE, respectively, according to its identification number (ID). All other reduction operators' functions can easily be deduced from their names. The execution of a reduction operation requires about log2 n time steps for a vector with n active components. However, this time estimation depends on the physical connection structure of the PEs.

 VAR s: INTEGER;     x: grid OF INTEGER;
     s := REDUCE.SUM(x);                       
Figure 11 Vector reduction in Parallaxis

The following example shows the use of the REDUCE operation with a user-defined function. Such a function has to have two vector input parameters and has to return a vector value of the same type. Note that the reduction function implemented by the user should be associative and commutative, or unpredictable results may occur,

e.g. (1 - 2) - 3 != 1 - (2 -3 ).

VAR v: grid OF BOOLEAN;
    s: BOOLEAN; 
...
PROCEDURE xor (a,b: VECTOR OF BOOLEAN): VECTOR OF BOOLEAN;
BEGIN 
	RETURN(a <> b); 
END xor; 
...  
s := REDUCE.xor(v);


[ Previous Page | Table of Contents | Next Page ]