🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #810

Re: vector length CSR?

#810
From: Thomas Koenig
Date: Thu, 19 Nov 2026 18:00
64 lines
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.
Technical Details
Message-ID: <11dndfd$2fr9j$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cpqih$acf5$1@dont-email.me> <sgu0flpndaqltpdbft40fghmi7vk78q2hs@4ax.com> <11cq2v7$dh5b$1@dont-email.me> <8jk1fl182pskj3fsmp4ju6qf420pgl0htg@4ax.com> <11csull$1ef6e$1@dont-email.me> <2026Nov9.230104@mips.complang.tuwien.ac.at> <11cvcr4$28k7g$1@dont-email.me> <11d3npt$3mmho$1@dont-email.me> <11dn936$2ebc2$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Thomas Koenig <tkoenig@netcologne.de>
Newsgroups: comp.arch
Subject: Re: vector length CSR?
Date: Thu, 19 Nov 2026 18:00:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <11dndfd$2fr9j$1@dont-email.me>
References: <11cpqih$acf5$1@dont-email.me>
 <sgu0flpndaqltpdbft40fghmi7vk78q2hs@4ax.com> <11cq2v7$dh5b$1@dont-email.me>
 <8jk1fl182pskj3fsmp4ju6qf420pgl0htg@4ax.com>
 <11csull$1ef6e$1@dont-email.me>
 <2026Nov9.230104@mips.complang.tuwien.ac.at>
 <11cvcr4$28k7g$1@dont-email.me> <11d3npt$3mmho$1@dont-email.me>
 <11dn936$2ebc2$1@dont-email.me>
Injection-Date: Thu, 19 Nov 2026 18:00:14 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2616627"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18uo6SkUb+oYa1fPhMxdlAQJ5pXqx8Tmv4="; posting-host="0ad3151e3bbdab8598ee465797a16a02"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:ImG18Np7zkN8cipKe6rYk11E0Eo= sha256:RlbytyuR+8hdu2NvOc5H5KsODfNZJbKtJTKNgCZNZuM=
	sha1:mN/tD1WGU7+p3ALqQTMP0C0SozA= sha256:bD4MLK4f8Du/OysbIiTDRhQYjZLEe4+/o690G4fzDko=