Re: SIMD layout again
"Tim Bradshaw (as tfb at tfeb dot org)" <[email protected]> Wed, 15 Jul 2026 17:51:18 +0100
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
On 15 Jul 2026, at 16:13, Yuri Davidovsky <[email protected]> wrote: > > I did find the syntax > > ... > ((x :array t :type fixnum :initform 12 :index-mappings ((2 1) (4 2) (6 3))) > (y :array t :type fixnum :initform 13 :index-mappings ((1 4) (3 5) (5 6))) > ... > > somewhat confusing first The array slots do correspond to slots in the instance, but the slot holds an object which can be used by the slow accessors, so things like (slot-ref thing 'x i j ...) and named accessors. But anything which wants to be fast uses the array slot macros, for instance: (with-array-slots (x y) (thing twod) (dotimes (i ...) (dotimes (j ...) ... (x i j) ... (y i j) ... (setf (x i j) ...)))) (you can also rename the local macro as (with-array-slots ((<name> x) ...) (...) ...) as you'd expect). The local macros this binds compile down to aref with a bunch of type declarations added for you so you don't have to think much. They need the class name so they can know the layout at compile time (things are constrained so that the layout of any subclass will be compatible with superclasses by, among other things, requiring single inheritance for classes with array slots (you can have non-SOA classes as well, but only one SOA class). If you don't use index mapping it is very quick. _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html