Re: The myth of fingerprints, er, no, garbage collectors

"Yuri Davidovsky (as work at disclosure dot ie)" <[email protected]> Sun, 28 Jun 2026 18:05:58 +0200
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
--Apple-Mail=_3B0739FE-7963-49EB-A8A2-D30546B83B43
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8


> On 28 Jun 2026, at 17:40, Tim Bradshaw <[email protected]> wrote:
>=20
> I am confused (really, this isn't rhetorical) about why you need this =
typed-aref stuff for SIMD.

Because you can put any fundamental type into a single vector. You can =
have single floats, double floats, unsigned bytes 16, signed bytes 16 in =
the same array.

>=20
> As best I can tell what you need to make use of SIMD instructions is =
to be able to pad arrays of whatever type to whatever lengths the SIMD =
instructions like.  But SIMD is, well, single instruction on multiple =
things, so the things in your array are all going to want to be the same =
data type.

Sure. That is why you group similar fields together in batches to be =
processable in parallel. So in case of a particle struct you have

|x0 x1 x2 x3 | y0 y1 y2 y3|

where you have a group of 4 X single float fields followed by a group of =
4 Y fields. If you wanted to calculate the hypothenuse by sqrt(x=C2=B2 + =
y=C2=B2), you could do that for 4 XY pairs in a go on a 4 lane 32 bit =
each SIMD.

There is no real necessity to do it this way and the approach that you =
chose with multiple arrays also works fine, however it burdens the =
prefetcher with having to stream data from multiple locations at the =
same time, which is not ideal. In other words, using a single array =
helps to use the RAM bandwidth more efficiently.

Also in this way you can have 1:1 relationship with arrays of structs in =
C in case you need to do struct processing in some specialised external =
library.

In relation to having to write C to use SIMD in LW that is not =
necessarily true: on MacOS there are libraries for vector processing, =
you just need to put together FLI bindings for them, dbm has done that =
before, I think.=

--Apple-Mail=_3B0739FE-7963-49EB-A8A2-D30546B83B43
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" =
content=3D"text/html; charset=3Dutf-8"></head><body =
style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; =
line-break: after-white-space;"><br><blockquote type=3D"cite">On 28 Jun =
2026, at 17:40, Tim Bradshaw &lt;[email protected]&gt; wrote:<br><br =
class=3D"Apple-interchange-newline">I am confused (really, this isn't =
rhetorical) about why you need this typed-aref stuff for =
SIMD.<br></blockquote><div><br></div><div>Because you can put any =
fundamental type into a single vector. You can have single floats, =
double floats, unsigned bytes 16, signed bytes 16 in the same =
array.</div><br><blockquote type=3D"cite"><br>As best I can tell what =
you need to make use of SIMD instructions is to be able to pad arrays of =
whatever type to whatever lengths the SIMD instructions like. &nbsp;But =
SIMD is, well, single instruction on multiple things, so the things in =
your array are all going to want to be the same data =
type.</blockquote><br>Sure. That is why you group similar fields =
together in batches to be processable in parallel. So in case of a =
particle struct you have<div><br></div><div><font face=3D"Courier =
New"><b>|x0 x1 x2 x3 | y0 y1 y2 =
y3|</b></font></div><div><br></div><div>where you have a group of 4 X =
single float fields followed by a group of 4 Y fields. If you wanted to =
calculate the hypothenuse by <i>sqrt(x=C2=B2 + y=C2=B2)</i>, you could =
do that for 4 XY pairs in a go on a 4 lane 32 bit each =
SIMD.</div><div><br></div><div>There is no real necessity to do it this =
way and the approach that you chose with multiple arrays also works =
fine, however it burdens the prefetcher with having to stream data from =
multiple locations at the same time, which is not ideal. In other words, =
using a single array helps to use the RAM bandwidth more =
efficiently.</div><div><br></div><div>Also in this way you can have 1:1 =
relationship with arrays of structs in C in case you need to do struct =
processing in some specialised external =
library.</div><div><br></div><div>In relation to having to write C to =
use SIMD in LW that is not necessarily true: on MacOS there are =
libraries for vector processing, you just need to put together FLI =
bindings for them, dbm has done that before, I =
think.</div></body></html>=

--Apple-Mail=_3B0739FE-7963-49EB-A8A2-D30546B83B43--

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html