|
inlineconstexpr |
#include <eve/module/algo/algo/transform_reduce.hpp>
SIMD version of std::transform_reduce for a single range.
Configurable Callable Object performing a SIMD optimized version of the transform_reduce By default, the operation will be unrolled by a factor of 4, align memory accesses and perform conversions if needed.
Due to the nature of how SIMD algorithms work, the reduce operation has to be paired with its, neutral element. For example, for add you pass {add, zero} as zero is the identity for add. Instead of zero it can be beneficial to pass eve's constants like eve::zero, eve::one because sometimes the implementation can be improved.
Supports fuse_operations trait => map_op starts to take an extra parameter: current sum. Allows to use fma. Note that add operations and zero are still used and have to be correct.
Alternative Header
map_op to each element in the range rng and reduces the results along with the initial value init using regular addition as the reduce operation.map_op to each element in the range rng and reduces the results along with the initial value init using the add_zero reduce operation and neutral element.Parameters
rng: Relaxed input range to processinit: Initial value. Also type of init matches the result typemap_op: Transformation operationadd_zero: Pair of reduction operation (commutative/associative) and an identity (zero) for it. Default add_zero is {eve::plus, eve::zero}.Return value
init and map_op applied on each element of rng.init and map_op applied on each element of rng using add_zero.