logoalt Hacker News

wk_endlast Tuesday at 6:02 PM3 repliesview on HN

    * the SB-SIMD contrib now supports ARM64. (Thanks to Sylvia Harrington)
    * AVX512 instructions are now supported on X86-64. (Thanks to Robert Smith and Arthur Miller)
    * additional support for SIMD instructions on ARM64 and X86-64. (Thanks to Arthur Miller)
These seem like pretty awesome additions. Does anyone know how SIMD works in SBCL? Is this at the codegen layer? i.e. can it auto-vectorize or anything like that? Or are these intrinsics you have to explicitly ask for?

Replies

peri-clyesterday at 8:32 AM

> "AVX512 instructions are now supported on X86-64"

This is the first news I've seen on HN in weeks that I am genuinely excited about! I have several AVX-2 hobby projects in Common Lisp, and an AVX-512 machine. It's an unexpected surprise to read this morning that this very useful ISA is suddenly unlocked. I'll be trying it out right away.

(edit: Looks like they mean *compiler* support for AVX-512, but not SB-SIMD definitions (yet). So I believe the only way for end-users to call AVX-512 instructions right now is to write custom VOP's).

> "Or are these intrinsics you have to explicitly ask for?"

There are language SIMD types and you explicitly use SIMD functions that operate on them. I believe it's essentially the same idea as C intrinsics. You can for example write (interactively)

    (u32.8+ (make-u32.8 0 1 2 3 4 5 6 7)
            (u32.8 10))

    ;; => #<SB-EXT:SIMD-PACK-256   10   11   12   13   14   15   16   17>
And that's VPADDD under the hood. Or reading an array

    (loop with sum = (f32.8 0.0f0)
          for index below (* 8 (floor length 8)) by 8
          do (setq sum (f32.8+ (f32.8-aref array index)
                               sum))
          finally (return sum))
which compiles down to a small loop around the vector insts

    VMOVUPS YMM1, [RDX+RCX*2+1]
    VADDPS YMM0, YMM1, YMM0
I much prefer it to writing intrinsics in C (and the results are just as good). It's an interactive, exploratory, coding: I write small modular functions, SBCL compiles them on the fly, I glue them together with high-level language constructs.
show 1 reply
wild_egglast Tuesday at 6:11 PM

No auto-vectorization yet, but you may find this illuminating: https://www.stylewarning.com/posts/nbody

show 1 reply