🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #812

Re: vector length CSR?

#812
From: Stephen Fuld
Date: Thu, 19 Nov 2026 18:49
70 lines
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)
Technical Details
Message-ID: <11dngb5$2he51$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> <11dndfd$2fr9j$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: Stephen Fuld <sfuld@alumni.cmu.edu.invalid>
Newsgroups: comp.arch
Subject: Re: vector length CSR?
Date: Thu, 19 Nov 2026 10:49:07 -0800
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <11dngb5$2he51$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>
 <11dndfd$2fr9j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 19 Nov 2026 18:49:10 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2668705"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/LNBLj33NsPElCzoXn5Lo2N53rfxsqPUM="; posting-host="b60df9889f50627eb745c7e3ad5cb98b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1d9xlHzlN0F4JR6H2NPWZbI1WgQ= sha256:GteMVozX3yHJxFBnIGRVxkEwyPlC/SkS13K4nxTTdsU=
	sha1:cD/h4RcqahwbjAJh8c9SMpY1dVE= sha256:NuCQBe/mZJn94BUo2g1UAOZsdwIby7iZDo0SsApOTXs=
In-Reply-To: <11dndfd$2fr9j$1@dont-email.me>
Content-Language: en-US