Reductions

A reduction takes a vector or matrix and produces a scalar value; for example, a sum reduction computes the sum of all values in the vector or matrix.

DAPPLE includes many different kinds of reductions, for both vectors and matrices:

intVector A(N); int x; ... x = sum(A); // x = A[0] + A[1] + ... + A[N-1] x = any(A); // x = true iff ANY of A[i] != 0 for i in 0..N-1 x = all(A); // x = true iff ALL of A[i] != 0 for i in 0..N-1 x = n_nonzeros(A); // x = number of nonzero elements in A x = n_active(A); // x = number of active elements in A x = max_value(A); // x = max of A[i] for i in 0..N-1 x = min_value(A); // x = min of A[i] for i in 0..N-1 Only the active elements contribute to the reduction. sum(), max_value(), and min_value() do not apply to boolean vectors or matrices.

DAPPLE includes some reductions only for vectors:

intVector A(N); int x; ... x = first(A); // x = A[first_index(A)] x = first_index(A); // x = i if i is the smallest-numbered active virtual processor x = max_index(A); // x = i if A[i] is max of A[j] for j in 0..N-1 x = min_index(A); // x = i if A[i] is min of A[j] for j in 0..N-1 Again, only the active elements contribute to the reduction. max_index(), and min_index() do not apply to boolean vectors.