Thread View: comp.arch
180 messages
180 total messages
Page 3 of 4
Started by Robert Finch
Sun, 08 Nov 2026 12:39
Page 3 of 4 • 180 total messages
Re: CISC are not "unreduced"
Author: Michael S
Date: Sat, 14 Nov 2026 16:36
Date: Sat, 14 Nov 2026 16:36
42 lines
3461 bytes
3461 bytes
On Fri, 13 Nov 2026 21:51:25 GMT anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: > >Stefan Monnier <monnier@iro.umontreal.ca> writes: > >>And how is the answer affected by subsequent operations accessing > >>the same memory location? > > > >Just the same as on a RISC: You run register allocation before > >instruction selection, so if a value is accessed several times and > >registers are available, the value will be allocated into a register, > >on both architecture styles. > > Actually, normally register allocation is performed after instruction > selection. So if the operand is a local variable that can be in a > register (no address taken), it will be assumed to be in a register, > for instruction selection. Later the register allocator actually > tries to allocate a register for the variable, and if not, on a RISC > spill code is inserted with additional live ranges, and the register > allocator has to run again (at least that's the way that Chaitin and > Briggs described this). On a VAX, you just use a memory operand for > those variables that do not fit into registers. > > >>> vVM is a microarchitectural mechanism, > >> > >>Is it? I use it as a way to refer to the design of VEC+LOOP (which > >>is so designed as to allow a particular micro-architecture). > > > >Architecturally, LOOP is a branch (maybe it also deals with the loop > >counter?), and VEC is a noop AFAIK. > > And the fact that VVM is a microarchitectural mechanism is it's > beauty. The semantics are just the same as for the whole loop without > VVM. > > - anton How would you do it for non-associative arithmetic opcodes like floating-point?
Re: CISC are not "unreduced"
Author: Anton Ertl
Date: Sat, 14 Nov 2026 17:53
Date: Sat, 14 Nov 2026 17:53
12 lines
1977 bytes
1977 bytes
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. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: CISC are not "unreduced"
Author: Michael S
Date: Sat, 14 Nov 2026 18:16
Date: Sat, 14 Nov 2026 18:16
16 lines
2201 bytes
2201 bytes
On Sat, 14 Nov 2026 17:53:07 GMT anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > 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. > > - anton It still does not produce the same result as sequiential code. May be, better, but not the same.
Re: CISC are not "unreduced"
Author: Anton Ertl
Date: Sat, 14 Nov 2026 18:32
Date: Sat, 14 Nov 2026 18:32
31 lines
2814 bytes
2814 bytes
Michael S <already5chosen@yahoo.com> writes: >On Sat, 14 Nov 2026 17:53:07 GMT >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: >> 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. >> >> - anton > >It still does not produce the same result as sequiential code. Of course the (architectural) code does not add an FP value with another FP value, instead it always adds to the accumulator; so the programmer or compiler has to know what they are doing. Adding to the accumulator produces an exact result. So the order in which you add is irrelevant. A way to do it in parallel would be to have 16 accumulators that each can do one addition per cycle, and add them all in the end. But that would be very expensive to implement. Maybe there is a clever way to add more than one value per cycle. It's less clear to me if one can use an accumulator for multiplicative reduction and if that can be parallelized, but it's rare AFAIK, so it may not be so important to make it fast. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: CISC are not "unreduced"
Author: Michael S
Date: Sat, 14 Nov 2026 18:56
Date: Sat, 14 Nov 2026 18:56
46 lines
3205 bytes
3205 bytes
On Sat, 14 Nov 2026 18:32:08 GMT anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > Michael S <already5chosen@yahoo.com> writes: > >On Sat, 14 Nov 2026 17:53:07 GMT > >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > >> 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. > >> > >> - anton > > > >It still does not produce the same result as sequiential code. > > Of course the (architectural) code does not add an FP value with > another FP value, instead it always adds to the accumulator; so the > programmer or compiler has to know what they are doing. > O.k. > Adding to the accumulator produces an exact result. So the order in > which you add is irrelevant. > I think that it is only almost irrelevant. Overflows still can differ. Or may be not, if you have few more bits? > A way to do it in parallel would be to have 16 accumulators that each > can do one addition per cycle, and add them all in the end. But that > would be very expensive to implement. Maybe there is a clever way to > add more than one value per cycle. > > It's less clear to me if one can use an accumulator for > multiplicative reduction and if that can be parallelized, but it's > rare AFAIK, so it may not be so important to make it fast. > > - anton FMA reduction is the most common by far. But Horner scheme is not exactly unseen of.
Re: vector length CSR?
Author: MitchAlsup
Date: Sat, 14 Nov 2026 19:07
Date: Sat, 14 Nov 2026 19:07
40 lines
2963 bytes
2963 bytes
Thomas Koenig <tkoenig@netcologne.de> posted:
> MitchAlsup <user5857@newsgrouper.org.invalid> schrieb:
> > Thomas Koenig <tkoenig@netcologne.de> posted:
> >
> >> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> >> > On 11/11/2026 10:53 PM, Thomas Koenig wrote:
> >> >> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> >> >>
> >> >>> It seems the
> >> >>> advantage of an SIMD approach is the large set of addressable registers
> >> >>> that can be used to keep data readily available for future use.
> >> >>
> >> >> Plus, you can do wide permutes, and it can also help with reduction.
> >> >> Having mask for reducing operations also helps (or a length field).
> >> >>
> >> >> There is one other thing that VVM does not do natively: Reductions
> >> >> on commutative operators.
> >> >
> >> > When we talked about reductions on VVM in a thread some months ago, I
> >> > thought Mitch said that VVM could parallelize such reductions, including
> >> > handling an array size that was not a multiple of the number of
> >> > functional units used (i.e. the degree of parallelism), and combining
> >> > the partial sums at the end. As I have said, I am not a hardware guy
> >> > but that sounded impressive and I don't know how he does that.
> >>
> >> I don't see this in the manuals, at least. Mitch, did I miss it?
> >
> > The augend input to FMAC has a special feed-forward mechanism
> > {µArchitectural}
> >
> > I may have to do something special when running 4-wide.
>
>
> So, in order to do efficient reductions, the vectorized VVM
> loops will also have to be unrolled, with a final horizontal
> reduction step (like I wrote above).
I think not. I may need to build a reduction summer and recognize
the pattern from asm code.
Re: CISC are not "unreduced"
Author: Terje Mathisen
Date: Sat, 14 Nov 2026 22:38
Date: Sat, 14 Nov 2026 22:38
28 lines
3038 bytes
3038 bytes
Anton Ertl wrote: > 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. A superaccumulator using fully redundant storage (bits + carries) can add another input in a small fraction of a clock cycle, you just need parallel aligners to allow mantissa bits to enter in the right spot. Probably not 16 doubles every clock cycle, but much more than one. That Zen5 needs a pair of 512-bit accumulators to do it, right? Total number of accumulator bits are in the same ballpark, but a Superaccumulator will give the correct/exact answer totally independent of the aggregation order, something which you definitely cannot claim for that 16-wide Zen5 AVX-512 version. (For the last claim to be true, you actually need a fair number of extra bits so that you cannot get a spurious intermediate overflow due to a particularly bad operand ordering.) Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching"
Re: CISC are not "unreduced"
Author: Anton Ertl
Date: Sun, 15 Nov 2026 06:56
Date: Sun, 15 Nov 2026 06:56
33 lines
2887 bytes
2887 bytes
Michael S <already5chosen@yahoo.com> writes: >On Sat, 14 Nov 2026 18:32:08 GMT >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: >> Adding to the accumulator produces an exact result. So the order in >> which you add is irrelevant. >> > >I think that it is only almost irrelevant. Overflows still can differ. >Or may be not, if you have few more bits? Yes. But how many more bits? I guess you have to use on the order of 60 extra bits if you want to support accumulating over several years without forcing overflow detection in the meantime. Alternatively, the architecture could require an explicit overflow-check instruction every n adds to the accumulator, and then the additions could not be reordered wrt. this instruction. 60 extra bits looks more attractive to me. >But Horner scheme is not exactly unseen of. How would it be sped up in SIMD? Un-Horner it and compute all the powers in parallel, then multiply with the coefficients in parallel, then add up the summands with pairwise addition? With VVM, the parallel parts should be relatively straightforward to do, and then the pairwise addition parts would be done with the reduction support, whatever it is. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: CISC are not "unreduced"
Author: Anton Ertl
Date: Sun, 15 Nov 2026 07:18
Date: Sun, 15 Nov 2026 07:18
33 lines
2968 bytes
2968 bytes
Terje Mathisen <terje.mathisen@tmsw.no> writes: >Anton Ertl wrote: >> 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. > >That >Zen5 needs a pair of 512-bit accumulators to do it, right? You use n*2 ZMM (512-bit) registers to accumulate stuff in the main loop, where n>= the latency in cycles of the fadd (or fma, if that is used). The latency is 2 cycles for Zen6, but higher for Zen5. In the end you use pairwise addition with ld(16*n) levels to reduce these n*2 ZMM registers to a single FP value. >Total number of accumulator bits are in the same ballpark, but a >Superaccumulator will give the correct/exact answer totally independent >of the aggregation order, something which you definitely cannot claim >for that 16-wide Zen5 AVX-512 version. Yes. So one has to code this explicitly, or, when using compiler auto-vectorization, use a flag like -ffast-math to tell the compiler that you don't care for bit-accurate results and that it can re-associate FP addition and multipliation. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: CISC are not "unreduced"
Author: Michael S
Date: Sun, 15 Nov 2026 07:40
Date: Sun, 15 Nov 2026 07:40
43 lines
3329 bytes
3329 bytes
On Sun, 15 Nov 2026 06:56:55 GMT anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > Michael S <already5chosen@yahoo.com> writes: > >On Sat, 14 Nov 2026 18:32:08 GMT > >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > >> Adding to the accumulator produces an exact result. So the order > >> in which you add is irrelevant. > >> > > > >I think that it is only almost irrelevant. Overflows still can > >differ. Or may be not, if you have few more bits? > > Yes. But how many more bits? I guess you have to use on the order of > 60 extra bits if you want to support accumulating over several years > without forcing overflow detection in the meantime. > > Alternatively, the architecture could require an explicit > overflow-check instruction every n adds to the accumulator, and then > the additions could not be reordered wrt. this instruction. 60 extra > bits looks more attractive to me. > > >But Horner scheme is not exactly unseen of. > > How would it be sped up in SIMD? Un-Horner it and compute all the > powers in parallel, then multiply with the coefficients in parallel, > then add up the summands with pairwise addition? > May be that. May be, if app allows, by evaluation of several polys in parallel. May be, something completely different. But with SIMD explicit, it's just another engineering task. With VMM you don't know what to do. Not unlike with magic autovec by compiler. > With VVM, the parallel parts should be relatively straightforward to > do, and then the pairwise addition parts would be done with the > reduction support, whatever it is. > > - anton
Re: CISC are not "unreduced"
Author: Thomas Koenig
Date: Sun, 15 Nov 2026 11:25
Date: Sun, 15 Nov 2026 11:25
22 lines
2424 bytes
2424 bytes
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. See https://en.wikipedia.org/wiki/Karlsruhe_Accurate_Arithmetic , a development of the group of Prof. Kuisch at Karlsruhe, which was implemented on an IBM 4361. (I had to do my basic programming courses on a Pascal version which implemented this >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. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: CISC are not "unreduced"
Author: Anton Ertl
Date: Sun, 15 Nov 2026 17:03
Date: Sun, 15 Nov 2026 17:03
22 lines
2365 bytes
2365 bytes
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. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: vector length CSR?
Author: EricP
Date: Sun, 15 Nov 2026 17:36
Date: Sun, 15 Nov 2026 17:36
113 lines
6206 bytes
6206 bytes
On 2026-Nov-13 02:20, Anton Ertl wrote: > EricP <ThatWouldBeTelling@thevillage.com> writes: >> Wikipedia mentions an earlier array processor, the 3838 >> >> https://www.bitsavers.org/pdf/ibm/3838/Array_Processor_Status_Report_Jan76.pdf >> >> "HARDWARE >> 1 MEGABYTE BULK STORE (24K POINTS, 1M-PURCHASE) >> 24/48 BIT FRACTION >> ARITHMATIC ELEMENT >> 2 ADDERS >> 1 MULTIPLIER >> HIGHLY PIPELINED >> 100 NS CYCLE >> 2-1000 WORD WORKING STORES >> MICROPROGRAMMED >> SHORT/LONG PRECISION >> No ERROR CHECKING >> CONTROL PROCESSOR >> 2 MICRO SECOND CYCLE >> CONTROLS DATA TRANSFERS >> HOST TO BULK STORE (3M B/S) >> BULK STORE TO WORKING STORE (40M B/S) >> PROVIDES OVERLAP >> 370 CHANNEL INTERFACE > > So that's around the same time as Cray-1, maybe inspired by earlier > pipelined vector machines by TI and CDC. > > The cycle time is 8 times longer than that of the Cray-1, so the > Cray-1 probably resulted in very low sales for the 3838. Both the 2938 and 3838 documents are internal marketing docs. Both contain confidential comparisons to multiple IBM systems and competitors. They seem to be trying to figure out who might buy their kit. 3838 doc compares Cray-1, CDC 7600, Cyber 175, Amdahl 470/V6 to IBM 195, 168 AP, 168 MP, 168 UP, 158 MP, 158 UP, 145 and the base speed is 1.0 for a 168 UP, Cray-1 is 10 to 14 times faster, 195 is 2 to 5 times faster. I don't see where they compare 3838 vector performance. > The use of the channels for these kinds of accelerators is > interesting. Maybe this was the inspiration for the way that the SPEs > in the Cell Broadband Engine (used in, e.g., the Playstation 3) > interface to the rest of the system. I'll ask Michael Gschwind when I > see him (he occasionally visits his alma mater). Actually the 2938 document has some analysis of its pros and cons, and the channel attachment is part of its cons as it bottlenecks the whole thing. The 2938 only allowing single precision is another. > While reading up on Cell and Michal Gschwind, I found the following, which leads us back to vector extensions on S390x: > > <https://en.wikipedia.org/wiki/Michael_Gschwind#SIMD_Parallel_vector_architecture> > |To enable efficient compilation, Gschwind proposed the implementation > |of merged scalar and vector execution units, eliminating the cost of > |copies between scalar and vectorized code, and simplifying compiler > |architecture by resolving phase ordering problems in compilers. > | > |The Cell's accelerator cores (Synergistic Processor Unit SPU) contain > |a single 128 element register file with 128 bit per register. > |Registers may hold either scalar or a vector of multiple values.[66] > |The simplified cost model leads to significantly improved > |vectorization success, improving overall program performance and > |efficiency.[67] > | > |The vector-scalar approach was also adopted by the IBM Power VSX > |(Vector Scalar Extension) SIMD instructions,[68] BlueGene/Q vector > |instructions[69][70] and System/z mainframe vector instruction > |set,[42][71] the design of all three IBM vector-scalar architectures > |having been led by Gschwind as Chief Architect for IBM System > |Architecture. > > So IBM reuses architectural (and probably implementation) work across > its various architectures. This has also happened with decimal FP > appearing on Power and S390x. So the S390x vector stuff probably was > not demand-driven, but supply-driven. One would have to compare the > vector extensions of the various architectures (and architecture > versions) to see if there are any parts that occur only on some of > them and where they appear first. One can assume that demand puts the > feature in the first architecture, and then supply puts it in the > others. > >> It mentions an earlier array processor, the 2938, note the date of 1966 >> >> https://www.bitsavers.org/pdf/ibm/2938/Functional_Objectives_for_an_Array_Processor_Nov66.pdf >> >> "August 1967 >> THE 2938 ARRAY PROCESSOR >> >> The 2938 Array Processor is a peripheral processor for attachment to >> System/360 Models 44, 65, and 75. >> ... >> The arithmetic unit of the 2938 is a multiplication and addition unit which >> performs the operation Z = U*X +- Y. The unit operates on System/360 >> short-operand floating-point data only. >> ... >> the combined multiply and add time is effectively 200 nanoseconds, >> whereas the total time for a particular set of U, X I and Y to pass >> through the arithmetic unit to form the resultant Z is approximately >> 800 nanoseconds." > > Should I interpret that as 800ns latency with a throughput of 1/200ns? > That would then be an early case of a pipelined vector processor. > > - anton I'm guessing both are pipelined FPU's which run at their 100/200 ns clocks if working with register operands but stall with 3 us memory accesses. Also the channel overhead doesn't help, plus it signals completion with an interrupt and I've never heard anything nice about 370 interrupt timing.
Re: vector length CSR?
Author: EricP
Date: Sun, 15 Nov 2026 17:45
Date: Sun, 15 Nov 2026 17:45
75 lines
5128 bytes
5128 bytes
On 2026-Nov-13 11:36, Stephen Fuld wrote: > On 11/13/2026 7:28 AM, EricP wrote: >> On 2026-Nov-12 15:43, Robert Finch wrote: > > snip >>> IDK how the belt works. Sounds like a familiar architecture with a conveyor belt of operands bolted on? When does the belt advance? At one point I was trying to re-organize the re-order buffer like a belt. Queueing at one end and committing at the other. The idea was to use a shift register for the re-order buffer. >> >> Its like an accumulator register in that it is the default result output register >> but it has multiple slots that logically act like a shift register array. >> As each new result is output the one at the far end falls off the belt. >> Like a regular register file it is logically committed when a result is written out. > > Yes. I look at it as sort of a fixed length stack (put new elements at the top an push all other elements down) with the enhancement that you can address, for reading only, stack elements other than the top. > > >> Internally it can be implemented as a shift register, or as a circular buffer, >> or as a fixed physical register file with a circular renamer. > > IIRC, the Mill implements it using the output buffers of each functional unit plus each having a "position register" of log2 (number of FUs) bit register that gives that register's position within the stack. Each instruction sets the register corresponding to that instruction to TOS and increments all the other position registers. No actual separate register set and no shifting. I'm borrowing it's architectural model of relative register addressing. Yeah, I skipped over their implementation as I didn't have a good mental picture of exactly how it works. AIUI each Mill FU has a small set of output registers which gives a private write port to its bank. But it also has something to do with instruction latency. And it tracks where each belt slot resides (in effect a renamer). But what happens when all the small set of output registers are full - where does the next output go? Seems like they would have to shuffle everything about. Since each output register can hold a belt value, Mill requires a giant crossbar to route any output register to each FU as a source operand. This looked to me like a register file with a read port for each belt slot, for each source operand. It wasn't clear to me where the benefit of this approach was. I chock this up to me not grokking their internal details. Links to the belt patents are below. >> The difference is in the programming model. >> A regular scalar RF (SRF) uses absolute register number addressing >> while a belt register file (BRF) uses relative addressing. > > Yes. > >> >> With SRF when you write to R1 and that's where the result stays. >> If you want to retain R1 for a later loop iteration then you have to copy it >> to R2 or unroll a loop and assign a different register to each iteration. >> >> With BRF each result is saved to belt[0] and older ones shift up. >> If the belt is 32 slots then belt[31] falls off and is lost unless saved first. > > Yes, although with the Mill (IIRC), the "shift" is logical not physical. Yes, I'm referring to an architectural or logical belt. It is also possible to do an OoO belt with more physical registers than the logical number of belt slots. If anyone is interested the Mill patents are here: https://patents.google.com/?assignee=Mill+Computing+Inc&sort=new The two that seem relevant to the belt operation are: US20150347142A1 - Computer Processor Employing Split Crossbar Circuit For Operand Routing And Slot-Based Organization Of Functional Units https://patents.google.com/patent/US20150370738A1/en US20150370570A1 - Computer Processor Employing Temporal Addressing For Storage Of Transient Operands https://patents.google.com/patent/US20150370570A1/en
Re: CISC are not "unreduced"
Author: MitchAlsup
Date: Sun, 15 Nov 2026 18:42
Date: Sun, 15 Nov 2026 18:42
45 lines
3255 bytes
3255 bytes
Michael S <already5chosen@yahoo.com> posted: > On Fri, 13 Nov 2026 21:51:25 GMT > anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > > > anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: > > >Stefan Monnier <monnier@iro.umontreal.ca> writes: > > >>And how is the answer affected by subsequent operations accessing > > >>the same memory location? > > > > > >Just the same as on a RISC: You run register allocation before > > >instruction selection, so if a value is accessed several times and > > >registers are available, the value will be allocated into a register, > > >on both architecture styles. > > > > Actually, normally register allocation is performed after instruction > > selection. So if the operand is a local variable that can be in a > > register (no address taken), it will be assumed to be in a register, > > for instruction selection. Later the register allocator actually > > tries to allocate a register for the variable, and if not, on a RISC > > spill code is inserted with additional live ranges, and the register > > allocator has to run again (at least that's the way that Chaitin and > > Briggs described this). On a VAX, you just use a memory operand for > > those variables that do not fit into registers. > > > > >>> vVM is a microarchitectural mechanism, > > >> > > >>Is it? I use it as a way to refer to the design of VEC+LOOP (which > > >>is so designed as to allow a particular micro-architecture). > > > > > >Architecturally, LOOP is a branch (maybe it also deals with the loop > > >counter?), and VEC is a noop AFAIK. > > > > And the fact that VVM is a microarchitectural mechanism is it's > > beauty. The semantics are just the same as for the whole loop without > > VVM. > > > > - anton > > How would you do it for non-associative arithmetic opcodes like > floating-point? > As Ivan would say:: Not Yet Filed. > >
Re: CISC are not "unreduced"
Author: MitchAlsup
Date: Sun, 15 Nov 2026 18:51
Date: Sun, 15 Nov 2026 18:51
32 lines
2655 bytes
2655 bytes
Terje Mathisen <terje.mathisen@tmsw.no> posted: > Anton Ertl wrote: > > 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. > > A superaccumulator using fully redundant storage (bits + carries) can > add another input in a small fraction of a clock cycle, you just need > parallel aligners to allow mantissa bits to enter in the right spot. Yes > Probably not 16 doubles every clock cycle, but much more than one. That > Zen5 needs a pair of 512-bit accumulators to do it, right? 16 inputs per cycle in carry-save form is only 8-gates of delay for accumulation. > Total number of accumulator bits are in the same ballpark, but a > Superaccumulator will give the correct/exact answer totally independent > of the aggregation order, something which you definitely cannot claim > for that 16-wide Zen5 AVX-512 version. (For the last claim to be true, > you actually need a fair number of extra bits so that you cannot get a > spurious intermediate overflow due to a particularly bad operand ordering.) > > Terje >
Re: CISC are not "unreduced"
Author: MitchAlsup
Date: Sun, 15 Nov 2026 19:00
Date: Sun, 15 Nov 2026 19:00
34 lines
2654 bytes
2654 bytes
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted: > Michael S <already5chosen@yahoo.com> writes: > >On Sat, 14 Nov 2026 18:32:08 GMT > >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > >> Adding to the accumulator produces an exact result. So the order in > >> which you add is irrelevant. > >> > > > >I think that it is only almost irrelevant. Overflows still can differ. > >Or may be not, if you have few more bits? > > Yes. But how many more bits? I guess you have to use on the order of > 60 extra bits if you want to support accumulating over several years > without forcing overflow detection in the meantime. > > Alternatively, the architecture could require an explicit > overflow-check instruction every n adds to the accumulator, and then > the additions could not be reordered wrt. this instruction. 60 extra > bits looks more attractive to me. > > >But Horner scheme is not exactly unseen of. > > How would it be sped up in SIMD? Un-Horner it and compute all the > powers in parallel, then multiply with the coefficients in parallel, > then add up the summands with pairwise addition? See: Estrin's method--it tree-ifies Horner. > With VVM, the parallel parts should be relatively straightforward to > do, and then the pairwise addition parts would be done with the > reduction support, whatever it is. > > - anton
Re: CISC are not "unreduced"
Author: Thomas Koenig
Date: Sun, 15 Nov 2026 19:49
Date: Sun, 15 Nov 2026 19:49
31 lines
2875 bytes
2875 bytes
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. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: vector length CSR?
Author: George Neuner
Date: Tue, 17 Nov 2026 19:40
Date: Tue, 17 Nov 2026 19:40
48 lines
3379 bytes
3379 bytes
On Fri, 13 Nov 2026 15:19:04 +0100, Terje Mathisen <terje.mathisen@tmsw.no> wrote: >George Neuner wrote: >> WRT the Mill, I think people here may be missing that it supported >> short-vector-SIMD, and that a vector operand on its belt was a single >> element [of whatever width] - not a bunch of scalars that magically >> would be operated on together. > >Yes and no, see below. >> >> According to Ivan, the Mill's instruction set supported quad FP and >> 128-bit short vector SIMD. >> [Similar width as Intel's SSE2, though SSE_ doesn't do quad FP.] >> >> He spoke about the potential for [more lanes] wider SIMD and made >> clear that, whatever widths were supported, the "operands" still would >> be treated as single belt elements. >> >The real magic sauce is the fact that belt operands carries metadata, >including not just byte/short/int/long/float/double/etc designators, but >also a vector vs scalar boolean, as well as None and NAR (Not A Result, >similar to NaN but even more powerful). > >This means that Mill only needs a single ADD instruction, it >automagically handles vector/scalar/multiple element sizes based on >those metadata bits. > >If you want to treat 16 bytes, loaded as 16 unsigned bytes, as if they >were 8 int16_t's, then you need to convert the entry. Yes, but not what I was referring to. I'm paraphrasing, but Ivan said that if someone wanted [to pay for] a Mill with, e.g., multiple 1024-bit SIMD units, he'd be happy to give it to them. He also said "the belt holds operands" - more or less a direct quote - and we know the belt basically is a set of dynamically renamed latch registers, that means that: if there are 1024-bit wide vector units, then there must be 1024-bit wide operand values. And, of course, also operands of whatever other widths are supported. >Terje > >PS. Expect to see Mill return to being generally visible in the near future.
Re: vector length CSR?
Author: Terje Mathisen
Date: Tue, 17 Nov 2026 20:44
Date: Tue, 17 Nov 2026 20:44
60 lines
4095 bytes
4095 bytes
George Neuner wrote: > On Fri, 13 Nov 2026 15:19:04 +0100, Terje Mathisen > <terje.mathisen@tmsw.no> wrote: > >> George Neuner wrote: >>> WRT the Mill, I think people here may be missing that it supported >>> short-vector-SIMD, and that a vector operand on its belt was a single >>> element [of whatever width] - not a bunch of scalars that magically >>> would be operated on together. >> >> Yes and no, see below. >>> >>> According to Ivan, the Mill's instruction set supported quad FP and >>> 128-bit short vector SIMD. >>> [Similar width as Intel's SSE2, though SSE_ doesn't do quad FP.] >>> >>> He spoke about the potential for [more lanes] wider SIMD and made >>> clear that, whatever widths were supported, the "operands" still would >>> be treated as single belt elements. >>> >> The real magic sauce is the fact that belt operands carries metadata, >> including not just byte/short/int/long/float/double/etc designators, but >> also a vector vs scalar boolean, as well as None and NAR (Not A Result, >> similar to NaN but even more powerful). >> >> This means that Mill only needs a single ADD instruction, it >> automagically handles vector/scalar/multiple element sizes based on >> those metadata bits. >> >> If you want to treat 16 bytes, loaded as 16 unsigned bytes, as if they >> were 8 int16_t's, then you need to convert the entry. > > Yes, but not what I was referring to. > > I'm paraphrasing, but Ivan said that if someone wanted [to pay for] a > Mill with, e.g., multiple 1024-bit SIMD units, he'd be happy to give > it to them. > > He also said "the belt holds operands" - more or less a direct quote - > and we know the belt basically is a set of dynamically renamed latch > registers, that means that: if there are 1024-bit wide vector units, > then there must be 1024-bit wide operand values. Right. > > And, of course, also operands of whatever other widths are supported. Every belt element is of a fixed size for a given implementation, and for vector operands, the full width is always used. For scalar, only the first (low order/LE) 8/16/32/64 bits are actually used, the rest is carry-on luggage which never produce any visible results.I don't remember exactly but I would assume any attempt to access undefined parts will either trap or result in None. Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching"
Re: vector length CSR?
Author: MitchAlsup
Date: Tue, 17 Nov 2026 20:57
Date: Tue, 17 Nov 2026 20:57
54 lines
3392 bytes
3392 bytes
George Neuner <gneuner2@comcast.net> posted: > On Fri, 13 Nov 2026 15:19:04 +0100, Terje Mathisen > <terje.mathisen@tmsw.no> wrote: > > >George Neuner wrote: > >> WRT the Mill, I think people here may be missing that it supported > >> short-vector-SIMD, and that a vector operand on its belt was a single > >> element [of whatever width] - not a bunch of scalars that magically > >> would be operated on together. > > > >Yes and no, see below. > >> > >> According to Ivan, the Mill's instruction set supported quad FP and > >> 128-bit short vector SIMD. > >> [Similar width as Intel's SSE2, though SSE_ doesn't do quad FP.] > >> > >> He spoke about the potential for [more lanes] wider SIMD and made > >> clear that, whatever widths were supported, the "operands" still would > >> be treated as single belt elements. > >> > >The real magic sauce is the fact that belt operands carries metadata, > >including not just byte/short/int/long/float/double/etc designators, but > >also a vector vs scalar boolean, as well as None and NAR (Not A Result, > >similar to NaN but even more powerful). > > > >This means that Mill only needs a single ADD instruction, it > >automagically handles vector/scalar/multiple element sizes based on > >those metadata bits. > > > >If you want to treat 16 bytes, loaded as 16 unsigned bytes, as if they > >were 8 int16_t's, then you need to convert the entry. > > Yes, but not what I was referring to. > > I'm paraphrasing, but Ivan said that if someone wanted [to pay for] a > Mill with, e.g., multiple 1024-bit SIMD units, he'd be happy to give > it to them. > > He also said "the belt holds operands" - more or less a direct quote - > and we know the belt basically is a set of dynamically renamed latch > registers, that means that: if there are 1024-bit wide vector units, > then there must be 1024-bit wide operand values. Minor quibble: if you have 1024-bit wide SIMD units, you need a way to read and write 1024-bits as operands and results. This does NOT end up using 1024-bit registers, necessarily. > > And, of course, also operands of whatever other widths are supported. > > > >Terje > > > >PS. Expect to see Mill return to being generally visible in the near future.
Re: vector length CSR?
Author: BGB
Date: Tue, 17 Nov 2026 23:40
Date: Tue, 17 Nov 2026 23:40
153 lines
8316 bytes
8316 bytes
On 11/17/2026 2:57 PM, MitchAlsup wrote: > George Neuner <gneuner2@comcast.net> posted: > >> On Fri, 13 Nov 2026 15:19:04 +0100, Terje Mathisen >> <terje.mathisen@tmsw.no> wrote: >> >>> George Neuner wrote: >>>> WRT the Mill, I think people here may be missing that it supported >>>> short-vector-SIMD, and that a vector operand on its belt was a single >>>> element [of whatever width] - not a bunch of scalars that magically >>>> would be operated on together. >>> >>> Yes and no, see below. >>>> >>>> According to Ivan, the Mill's instruction set supported quad FP and >>>> 128-bit short vector SIMD. >>>> [Similar width as Intel's SSE2, though SSE_ doesn't do quad FP.] >>>> >>>> He spoke about the potential for [more lanes] wider SIMD and made >>>> clear that, whatever widths were supported, the "operands" still would >>>> be treated as single belt elements. >>>> >>> The real magic sauce is the fact that belt operands carries metadata, >>> including not just byte/short/int/long/float/double/etc designators, but >>> also a vector vs scalar boolean, as well as None and NAR (Not A Result, >>> similar to NaN but even more powerful). >>> >>> This means that Mill only needs a single ADD instruction, it >>> automagically handles vector/scalar/multiple element sizes based on >>> those metadata bits. >>> >>> If you want to treat 16 bytes, loaded as 16 unsigned bytes, as if they >>> were 8 int16_t's, then you need to convert the entry. >> >> Yes, but not what I was referring to. >> >> I'm paraphrasing, but Ivan said that if someone wanted [to pay for] a >> Mill with, e.g., multiple 1024-bit SIMD units, he'd be happy to give >> it to them. >> >> He also said "the belt holds operands" - more or less a direct quote - >> and we know the belt basically is a set of dynamically renamed latch >> registers, that means that: if there are 1024-bit wide vector units, >> then there must be 1024-bit wide operand values. > > Minor quibble: if you have 1024-bit wide SIMD units, you need a way to > read and write 1024-bits as operands and results. This does NOT end up > using 1024-bit registers, necessarily. Yes. Can note that I am typically doing 128-bit SIMD and ALU ops with 64-bit registers. Theoretically, the current approach could be extended to 256-bits, though if taking my originally imagined approach would incur a penalty for 64-bit usage (which would then be faking 64-bit operations via 3R1W patterns on 128-bit register ports); and would imply likely needing to expand the register file as 64x 64-bit GPRs wouldn't go very far when the occasional 256-bit operation is thrown in the mix. Don't claim that it cleanly scales up though, as my design was built fairly explicitly on the assumption that this stuff either doesn't really scale, or that one switches to a dedicated wider-vector SIMD approach (more like RV-V or similar) when needed (but, that I will wager that most code will not need this, most of the time; even when the HW has the capability to do so). Well, in other news, my experiments with Cinepak-style VQ video compression are now going better than initial results suggested: Very early experiments: "Meh, this is kinda going to suck". More recent: It is beating my other designs and can do 720p and 1080p video at ~ 1 Mbps and not totally fall on its face. While decoding isn't as fast as some of my color-cell codecs, it isn't too bad either. Can give better image quality and better Q/bpp. It is also beating out my prior experiment of "try to use my UPIC format as a makeshift H.261 style video codec" (which worked OK for 360p at 1 Mbps; fell on its face for 720p). Granted, UPIC was mostly meant as a "cheaper to decode but more capable JPEG alternative" (wanted the option for lossless, and an alpha channel; also needed to be faster to decode than JPEG and PNG; ...). Most other modern "JPEG replacements" had more focused on compression, rather than cases where it was too slow. My current codec experiment could be useful as a lossy image codec as well (also falls into the "faster than JPEG" bucket); though would need to come up with some reasonable way to encode an alpha channel. Current design doesn't address this; could use another luma-only sub-image to encode an Alpha layer, but this is lame. Likely alternatives being to encode it as special blocks (similar to skip handling) or as a special out-of-gamut color. Well, and 1080p video decoding uses reasonably modest CPU power for a single-threaded decoder. Not tested 2160p yet. Theoretically the codec can handle this in isolation, but also this is likely pushing it for actual playback. Can also note that "Media Player Classic" in the case of 1080p video, while mostly staying under 1% CPU (where the decode is happening), is apparently pushing like 30% on the GPU to actually get the frames displayed. Well, now encoding an experiment where it up-scales the video to 4K as a test so I can see whether the playback handles it. It is going to be a little while though, as my encoder isn't exactly all that fast... What is has in decode speed is paid for in a painfully slow encoder (a faster encoder could be possible, but then Q/bpp would basically be horrible if one is mostly just using it for pushing minimally quantized YUV data or similar). Most of the compression magic depends on "codebooks", but the process of codebook lookups, or encode time curation of blocks to "pre-warm" the state for P-Frames, isn't particularly fast. Well, came up with a trick to improve compression some: During encoding it keeps track of which codebook patterns are used most frequently (say, tracking the top 16K patterns or so), and then during each I-Frame it emits a "prolog" blob that is decoded prior to the main image data for the frame, which mostly contains a bunch of the most commonly used codebook patterns (selecting the top 1K patterns). This adds a little cost to the I-Frame, but generally allows making the P-Frames cheaper, without having too much impact on decode speed, by allowing the P-Frame to reference previously seen patterns rather than have to re-encode them every frame. So, in this case, for a 4K frame the encoder is currently going along at roughly 1 frame per second. (time skip) Well, took a while to encode, but seems like, yes, 4K video playback works with a single-threaded decoder via VFW. ... >> >> And, of course, also operands of whatever other widths are supported. >> >> >>> Terje >>> >>> PS. Expect to see Mill return to being generally visible in the near future.
Re: vector length CSR?
Author: Stephen Fuld
Date: Thu, 19 Nov 2026 16:45
Date: Thu, 19 Nov 2026 16:45
30 lines
2703 bytes
2703 bytes
On 11/11/2026 10:53 PM, Thomas Koenig wrote: > Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: > >> It seems the >> advantage of an SIMD approach is the large set of addressable registers >> that can be used to keep data readily available for future use. > > Plus, you can do wide permutes, and it can also help with reduction. > Having mask for reducing operations also helps (or a length field). > > There is one other thing that VVM does not do natively: Reductions > on commutative operators. Consider the implementation of a simple > SUM intrinsic of FORTRAN. If you write the assembly equivalent of > > s = 0; > for (long int i=0; i<n; i++) > s = s + a[i]; I am certainly not a numerical analyst, so correct me if I am wrong, but if the code above is C, then the reduction is not commutative unless you don't care about intermediate overflow or S is defined as unsigned, e.g. suppose consecutive elements are Max-10, 20, -Max+50 (where Max is the maximum value allowed, either integer or FP). If it is the SUM intrinsic in FORTRAN, then since FORTRAN doesn't care about overflow, then my point is irrelevant. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: vector length CSR?
Author: Thomas Koenig
Date: Thu, 19 Nov 2026 18:00
Date: Thu, 19 Nov 2026 18:00
64 lines
3827 bytes
3827 bytes
Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> On 11/11/2026 10:53 PM, Thomas Koenig wrote:
>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>
>>> It seems the
>>> advantage of an SIMD approach is the large set of addressable registers
>>> that can be used to keep data readily available for future use.
>>
>> Plus, you can do wide permutes, and it can also help with reduction.
>> Having mask for reducing operations also helps (or a length field).
>>
>> There is one other thing that VVM does not do natively: Reductions
>> on commutative operators. Consider the implementation of a simple
>> SUM intrinsic of FORTRAN. If you write the assembly equivalent of
>>
>> s = 0;
>> for (long int i=0; i<n; i++)
>> s = s + a[i];
>
> I am certainly not a numerical analyst, so correct me if I am wrong, but
> if the code above is C, then the reduction is not commutative unless you
> don't care about intermediate overflow or S is defined as unsigned, e.g.
> suppose consecutive elements are Max-10, 20, -Max+50 (where Max is the
> maximum value allowed, either integer or FP).
That is how I understand it, too. But the language definition of C does
not give the compiler permission to sum up things in a different order.
> If it is the SUM
> intrinsic in FORTRAN, then since FORTRAN doesn't care about overflow,
> then my point is irrelevant.
The definition of the result of the SUM intrinsic is
# The result of SUM (ARRAY) has a value equal to a processor-dependent
# approximation to the sum of all the elements of ARRAY or has the
# value zero if ARRAY has size zero.
This allows all sorts of rearrangements for floating point or
integer that the compiler might care to make.
On an OoO machine, there can be considerable advantage of doing this
kind of thing. For example, compare (if you will excuse my French)
add_v1_:
addq %rsi, %rdi
addq %rdx, %rdi
leaq (%rdi,%rcx), %rax
ret
add_v2_:
addq %rsi, %rdi
addq %rcx, %rdx
leaq (%rdi,%rdx), %rax
ret
Both calculate the same sum, but the v1 version has a dependency
on rdi so it cannot do the first two additions in parallel
(from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128737 ).
--
This USENET posting was made without artificial intelligence,
artificial impertinence, artificial arrogance, artificial stupidity,
artificial flavorings or artificial colorants.
reassociation and undefined behaviour (was: vector length CSR?)
Author: Anton Ertl
Date: Thu, 19 Nov 2026 18:38
Date: Thu, 19 Nov 2026 18:38
51 lines
3608 bytes
3608 bytes
Thomas Koenig <tkoenig@netcologne.de> writes: >On an OoO machine, there can be considerable advantage of doing this >kind of thing. For example, compare (if you will excuse my French) > >add_v1_: > addq %rsi, %rdi > addq %rdx, %rdi > leaq (%rdi,%rcx), %rax > ret >add_v2_: > addq %rsi, %rdi > addq %rcx, %rdx > leaq (%rdi,%rdx), %rax > ret On an in-order machine, it's even clearer. In add_v2_, the two adds can be done in the same cycle on an in-order machine. On an OoO machine, this is not always relevant, in particular, if rdx is only ready after rsi and rdi are ready. >(from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128737 ). If the undefined behaviour nonsense would not be so sad, it would be funny. The undefined behaviour advocates love to claim that undefined behaviour allows more optimization than defined behaviour, but in Comment 1 Richard Biener writes that gcc does not perform this optimization because of undefined behaviour. If the compiler rightly does not perform this optimization (e.g., because in other cases this would lead to miscompilation of the kind that even undefined behaviour fans consider to be miscompilation), this demonstrates that undefined behaviour not only prevents human optimizations, but also compiler optimizations. So undefined behaviour can be bad for optimization all around. But even if the gcc maintainers are mistaken, and the optimization can be safely applied, this case demonstrates that undefined behaviour has negative effects on compiler optimization capabilities. Does gcc reassociate the additions when you use -fwrapv? Interestingly, just today I wrote a piece of code that sums up signed longs in a loop, and gcc reassociates the additions in that compuation and vectorizes it. I guess that this happens at a later stage in the compiler where all undefined behaviour shenanigans are already behind it, so reassociation is now safe. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: vector length CSR?
Author: Stephen Fuld
Date: Thu, 19 Nov 2026 18:49
Date: Thu, 19 Nov 2026 18:49
70 lines
4233 bytes
4233 bytes
On 11/19/2026 10:00 AM, Thomas Koenig wrote: > Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>> >>>> It seems the >>>> advantage of an SIMD approach is the large set of addressable registers >>>> that can be used to keep data readily available for future use. >>> >>> Plus, you can do wide permutes, and it can also help with reduction. >>> Having mask for reducing operations also helps (or a length field). >>> >>> There is one other thing that VVM does not do natively: Reductions >>> on commutative operators. Consider the implementation of a simple >>> SUM intrinsic of FORTRAN. If you write the assembly equivalent of >>> >>> s = 0; >>> for (long int i=0; i<n; i++) >>> s = s + a[i]; >> >> I am certainly not a numerical analyst, so correct me if I am wrong, but >> if the code above is C, then the reduction is not commutative unless you >> don't care about intermediate overflow or S is defined as unsigned, e.g. >> suppose consecutive elements are Max-10, 20, -Max+50 (where Max is the >> maximum value allowed, either integer or FP). > > That is how I understand it, too. But the language definition of C does > not give the compiler permission to sum up things in a different order. So does that mean that no parallelization of the above loop is legal? Even if if wouldn't make any difference, e.g. the array entries are unsigned integers? >> If it is the SUM >> intrinsic in FORTRAN, then since FORTRAN doesn't care about overflow, >> then my point is irrelevant. > > The definition of the result of the SUM intrinsic is > > # The result of SUM (ARRAY) has a value equal to a processor-dependent > # approximation to the sum of all the elements of ARRAY or has the > # value zero if ARRAY has size zero. > > This allows all sorts of rearrangements for floating point or > integer that the compiler might care to make. > > On an OoO machine, there can be considerable advantage of doing this > kind of thing. For example, compare (if you will excuse my French) > > add_v1_: > addq %rsi, %rdi > addq %rdx, %rdi > leaq (%rdi,%rcx), %rax > ret > add_v2_: > addq %rsi, %rdi > addq %rcx, %rdx > leaq (%rdi,%rdx), %rax > ret > > Both calculate the same sum, but the v1 version has a dependency > on rdi so it cannot do the first two additions in parallel > (from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128737 ). Makes sense. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: vector length CSR?
Author: Thomas Koenig
Date: Thu, 19 Nov 2026 19:02
Date: Thu, 19 Nov 2026 19:02
43 lines
3311 bytes
3311 bytes
Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: > On 11/19/2026 10:00 AM, Thomas Koenig wrote: >> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>> >>>>> It seems the >>>>> advantage of an SIMD approach is the large set of addressable registers >>>>> that can be used to keep data readily available for future use. >>>> >>>> Plus, you can do wide permutes, and it can also help with reduction. >>>> Having mask for reducing operations also helps (or a length field). >>>> >>>> There is one other thing that VVM does not do natively: Reductions >>>> on commutative operators. Consider the implementation of a simple >>>> SUM intrinsic of FORTRAN. If you write the assembly equivalent of >>>> >>>> s = 0; >>>> for (long int i=0; i<n; i++) >>>> s = s + a[i]; >>> >>> I am certainly not a numerical analyst, so correct me if I am wrong, but >>> if the code above is C, then the reduction is not commutative unless you >>> don't care about intermediate overflow or S is defined as unsigned, e.g. >>> suppose consecutive elements are Max-10, 20, -Max+50 (where Max is the >>> maximum value allowed, either integer or FP). >> >> That is how I understand it, too. But the language definition of C does >> not give the compiler permission to sum up things in a different order. > > So does that mean that no parallelization of the above loop is legal? > Even if if wouldn't make any difference, e.g. the array entries are > unsigned integers? I think the "as if" rule would apply in this case, so it would be permitted. For integers, doubtful; for floating point, no. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: vector length CSR?
Author: Anton Ertl
Date: Thu, 19 Nov 2026 19:38
Date: Thu, 19 Nov 2026 19:38
39 lines
3077 bytes
3077 bytes
Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes: >On 11/19/2026 10:00 AM, Thomas Koenig wrote: >> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>> s = 0; >>>> for (long int i=0; i<n; i++) >>>> s = s + a[i]; ... >So does that mean that no parallelization of the above loop is legal? >Even if if wouldn't make any difference, e.g. the array entries are >unsigned integers? For unsigned integers and signed integers in C, this loop can be reassociated just fine. For unsigned integers: The associative law holds for modulo arithmetic, in particular unsigned addition and multiplication in C. For signed integers: The compiler can choose what it wants to do in case of overflow; e.g., it can choose modulo arithmetic, which is associative. So in both cases the code can be reassociated, and thus parallelized. For FP addition and multiplication, the associative law does not hold, so the compiler cannot reassociate this loop if the addition is an FP addition. However, gcc has a flag -ffast-math, which tells the compiler that you do not care about bit-exact FP arithmetics. With this flag gcc pretends that the associative law holds even for FP + and vectorizes this loop (with the appropriate other flags). Can you explain why you are writing about "commutative" when what's relevant here is the associative, not the commutative law? - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: vector length CSR?
Author: George Neuner
Date: Thu, 19 Nov 2026 23:48
Date: Thu, 19 Nov 2026 23:48
16 lines
2159 bytes
2159 bytes
On Tue, 17 Nov 2026 20:57:58 GMT, MitchAlsup <user5857@newsgrouper.org.invalid> wrote: >Minor quibble: if you have 1024-bit wide SIMD units, you need a way to >read and write 1024-bits as operands and results. This does NOT end up >using 1024-bit registers, necessarily. Yes. But we're not talking about a register file here. The Mill's belt consists of the output latches of the load and compute units, and the bypass network that connects all the units (as necessary) When I learned it, such latches were referred to as "registers" - not programmer visible, but "registers" nonetheless. Maybe you call them something different.
Re: vector length CSR?
Author: MitchAlsup
Date: Fri, 20 Nov 2026 02:21
Date: Fri, 20 Nov 2026 02:21
21 lines
2022 bytes
2022 bytes
George Neuner <gneuner2@comcast.net> posted: > On Tue, 17 Nov 2026 20:57:58 GMT, MitchAlsup > <user5857@newsgrouper.org.invalid> wrote: > > >Minor quibble: if you have 1024-bit wide SIMD units, you need a way to > >read and write 1024-bits as operands and results. This does NOT end up > >using 1024-bit registers, necessarily. > > Yes. But we're not talking about a register file here. > > The Mill's belt consists of the output latches of the load and compute > units, and the bypass network that connects all the units (as > necessary) > > When I learned it, such latches were referred to as "registers" - not > programmer visible, but "registers" nonetheless. Maybe you call them > something different. One annotates them specifically in source code (for that model). Thus, they are program visible.
Re: vector length CSR?
Author: Michael S
Date: Fri, 20 Nov 2026 14:02
Date: Fri, 20 Nov 2026 14:02
29 lines
2805 bytes
2805 bytes
On Thu, 19 Nov 2026 18:48:13 -0500 George Neuner <gneuner2@comcast.net> wrote: > On Tue, 17 Nov 2026 20:57:58 GMT, MitchAlsup > <user5857@newsgrouper.org.invalid> wrote: > > >Minor quibble: if you have 1024-bit wide SIMD units, you need a way > >to read and write 1024-bits as operands and results. This does NOT > >end up using 1024-bit registers, necessarily. > > Yes. But we're not talking about a register file here. > > The Mill's belt consists of the output latches of the load and compute > units, and the bypass network that connects all the units (as > necessary) > > When I learned it, such latches were referred to as "registers" - not > programmer visible, but "registers" nonetheless. Maybe you call them > something different. If we are going to believe early Mill presentation, belt can not consist *just* from EU latches and from bypass network. Presentations claimed that for any given model belt has fixed depth independent of mix of executed instructions. If it were just latches and bypasses then the depth would be variable and heavily dependent on the mix. Of course, it is possible that presentations were too generic, missing important details.
Re: vector length CSR?
Author: Thomas Koenig
Date: Fri, 20 Nov 2026 18:57
Date: Fri, 20 Nov 2026 18:57
33 lines
2708 bytes
2708 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: > Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes: >>On 11/19/2026 10:00 AM, Thomas Koenig wrote: >>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>> s = 0; >>>>> for (long int i=0; i<n; i++) >>>>> s = s + a[i]; > ... >>So does that mean that no parallelization of the above loop is legal? >>Even if if wouldn't make any difference, e.g. the array entries are >>unsigned integers? > > For unsigned integers and signed integers in C, this loop can be > reassociated just fine. Not according to the C standard. > > For unsigned integers: The associative law holds for modulo > arithmetic, in particular unsigned addition and multiplication in C. > > For signed integers: The compiler can choose what it wants to do in > case of overflow; e.g., it can choose modulo arithmetic, which is > associative. Or it can issue an overvlow trap, for example with -fsanitize=undefined. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: vector length CSR?
Author: David Brown
Date: Sat, 21 Nov 2026 11:50
Date: Sat, 21 Nov 2026 11:50
48 lines
3551 bytes
3551 bytes
On 20/11/2026 19:57, Thomas Koenig wrote: > Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: >> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes: >>> On 11/19/2026 10:00 AM, Thomas Koenig wrote: >>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>>> s = 0; >>>>>> for (long int i=0; i<n; i++) >>>>>> s = s + a[i]; >> ... >>> So does that mean that no parallelization of the above loop is legal? >>> Even if if wouldn't make any difference, e.g. the array entries are >>> unsigned integers? >> >> For unsigned integers and signed integers in C, this loop can be >> reassociated just fine. > > Not according to the C standard. Yes, according to the C standards. UB on signed integer overflow means the language does not say anything about what happens on overflow - it does not mean the compiler has to handle it specially. > >> >> For unsigned integers: The associative law holds for modulo >> arithmetic, in particular unsigned addition and multiplication in C. >> >> For signed integers: The compiler can choose what it wants to do in >> case of overflow; e.g., it can choose modulo arithmetic, which is >> associative. > > Or it can issue an overvlow trap, for example with -fsanitize=undefined. > The C standard does not require overflow traps in any way. It explicitly says /nothing/ about what happens on signed integer arithmetic overflow. So there is no problem doing a summation loop like this in any order, serially or in parallel, with signed integer types or unsigned integer types. A particular compiler implementation, possibly under control of particular flags, can of course give specific behaviour to signed integer overflow. And in that case the compiler must generate code that fits the semantics it is giving.
Re: vector length CSR?
Author: Thomas Koenig
Date: Sat, 21 Nov 2026 14:01
Date: Sat, 21 Nov 2026 14:01
34 lines
2951 bytes
2951 bytes
David Brown <david.brown@hesbynett.no> schrieb: > On 20/11/2026 19:57, Thomas Koenig wrote: >> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: >>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes: >>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote: >>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>>>> s = 0; >>>>>>> for (long int i=0; i<n; i++) >>>>>>> s = s + a[i]; >>> ... >>>> So does that mean that no parallelization of the above loop is legal? >>>> Even if if wouldn't make any difference, e.g. the array entries are >>>> unsigned integers? >>> >>> For unsigned integers and signed integers in C, this loop can be >>> reassociated just fine. >> >> Not according to the C standard. > > Yes, according to the C standards. UB on signed integer overflow means > the language does not say anything about what happens on overflow - it > does not mean the compiler has to handle it specially. Yep, I was too short in what I wrote. Of course, the compiler can assign any meaning to undefined behavior that it choses. What I *did* mean to write is that a programmer cannot expect this loop to be reassociated. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: vector length CSR?
Author: David Brown
Date: Sat, 21 Nov 2026 14:17
Date: Sat, 21 Nov 2026 14:17
49 lines
3976 bytes
3976 bytes
On 21/11/2026 15:01, Thomas Koenig wrote: > David Brown <david.brown@hesbynett.no> schrieb: >> On 20/11/2026 19:57, Thomas Koenig wrote: >>> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: >>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes: >>>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote: >>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >>>>>>>> s = 0; >>>>>>>> for (long int i=0; i<n; i++) >>>>>>>> s = s + a[i]; >>>> ... >>>>> So does that mean that no parallelization of the above loop is legal? >>>>> Even if if wouldn't make any difference, e.g. the array entries are >>>>> unsigned integers? >>>> >>>> For unsigned integers and signed integers in C, this loop can be >>>> reassociated just fine. >>> >>> Not according to the C standard. >> >> Yes, according to the C standards. UB on signed integer overflow means >> the language does not say anything about what happens on overflow - it >> does not mean the compiler has to handle it specially. > > Yep, I was too short in what I wrote. Of course, the compiler can > assign any meaning to undefined behavior that it choses. What I > *did* mean to write is that a programmer cannot expect this loop > to be reassociated. > I would say that programmers can and should expect that a loop like this might be re-arranged by the compiler, for both signed and unsigned types. You rarely want to rely on an assumption of optimisation - if you /need/ the loop to be optimised in some particular way, then you typically have to use compiler-specific features (like gcc's "#pragma GCC ivdep" or "vector_size" attributes), intrinsic functions for a particular target, or perhaps C++26's "simd" features. If you really need the loop /not/ to be re-arranged, then you need to inform the compiler of that too - compiler flags, "#pragma GCC unroll 0", using volatile, etc. Without additional effort from the compiler user, a loop like this can be re-arranged using commutative and associative laws and any other information the compiler has. I would not expect the compiler to handle this differently for signed or unsigned types.
Re: vector length CSR?
Author: Thomas Koenig
Date: Sat, 21 Nov 2026 14:54
Date: Sat, 21 Nov 2026 14:54
45 lines
3291 bytes
3291 bytes
David Brown <david.brown@hesbynett.no> schrieb:
> On 21/11/2026 15:01, Thomas Koenig wrote:
>> David Brown <david.brown@hesbynett.no> schrieb:
>>> On 20/11/2026 19:57, Thomas Koenig wrote:
>>>> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
>>>>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote:
>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote:
>>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>>>> s = 0;
>>>>>>>>> for (long int i=0; i<n; i++)
>>>>>>>>> s = s + a[i];
[...]
> Without additional effort from the compiler user, a loop like this can
> be re-arranged using commutative and associative laws and any other
> information the compiler has. I would not expect the compiler to handle
> this differently for signed or unsigned types.
gcc treats wrapping and non-wrapping differently. Here's a function
from gcc/tree-ssa-reassoc.cc:
/* Returns true if we can reassociate operations of TYPE.
That is for integral or non-saturating fixed-point types, and for
floating point type when associative-math is enabled. */
static bool
can_reassociate_type_p (tree type)
{
if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
|| NON_SAT_FIXED_POINT_TYPE_P (type)
|| (flag_associative_math && FLOAT_TYPE_P (type)))
return true;
return false;
}
Reassociation is possible with -frwapv, not possible with
normal semantics.
--
This USENET posting was made without artificial intelligence,
artificial impertinence, artificial arrogance, artificial stupidity,
artificial flavorings or artificial colorants.
Re: vector length CSR?
Author: David Brown
Date: Sat, 21 Nov 2026 15:15
Date: Sat, 21 Nov 2026 15:15
49 lines
3683 bytes
3683 bytes
On 21/11/2026 15:54, Thomas Koenig wrote:
> David Brown <david.brown@hesbynett.no> schrieb:
>> On 21/11/2026 15:01, Thomas Koenig wrote:
>>> David Brown <david.brown@hesbynett.no> schrieb:
>>>> On 20/11/2026 19:57, Thomas Koenig wrote:
>>>>> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
>>>>>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote:
>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote:
>>>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>>>>> s = 0;
>>>>>>>>>> for (long int i=0; i<n; i++)
>>>>>>>>>> s = s + a[i];
>
> [...]
>
>> Without additional effort from the compiler user, a loop like this can
>> be re-arranged using commutative and associative laws and any other
>> information the compiler has. I would not expect the compiler to handle
>> this differently for signed or unsigned types.
>
> gcc treats wrapping and non-wrapping differently. Here's a function
> from gcc/tree-ssa-reassoc.cc:
>
> /* Returns true if we can reassociate operations of TYPE.
> That is for integral or non-saturating fixed-point types, and for
> floating point type when associative-math is enabled. */
>
> static bool
> can_reassociate_type_p (tree type)
> {
> if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
> || NON_SAT_FIXED_POINT_TYPE_P (type)
> || (flag_associative_math && FLOAT_TYPE_P (type)))
> return true;
> return false;
> }
>
> Reassociation is possible with -frwapv, not possible with
> normal semantics.
>
That surprises me, but okay. There is certainly no reason why signed
integer types cannot be treated as wrapping if it results in better code
(assuming, of course, you don't have "-ftrapv" or relevant sanitizer
flags in effect).
Re: vector length CSR?
Author: Michael S
Date: Sat, 21 Nov 2026 20:50
Date: Sat, 21 Nov 2026 20:50
85 lines
4237 bytes
4237 bytes
On Sat, 21 Nov 2026 14:54:08 -0000 (UTC)
Thomas Koenig <tkoenig@netcologne.de> wrote:
> David Brown <david.brown@hesbynett.no> schrieb:
> > On 21/11/2026 15:01, Thomas Koenig wrote:
> >> David Brown <david.brown@hesbynett.no> schrieb:
> >>> On 20/11/2026 19:57, Thomas Koenig wrote:
> >>>> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
> >>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
> >>>>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote:
> >>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> >>>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote:
> >>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> >>>>>>>>> s = 0;
> >>>>>>>>> for (long int i=0; i<n; i++)
> >>>>>>>>> s = s + a[i];
>
> [...]
>
> > Without additional effort from the compiler user, a loop like this
> > can be re-arranged using commutative and associative laws and any
> > other information the compiler has. I would not expect the
> > compiler to handle this differently for signed or unsigned types.
>
> gcc treats wrapping and non-wrapping differently. Here's a function
> from gcc/tree-ssa-reassoc.cc:
>
> /* Returns true if we can reassociate operations of TYPE.
> That is for integral or non-saturating fixed-point types, and for
> floating point type when associative-math is enabled. */
>
> static bool
> can_reassociate_type_p (tree type)
> {
> if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
> || NON_SAT_FIXED_POINT_TYPE_P (type)
> || (flag_associative_math && FLOAT_TYPE_P (type)))
> return true;
> return false;
> }
>
> Reassociation is possible with -frwapv, not possible with
> normal semantics.
>
I don't know what exactly this flag means, but it does not mean what you
think it does.
int sum_int(const int* a)
{
int sum = 0;
for (int i = 0; i < 128; ++i)
sum += a[i];
return sum;
}
Compiled by gcc into:
sum_int:
leaq 512(%rdi), %rax
vpxor %xmm0, %xmm0, %xmm0
.L2:
vpaddd (%rdi), %ymm0, %ymm0
addq $32, %rdi
cmpq %rdi, %rax
jne .L2
vextracti128 $0x1, %ymm0, %xmm1
vpaddd %xmm0, %xmm1, %xmm0
vpsrldq $8, %xmm0, %xmm1
vpaddd %xmm1, %xmm0, %xmm0
vpsrldq $4, %xmm0, %xmm1
vpaddd %xmm1, %xmm0, %xmm0
vmovd %xmm0, %eax
vzeroupper
ret
https://godbolt.org/z/n8YjxnrW6
Re: vector length CSR?
Author: George Neuner
Date: Sat, 21 Nov 2026 21:32
Date: Sat, 21 Nov 2026 21:32
29 lines
2687 bytes
2687 bytes
On Fri, 20 Nov 2026 02:21:32 GMT, MitchAlsup <user5857@newsgrouper.org.invalid> wrote: >George Neuner <gneuner2@comcast.net> posted: > >> On Tue, 17 Nov 2026 20:57:58 GMT, MitchAlsup >> <user5857@newsgrouper.org.invalid> wrote: >> >> >Minor quibble: if you have 1024-bit wide SIMD units, you need a way to >> >read and write 1024-bits as operands and results. This does NOT end up >> >using 1024-bit registers, necessarily. >> >> Yes. But we're not talking about a register file here. >> >> The Mill's belt consists of the output latches of the load and compute >> units, and the bypass network that connects all the units (as >> necessary) >> >> When I learned it, such latches were referred to as "registers" - not >> programmer visible, but "registers" nonetheless. Maybe you call them >> something different. > >One annotates them specifically in source code (for that model). >Thus, they are program visible. Yes, in the Mill model the "registers" that form the belt are visible. But they are not necessarily uniform width as in a register file. And their programmer visible names change every time the belt "moves".
Re: vector length CSR?
Author: Anton Ertl
Date: Sun, 22 Nov 2026 09:16
Date: Sun, 22 Nov 2026 09:16
101 lines
4359 bytes
4359 bytes
Thomas Koenig <tkoenig@netcologne.de> writes:
>gcc treats wrapping and non-wrapping differently. Here's a function
>from gcc/tree-ssa-reassoc.cc:
>
>/* Returns true if we can reassociate operations of TYPE.
> That is for integral or non-saturating fixed-point types, and for
> floating point type when associative-math is enabled. */
>
>static bool
>can_reassociate_type_p (tree type)
>{
> if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
> || NON_SAT_FIXED_POINT_TYPE_P (type)
> || (flag_associative_math && FLOAT_TYPE_P (type)))
> return true;
> return false;
>}
>
>Reassociation is possible with -frwapv, not possible with
>normal semantics.
Let's see how well it works (gcc-12):
[~/tmp:173584] cat reassoc.c
int foo(int a, int b, int c, int d)
{
int r=a;
r+=b;
r+=c;
r+=d;
return r;
}
[~/tmp:173585] gcc -O3 -c reassoc.c && objdump -d reassoc.o
reassoc.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 01 f7 add %esi,%edi
2: 01 d7 add %edx,%edi
4: 8d 04 0f lea (%rdi,%rcx,1),%eax
7: c3 ret
[~/tmp:173586] gcc -fwrapv -O3 -c reassoc.c && objdump -d reassoc.o
reassoc.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 01 ca add %ecx,%edx
2: 01 f2 add %esi,%edx
4: 8d 04 3a lea (%rdx,%rdi,1),%eax
7: c3 ret
So gcc by default does not reassociate, and in the -fwrapv case
reassociates, but does so in a way that does not reduce the tree
height, but that corresponds to
c+=d;
c+=b;
return c+a;
What's the reason for that? "Relevant" programs where the earlier
parameters are on the critical path and the later ones are not?
Let's see how clang-14 does:
[~/tmp:173587] clang -O3 -c reassoc.c && objdump -d reassoc.o
reassoc.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 8d 04 37 lea (%rdi,%rsi,1),%eax
3: 01 d0 add %edx,%eax
5: 01 c8 add %ecx,%eax
7: c3 ret
[~/tmp:173588] clang -fwrapv -O3 -c reassoc.c && objdump -d reassoc.o
reassoc.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 8d 04 37 lea (%rdi,%rsi,1),%eax
3: 01 d0 add %edx,%eax
5: 01 c8 add %ecx,%eax
7: c3 ret
No reassociation with either flag.
- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: vector length CSR?
Author: Tim Rentsch
Date: Sun, 22 Nov 2026 15:45
Date: Sun, 22 Nov 2026 15:45
30 lines
2854 bytes
2854 bytes
Michael S <already5chosen@yahoo.com> writes: > On Sat, 21 Nov 2026 14:54:08 -0000 (UTC) > Thomas Koenig <tkoenig@netcologne.de> wrote: [...] >>>>>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote: >>>>>>>>>> >>>>>>>>>>> [considering whether code like this can be rearranged] >>>>>>>>>>> s = 0; >>>>>>>>>>> for (long int i=0; i<n; i++) >>>>>>>>>>> s = s + a[i]; [...] >> Reassociation is possible with -frwapv, not possible with >> normal semantics. > > I don't know what exactly this flag means, but it does not mean > what you think it does. Whatever it is that gcc does, the basic point is correct. If signed integer arithmetic is implemented as producing the same bit patterns as though done using unsigned arithmetic, then a compiler may take advantage of that property and rearrange terms of the sum, without being in conflict with the C standard. Alternatively, the variable s could be declared as an unsigned type of appropriate size, and the result converted to the appropriate signed type after the loop completes, which allows rearrangement regardless of the rules for signed arithmetic.
Re: vector length CSR?
Author: Michael S
Date: Sun, 22 Nov 2026 19:55
Date: Sun, 22 Nov 2026 19:55
118 lines
5183 bytes
5183 bytes
On Sun, 22 Nov 2026 09:16:24 GMT
anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
> Thomas Koenig <tkoenig@netcologne.de> writes:
> >gcc treats wrapping and non-wrapping differently. Here's a function
> >from gcc/tree-ssa-reassoc.cc:
> >
> >/* Returns true if we can reassociate operations of TYPE.
> > That is for integral or non-saturating fixed-point types, and for
> > floating point type when associative-math is enabled. */
> >
> >static bool
> >can_reassociate_type_p (tree type)
> >{
> > if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
> > || NON_SAT_FIXED_POINT_TYPE_P (type)
> > || (flag_associative_math && FLOAT_TYPE_P (type)))
> > return true;
> > return false;
> >}
> >
> >Reassociation is possible with -frwapv, not possible with
> >normal semantics.
>
> Let's see how well it works (gcc-12):
>
> [~/tmp:173584] cat reassoc.c
> int foo(int a, int b, int c, int d)
> {
> int r=a;
> r+=b;
> r+=c;
> r+=d;
> return r;
> }
> [~/tmp:173585] gcc -O3 -c reassoc.c && objdump -d reassoc.o
>
> reassoc.o: file format elf64-x86-64
>
>
> Disassembly of section .text:
>
> 0000000000000000 <foo>:
> 0: 01 f7 add %esi,%edi
> 2: 01 d7 add %edx,%edi
> 4: 8d 04 0f lea (%rdi,%rcx,1),%eax
> 7: c3 ret
> [~/tmp:173586] gcc -fwrapv -O3 -c reassoc.c && objdump -d reassoc.o
>
> reassoc.o: file format elf64-x86-64
>
>
> Disassembly of section .text:
>
> 0000000000000000 <foo>:
> 0: 01 ca add %ecx,%edx
> 2: 01 f2 add %esi,%edx
> 4: 8d 04 3a lea (%rdx,%rdi,1),%eax
> 7: c3 ret
>
> So gcc by default does not reassociate, and in the -fwrapv case
> reassociates, but does so in a way that does not reduce the tree
> height, but that corresponds to
>
> c+=d;
> c+=b;
> return c+a;
>
> What's the reason for that? "Relevant" programs where the earlier
> parameters are on the critical path and the later ones are not?
>
> Let's see how clang-14 does:
>
> [~/tmp:173587] clang -O3 -c reassoc.c && objdump -d reassoc.o
>
> reassoc.o: file format elf64-x86-64
>
>
> Disassembly of section .text:
>
> 0000000000000000 <foo>:
> 0: 8d 04 37 lea (%rdi,%rsi,1),%eax
> 3: 01 d0 add %edx,%eax
> 5: 01 c8 add %ecx,%eax
> 7: c3 ret
> [~/tmp:173588] clang -fwrapv -O3 -c reassoc.c && objdump -d reassoc.o
>
> reassoc.o: file format elf64-x86-64
>
>
> Disassembly of section .text:
>
> 0000000000000000 <foo>:
> 0: 8d 04 37 lea (%rdi,%rsi,1),%eax
> 3: 01 d0 add %edx,%eax
> 5: 01 c8 add %ecx,%eax
> 7: c3 ret
>
> No reassociation with either flag.
>
> - anton
Unlike clang, gcc performs no useful re-association for "open" code.
The uselessness is independent, of presence/absence of -fwrapv
flags. More so, it is independent of signed vs unsigned.
gcc does re-associate in useful manner when vecorizing loops.
Again, it performs it independently of -fwrapv or from signness.
See examples in my post below.
BTW, gcc will happily vectorize very short summation loops, even as
short as 4 integers, where vectorization almost certainly would be
pessimizing.
Re: CISC are not "unreduced"
Author: BGB
Date: Sun, 22 Nov 2026 21:26
Date: Sun, 22 Nov 2026 21:26
107 lines
5800 bytes
5800 bytes
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). ...
Re: vector length CSR?
Author: Anton Ertl
Date: Sun, 22 Nov 2026 22:04
Date: Sun, 22 Nov 2026 22:04
64 lines
3317 bytes
3317 bytes
Michael S <already5chosen@yahoo.com> writes:
>On Sun, 22 Nov 2026 09:16:24 GMT
>anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
>> int foo(int a, int b, int c, int d)
>> {
>> int r=a;
>> r+=b;
>> r+=c;
>> r+=d;
>> return r;
>> }
...
>> [~/tmp:173588] clang -fwrapv -O3 -c reassoc.c && objdump -d reassoc.o
>>
>> reassoc.o: file format elf64-x86-64
>>
>>
>> Disassembly of section .text:
>>
>> 0000000000000000 <foo>:
>> 0: 8d 04 37 lea (%rdi,%rsi,1),%eax
>> 3: 01 d0 add %edx,%eax
>> 5: 01 c8 add %ecx,%eax
>> 7: c3 ret
>>
>> No reassociation with either flag.
>>
>> - anton
>
>Unlike clang, gcc performs no useful re-association for "open" code.
And clang does not reassociate at all in this example. Do you have an
example (without vectorization) where it reassociates.
>BTW, gcc will happily vectorize very short summation loops, even as
>short as 4 integers, where vectorization almost certainly would be
>pessimizing.
Better measure that. Last year clang surprised me by vectorizing the
following loop:
#include <stddef.h>
void axpy1(float a, float *x, float *y,
float *z, float *w, float *v,
size_t n)
{
size_t i;
for (i=0; i<n; i++) {
z[i] += a*x[i];
w[i] = x[i]+y[i];
v[i] = x[i]*z[i];
}
}
v, w, and z are not restrict, so clang has to check first that they do
not overlap. Still vectorization was profitable for n=5 or so. When
the compiler is told that v, w, and z are restrict, the vectorized
variant was faster for even lower n (also for gcc).
- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: vector length CSR?
Author: Michael S
Date: Sun, 22 Nov 2026 22:47
Date: Sun, 22 Nov 2026 22:47
105 lines
4331 bytes
4331 bytes
On Sun, 22 Nov 2026 22:04:35 GMT
anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
> Michael S <already5chosen@yahoo.com> writes:
> >On Sun, 22 Nov 2026 09:16:24 GMT
> >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
> >> int foo(int a, int b, int c, int d)
> >> {
> >> int r=a;
> >> r+=b;
> >> r+=c;
> >> r+=d;
> >> return r;
> >> }
> ...
> >> [~/tmp:173588] clang -fwrapv -O3 -c reassoc.c && objdump -d
> >> reassoc.o
> >>
> >> reassoc.o: file format elf64-x86-64
> >>
> >>
> >> Disassembly of section .text:
> >>
> >> 0000000000000000 <foo>:
> >> 0: 8d 04 37 lea (%rdi,%rsi,1),%eax
> >> 3: 01 d0 add %edx,%eax
> >> 5: 01 c8 add %ecx,%eax
> >> 7: c3 ret
> >>
> >> No reassociation with either flag.
> >>
> >> - anton
> >
> >Unlike clang, gcc performs no useful re-association for "open" code.
> >
>
> And clang does not reassociate at all in this example. Do you have an
> example (without vectorization) where it reassociates.
>
int sum4(int a, int b, int c, int d)
{
return a + b + c + d;
}
Windows ABI
sum4: # @sum4
# %bb.0:
# kill: def $r9d killed $r9d
def $r9
# kill: def $r8d killed $r8d
def $r8
# kill: def $edx killed $edx
def $rdx
# kill: def $ecx killed $ecx
def $rcx
addl %edx, %ecx
leal (%r8,%r9), %eax
addl %ecx, %eax
retq
> >BTW, gcc will happily vectorize very short summation loops, even as
> >short as 4 integers, where vectorization almost certainly would be
> >pessimizing.
>
> Better measure that. Last year clang surprised me by vectorizing the
> following loop:
>
> #include <stddef.h>
>
> void axpy1(float a, float *x, float *y,
> float *z, float *w, float *v,
> size_t n)
> {
> size_t i;
> for (i=0; i<n; i++) {
> z[i] += a*x[i];
> w[i] = x[i]+y[i];
> v[i] = x[i]*z[i];
> }
> }
>
> v, w, and z are not restrict, so clang has to check first that they do
> not overlap. Still vectorization was profitable for n=5 or so. When
> the compiler is told that v, w, and z are restrict, the vectorized
> variant was faster for even lower n (also for gcc).
>
> - anton
In your example there is higher amount of work in the inner loop.
I am talking about really minimal case:
int sum4v(const int* a)
{
int sum = 0;
for (int i = 0; i < 4; ++i)
sum += a[i];
return sum;
}
Re: vector length CSR?
Author: aph
Date: Tue, 24 Nov 2026 09:28
Date: Tue, 24 Nov 2026 09:28
55 lines
4099 bytes
4099 bytes
David Brown <david.brown@hesbynett.no> wrote:
> On 21/11/2026 15:54, Thomas Koenig wrote:
>> David Brown <david.brown@hesbynett.no> schrieb:
>>> On 21/11/2026 15:01, Thomas Koenig wrote:
>>>> David Brown <david.brown@hesbynett.no> schrieb:
>>>>> On 20/11/2026 19:57, Thomas Koenig wrote:
>>>>>> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
>>>>>>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote:
>>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote:
>>>>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>>>>>> s = 0;
>>>>>>>>>>> for (long int i=0; i<n; i++)
>>>>>>>>>>> s = s + a[i];
>>
>> [...]
>>
>>> Without additional effort from the compiler user, a loop like this can
>>> be re-arranged using commutative and associative laws and any other
>>> information the compiler has. I would not expect the compiler to handle
>>> this differently for signed or unsigned types.
>>
>> gcc treats wrapping and non-wrapping differently. Here's a function
>> from gcc/tree-ssa-reassoc.cc:
>>
>> /* Returns true if we can reassociate operations of TYPE.
>> That is for integral or non-saturating fixed-point types, and for
>> floating point type when associative-math is enabled. */
>>
>> static bool
>> can_reassociate_type_p (tree type)
>> {
>> if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
>> || NON_SAT_FIXED_POINT_TYPE_P (type)
>> || (flag_associative_math && FLOAT_TYPE_P (type)))
>> return true;
>> return false;
>> }
>>
>> Reassociation is possible with -frwapv, not possible with
>> normal semantics.
>>
>
> That surprises me, but okay. There is certainly no reason why signed
> integer types cannot be treated as wrapping if it results in better code
> (assuming, of course, you don't have "-ftrapv" or relevant sanitizer
> flags in effect).
No pass within GCC (and probably any other compiler) may introduce
undefined behaviour where there was none in the program. That is
because a later pass might detect the introduced UB and miscompile it,
or even drop it onto the floor altogether.
Andrew.
Re: vector length CSR?
Author: Stephen Fuld
Date: Tue, 24 Nov 2026 20:12
Date: Tue, 24 Nov 2026 20:12
63 lines
4490 bytes
4490 bytes
On 11/9/2026 9:08 AM, Stephen Fuld wrote: I issued the following "challenge". > I can't speak to the hardware complexity of the implementation. Perhaps > that is a limiting factor. But barring that, and the mental effort > required to "reorient" your thinking, I don't see why any new clean > sheet design would use SIMD instructions. Perhaps someone can explain > why it should. The results were, at least to me, quite enlightening. I think it might be useful to summarize these responses. I group the types of problems that people thought SIMD was better at than VVM into three areas. The first group is exemplified by Anton bringing up the types of problems where memory values are reused in the vector registers. He gave matrix multiplication as an example. Terje presented an algorithm which others indicated was competitive with the SIMD method. Note that I am not ruling out that there may be other problems that fit into this group but aren't amenable to the kind of solution Terje presented. So I count that as worst case, a "tie". But so far, not a compelling argument for SIMD. The second group is "reductions" of various types. Mostly, this came down to the question of whether the operation on the given data type could be parallelized or "reassociated". I think we have come down to the following: For operations on unsigned integers, or on signed integers with certain compile options, and operations such as MAX, VVM has the advantage as it can parallelize them and, perhaps with some additional design work by Mitch, combine the partial results at the end, including handling sizes that are not a integer multiple of the amount of parallelization. This seems like a big win for VVM. For operations on signed integers where preserving possible internal overflows, etc. are required VVM can't parallelize them (signified by specifying 1 in the number of lanes field in the VEC instruction). But there is still a more modest advantage for VVM in that reading the data from memory doesn't "scrub" the cache, and the loop termination test is a single instruction. For operations on floating point, with some "not yet filed" stuff, VVM has the advantage in that the operation can be parallelized without loss of precision. So overall, for this second group, I see no argument for SIMD. The third group, and one we really haven't discussed in this thread beyond Thomas' first mention is wide permutations. I wasn't familiar with the relevant capabilities in AVX512, so I had to do a little research. While My 66000 has a permute instruction, and perhaps if preceded by a Double instruction modifier can be wider, I don't see how it can compete with the 512 byte wide permutation in three cycles provided by AVX512, nor the capability to do byte wide permutes where the source isn't required to be a 8 bit boundary. So if these kinds of operations are used often, then SIMD may be a requirement. Of course, I welcome comments, additions, subtractions (!), etc. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: vector length CSR?
Author: Thomas Koenig
Date: Tue, 24 Nov 2026 21:07
Date: Tue, 24 Nov 2026 21:07
94 lines
5908 bytes
5908 bytes
Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: > On 11/9/2026 9:08 AM, Stephen Fuld wrote: > > I issued the following "challenge". > >> I can't speak to the hardware complexity of the implementation. Perhaps >> that is a limiting factor. But barring that, and the mental effort >> required to "reorient" your thinking, I don't see why any new clean >> sheet design would use SIMD instructions. Perhaps someone can explain >> why it should. > > The results were, at least to me, quite enlightening. I think it might > be useful to summarize these responses. I group the types of problems > that people thought SIMD was better at than VVM into three areas. > > The first group is exemplified by Anton bringing up the types of > problems where memory values are reused in the vector registers. He > gave matrix multiplication as an example. Terje presented an algorithm > which others indicated was competitive with the SIMD method. Note that > I am not ruling out that there may be other problems that fit into this > group but aren't amenable to the kind of solution Terje presented. So I > count that as worst case, a "tie". But so far, not a compelling > argument for SIMD. I'm not really sure I understand, then. VVM always has to access memory at cache latencies (4-5 cycles); register access does not need that, and clever algorithms can resuse that data to good effect. > The second group is "reductions" of various types. Mostly, this came > down to the question of whether the operation on the given data type > could be parallelized or "reassociated". I think we have come down to > the following: > > For operations on unsigned integers, or on signed integers with certain > compile options, and operations such as MAX, VVM has the advantage as it > can parallelize them and, perhaps with some additional design work by > Mitch, combine the partial results at the end, including handling sizes > that are not a integer multiple of the amount of parallelization. This > seems like a big win for VVM. VVM is always at an advantage when the SINDified and the size of the hardware SIMD registers is unknown at comile and can leave all the loop peeling and other assorted nastiness to hardware. But a four-lane SIMD, for example, could do the same. It would need a reduction step at the and, as well. > For operations on signed integers where preserving possible internal > overflows, etc. are required VVM can't parallelize them (signified by > specifying 1 in the number of lanes field in the VEC instruction). That is an interesting question. Today's hardware does two's complement, so under "as if" rule a compiler could just happily do the summation in hardware and look at the end result; intermediate overflows will just be ignored, and as long as the end result fits, all is in order. A Fortran compiler calculating the SUM intrinsic could just do that. A C compiler could also do that if it chose to (and it seems that LLVM choses to do so at least for the a + b + c + d case). > But > there is still a more modest advantage for VVM in that reading the data > from memory doesn't "scrub" the cache, and the loop termination test is > a single instruction. > > For operations on floating point, with some "not yet filed" stuff, VVM > has the advantage in that the operation can be parallelized without loss > of precision. > > So overall, for this second group, I see no argument for SIMD. If VVM can do reductions, yes. > The third group, and one we really haven't discussed in this thread > beyond Thomas' first mention is wide permutations. I wasn't familiar > with the relevant capabilities in AVX512, so I had to do a little > research. While My 66000 has a permute instruction, and perhaps if > preceded by a Double instruction modifier can be wider, I don't see how > it can compete with the 512 byte wide permutation in three cycles > provided by AVX512, nor the capability to do byte wide permutes where > the source isn't required to be a 8 bit boundary. So if these kinds of > operations are used often, then SIMD may be a requirement. That is what i think, too. Those cases are not for auto-vectorization, you would have to write them especially with the special SIMD capabilities in mind. > Of course, I welcome comments, additions, subtractions (!), etc. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: vector length CSR?
Author: MitchAlsup
Date: Tue, 24 Nov 2026 22:22
Date: Tue, 24 Nov 2026 22:22
122 lines
6977 bytes
6977 bytes
Thomas Koenig <tkoenig@netcologne.de> posted:
> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> > On 11/9/2026 9:08 AM, Stephen Fuld wrote:
By the way the first v in vVM is lower case.
> >
> > I issued the following "challenge".
> >
> >> I can't speak to the hardware complexity of the implementation. Perhaps
> >> that is a limiting factor. But barring that, and the mental effort
> >> required to "reorient" your thinking, I don't see why any new clean
> >> sheet design would use SIMD instructions. Perhaps someone can explain
> >> why it should.
> >
> > The results were, at least to me, quite enlightening. I think it might
> > be useful to summarize these responses. I group the types of problems
> > that people thought SIMD was better at than VVM into three areas.
> >
> > The first group is exemplified by Anton bringing up the types of
> > problems where memory values are reused in the vector registers. He
> > gave matrix multiplication as an example. Terje presented an algorithm
> > which others indicated was competitive with the SIMD method. Note that
> > I am not ruling out that there may be other problems that fit into this
> > group but aren't amenable to the kind of solution Terje presented. So I
> > count that as worst case, a "tie". But so far, not a compelling
> > argument for SIMD.
>
> I'm not really sure I understand, then. VVM always has to access
> memory at cache latencies (4-5 cycles); register access does not
> need that, and clever algorithms can resuse that data to good effect.
My guess is that when the execution window is big enough to absorb
the cache latency, then there is little advantage to SIMD (if any).
> > The second group is "reductions" of various types. Mostly, this came
> > down to the question of whether the operation on the given data type
> > could be parallelized or "reassociated". I think we have come down to
> > the following:
> >
> > For operations on unsigned integers, or on signed integers with certain
> > compile options, and operations such as MAX, VVM has the advantage as it
> > can parallelize them and, perhaps with some additional design work by
> > Mitch, combine the partial results at the end, including handling sizes
> > that are not a integer multiple of the amount of parallelization. This
> > seems like a big win for VVM.
>
> VVM is always at an advantage when the SIMDified and the size of
> the hardware SIMD registers is unknown at compile and can leave
> all the loop peeling and other assorted nastiness to hardware.
Of somewhat higher importance is that the compile time SIMD-width
is a burden on SIMD that vVM does not have. If todays vVM is 256-
bits wide and tomorrows' is 124-bits wide--that same code is just
as optimal today as it is tomorrow.
> But a four-lane SIMD, for example, could do the same. It would
> need a reduction step at the and, as well.
Just a note: a 4-lane DP FP SIMD pipeline is 256-bits wide, and can
handle {4-DP FP, 8 SP FP, 16 HP FP, 4 Dint, 8 Wint, 16 Hint, 32 Bint}.
> > For operations on signed integers where preserving possible internal
> > overflows, etc. are required VVM can't parallelize them (signified by
> > specifying 1 in the number of lanes field in the VEC instruction).
I see exception handling migrating from "take a trap" to "make flow
control exception-branches" and leave the whole mess to SW. How
much faster is {Branch-on-integer-arithmetic-anomaly Anom, label}
than taking the trap, having trap handling setup a signal handler
setup an exception frame on application stack, and calling signal
handler.
Newer exception experiments are looking to optimize TRY-THROW-CATCH
with various SW conventions and stacked data.
> That is an interesting question. Today's hardware does two's
> complement, so under "as if" rule a compiler could just happily do
> the summation in hardware and look at the end result; intermediate
> overflows will just be ignored, and as long as the end result fits,
> all is in order. A Fortran compiler calculating the SUM
> intrinsic could just do that. A C compiler could also do that
> if it chose to (and it seems that LLVM choses to do so at least
> for the a + b + c + d case).
>
> > But
> > there is still a more modest advantage for VVM in that reading the data
> > from memory doesn't "scrub" the cache, and the loop termination test is
> > a single instruction.
> >
> > For operations on floating point, with some "not yet filed" stuff, VVM
> > has the advantage in that the operation can be parallelized without loss
> > of precision.
> >
> > So overall, for this second group, I see no argument for SIMD.
>
> If VVM can do reductions, yes.
>
> > The third group, and one we really haven't discussed in this thread
> > beyond Thomas' first mention is wide permutations. I wasn't familiar
> > with the relevant capabilities in AVX512, so I had to do a little
> > research. While My 66000 has a permute instruction, and perhaps if
> > preceded by a Double instruction modifier can be wider, I don't see how
> > it can compete with the 512 byte wide permutation in three cycles
> > provided by AVX512, nor the capability to do byte wide permutes where
> > the source isn't required to be a 8 bit boundary. So if these kinds of
> > operations are used often, then SIMD may be a requirement.
>
> That is what i think, too.
Many times the indexes of the loaded memory provide for the kind
of permutation, so you don't need the PERM as an instruction; it
is just something that the vVM loop-to-loop analyzer needs to
figure out--once figured out {easy when constant} the LD-buffer
is routed to FUs based on the permutation.
> Those cases are not for auto-vectorization, you would have to
> write them especially with the special SIMD capabilities in mind.
>
> > Of course, I welcome comments, additions, subtractions (!), etc.
>
Re: vector length CSR?
Author: Thomas Koenig
Date: Wed, 25 Nov 2026 06:56
Date: Wed, 25 Nov 2026 06:56
47 lines
3458 bytes
3458 bytes
MitchAlsup <user5857@newsgrouper.org.invalid> schrieb:
> Thomas Koenig <tkoenig@netcologne.de> posted:
>
>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>> > The third group, and one we really haven't discussed in this thread
>> > beyond Thomas' first mention is wide permutations. I wasn't familiar
>> > with the relevant capabilities in AVX512, so I had to do a little
>> > research. While My 66000 has a permute instruction, and perhaps if
>> > preceded by a Double instruction modifier can be wider, I don't see how
>> > it can compete with the 512 byte wide permutation in three cycles
>> > provided by AVX512, nor the capability to do byte wide permutes where
>> > the source isn't required to be a 8 bit boundary. So if these kinds of
>> > operations are used often, then SIMD may be a requirement.
>>
>> That is what i think, too.
>
> Many times the indexes of the loaded memory provide for the kind
> of permutation, so you don't need the PERM as an instruction; it
> is just something that the vVM loop-to-loop analyzer needs to
> figure out--once figured out {easy when constant} the LD-buffer
> is routed to FUs based on the permutation.
This will work for some cases, but not for _real_ high-performance
applications.
Take a high-speed JSON parser such as
https://gitlab.ethz.ch/extra_projects/fastjson or simdjson. The
shuffling, masking etc is not possible with VVM in its current
state - everything would have to travel through memory, with
its latencies, and that would kill performance. I also do
not see a way to do equivalent things with VVM.
This kind of code will probably never be emitted by
auto-vectorization, this is for people who write assembly or
compiler intrinsics specific to the particular architecture,
which is just glorified assembler where the compiler does the
register allocation.
Once the reduction problem is solved, I think VVM will be superior
for the vast majority of code, but some very important niches
remain.
--
This USENET posting was made without artificial intelligence,
artificial impertinence, artificial arrogance, artificial stupidity,
artificial flavorings or artificial colorants.
Page 3 of 4 • 180 total messages
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads