|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Accumulator policy for accumulating products of Values into an Acc. More...
#include <accumulator_traits.hpp>
Static Public Member Functions | |
| static void | clear (Acc &a) |
| Reset the accumulator to zero. | |
| static void | assign (Acc &a, const Value &v) |
| Set the accumulator to a single value. | |
| template<typename Result = Value> | |
| static Result | value (const Acc &a) |
| Round the accumulator out to Result (default: the element type Value), once, at the point the accumulated entry is consumed – giving single-rounding ("exact dot product") semantics when Acc is exact, and fusing the accumulate->output conversion when Result differs from Acc. | |
| static void | add_product (Acc &a, const Value &m, const Value &v) |
| a += m * v : the canonical accumulate-a-product primitive (a dot product / quire is a sum of products). | |
| static void | merge (Acc &a, const Acc &b) |
| a += b : combine two partial accumulators of the same reduction, e.g. | |
Accumulator policy for accumulating products of Values into an Acc.
Configuration 1 (plain acc += product): the primary template. The product is formed in Acc, so Acc wider than Value accumulates more accurately.
|
inlinestatic |
a += m * v : the canonical accumulate-a-product primitive (a dot product / quire is a sum of products).
Callers pass a negated multiplier for a subtraction (e.g. the LU elimination update). The product is formed in the accumulator precision Acc, so a wider Acc than Value (e.g. fp32 accumulate over bf16 elements) gains accuracy out of the box; this is a no-op cast and byte-identical when Acc == Value.
|
inlinestatic |
Set the accumulator to a single value.
|
inlinestatic |
Reset the accumulator to zero.
math::zero<Acc>(), i.e. Acc{0}, NOT a value-initialized Acc{}. The two agree for the built-in types but not in general: a logarithmic number system encodes 2^0 in its all-zero bit pattern, so Universal's lns{} is 1.0. With Acc{} here, every sum of products over an lns accumulator started at 1 – which, once householder() routed its default-path sum of squares through this function (#537), broke QR/LQ for lns outright.
|
inlinestatic |
a += b : combine two partial accumulators of the same reduction, e.g.
the per-thread or per-process partials of a parallel dot product. For this configuration it is an ordinary add, one rounding; for an exact super-accumulator it is exact, which is what makes a parallel reduction independent of how the terms were partitioned. Offered only when Acc has a +=, so mergeable_accumulator is an accurate test.
|
inlinestatic |
Round the accumulator out to Result (default: the element type Value), once, at the point the accumulated entry is consumed – giving single-rounding ("exact dot product") semantics when Acc is exact, and fusing the accumulate->output conversion when Result differs from Acc.