In many of our algorithms, one will notice that we do not necessarily maintain consistency of data in duplicated objects, like duplicated projected multivectors, or duplicated multiscalars. The reason for this is that often we will use the different copies of the duplicated object to accumulate contributions to a global result. Reducing these contribution to a single result is accomplished by a call to the PLA_Reduce routine: place HR here
place HR here It is assumed that for the reduce, the input object is a duplicated object, i.e., a duplicated projected (multi)vector or a duplicated multiscalar. Naturally, the global dimensions of input and output must conform, and again, one may need to cast a matrix or annotate the orientation of a matrix, as for the copy. It will almost always be the case that the reduction operator is summation, indicated by op = MPI_SUM. The reduction is an element-wise operation.
In the PLA_Reduce, it is assumed that the output object does not play a role in the reduction. It is only used to store the result. If the data in the output object is to take part in the computation that is part of the reduction, one can call the routine place HR here
place HR here It is assumed that the reduction performed by the PLA_Reduce_x routine is the summation. The shape parameter has the same meaning as in the PLA_Copy_x routine. The alpha parameter indicates that a multiple of the target object is to be summed to the result of summing the different instances of the input object together.
Notice that the call
is equivalent to the callPLA_Reduce( obj_from, MPI_SUM, obj_to );
PLA_Obj_datatype( obj_from, &datatype ); PLA_Obj_template( obj_from, &template ); PLA_Mscalar_create( datatype, PLA_ALL_ROWS, PLA_ALL_COLS, 1, 1, template, &zero ); PLA_Obj_set_to_zero( zero ); PLA_Reduce_x( PLA_SHAPE_GENERAL, obj_from, zero, obj_to );