The user code uses the reduction facility as given below. Each thread does the following:
// build the type specific reduction objectwhere ReducerType is a type of a binary function object which expects two arguments of type convertible to type T, and result type is a type convertible to type T. The constructor expects a Reduction object as an argument which is typically Rope::SelfRope().ReductionObj(). The class also exports a type called reducer_type which is the same as the actual argument for the template parameter ReducerType, and a type data_type which is basically type T. The () operator takes two arguments - reducer is a binary commutative and associative function object that is used in the reduction, and data is the contribution of the thread to the reduction operation. The () operator performs the actual reduction - each thread participating in the reduction operation invokes the () operator while in a data parallel computation. Note that all the threads should specify the same reducer_type argument. Making it a part of the () operator allows us to reuse the same reduction object for a different reduction operation easily.ReductionT<int, binary_function<int, int, int> >
red_obj(Rope::SelfRope().ReductionObj());
int my_contrib =
// sum reduction
int my_sum = red_obj(plus<int>, my_contrib);
// product reduction
int my_prod = red_obj(times<int>, my_contrib);