The most common use of returning a single value to the main control thread is to reduce, or summarize, the information computed by each thread of a processor object. Each of these functions are primitive, ``built in'', member functions of TEClass objects. In addition to computing and returning a uniform value to each processor object thread, they provide a way to synchronize the computations of each thread. The reduction functions available in pC++ are summarized in the table below. They are described in terms of a data type T which is assumed to have operators >, ==, >=, +, * which obey an associativity law. T may be a standard base type like int or double, or it may be a user defined type subject to some simple restrictions which we will describe later.

- T pCxx_max(T x) returns the maximum of a set of thread values.
- T pCxx_min(T x) returns the minimum of a set of thread values.
- T pCxx_sum(T x) returns the sum of a set of thread values.
- T pCxx_product(T x) returns the product of a values distributed over a processor set.

It is important to understand that these functions require the involvement of every thread in a processor set. For example, the following code illustrates two attempts to sum a set of values over the odd numbered threads of a TEClass object.

TEClass C{ float x; float oddSum(){ if(MyProc()/2 != 0) //<<< error: only odd threads return pCxx_sum(x); //<<< are executing this line else return 0; } float tryAgain(){ float y; if(MyProc()/2 != 0) y = x; else y = 0; return pCxx_sum(y); } };

In the first attempt, oddSum(), only the odd numbered threads execute the sum reduction. Consequently, they will ``hang'' waiting for the even numbered threads to contribute their part. In the second case, tryAgain(), all threads execute the reduction and there is no problem.

Mon Nov 21 09:49:54 EST 1994