From Newsgroup: comp.arch
On 11/15/2026 1:49 PM, Thomas Koenig wrote:
Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
Thomas Koenig <tkoenig@netcologne.de> writes:
Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
Michael S <already5chosen@yahoo.com> writes:
How would you do it for non-associative arithmetic opcodes like
floating-point?
IIRC Mitch Alsup's answer to FP reduction is an accumulator with about >>>> 2100 bits or so.
...
It's not clear to me how one can accumulate 16 DP FP
values per cycle, like Zen5 can do.
Lots of pipelining and lots of full adders would be my guess.
One way to do it would be to add up the 16 operands using pairwise
addition, and then finally add the result to the accumulator. That
approach would cost a lot of transistors, however.
That would be quite inefficient. Far better to use full adders to
do 3:2 compressions (for example); six layers would compress 19
inputs down to 2, and that could be doable in a cycle or two
Afterwards, it is "only" an addition of two numbers with around
2100 bits (I forget the exact number).
But I suspect a lot of optimization can go into that sort of thing.
My thought here:
16x could be broken up into a lot of parallel 4-bit adders, each
producing effectively an 8-bit result.
Build one value from the low 4 bits of each result, and another from the
high bits;
Add them together, with full carry propagation.
This means the final main carry chain need only look like a simpler
2-input add.
Or, 3 input, if 16x against a running accumulator.
Cost and latency would still be very high though.
Though as can be noted, the latency of a carry-select adder seems to
scale with the log2 of the final width (rather than linearly), albeit
with a higher initial constant cost.
But, even then, for ~ 2 ^ 11.05, an 11.05 cost scale still pretty steep
in latency terms. Probably going to need 3 or 4 clock cycles for this
part...
Could maybe be more reasonable to use 512 bits or so and accept the possibility of "imperfect" results (say, if some of the values are too
small relative to the others and fall off the bottom).
Most cases, wont matter, unless the sum is approximately 0.
In the near zero situation, either one would still not match the results exactly with a sequential FADD sequence. Each sequential FADD would
perform its own rounding step (and adding a large and small value would
result in the small value dropping out immediately), and a large N-way
adder would not.
So, a large N-way adder in this scenario would be burdened with being
too accurate.
In this case though, likely the results between the two strategies would
be "closer" if using RTZ rather than RNE or similar. However,
variability would still exist in terms of the carry propagation from low
order results, which would invariably differ depending on which order
the values are added together.
It is kind of like the "curse" of single-rounded FMA:
While one can argue it is more accurate... Its results are not an exact
match for double-rounded FMA.
So, for a compiler, casually turning "x*y+z" into an FMA op is
invariably playing with fire even when it is both more accurate and
faster, because the fused and non-fused cases may produce different
results (and most ISA's tend not to have separate single and double
rounded FMA instructions with guarantees that each produces the
specified result).
But, a lesson one may learn from other contexts is:
If you need determinism, don't use floating point.
Deterministic results being more usually being the domain of fixed-point
math.
But, then a lot of ISAs don't have particularly efficient support for
large integer math.
And, the people designing SSE and AVX seemingly at no point decided to
grace the programmers with a convenient way to use them for doing 128 or
256 bit integer math (say, so that people can use it to do large
fixed-point calculations).
...
--- Synchronet 3.21e-Linux NewsLink 1.2