Alder Lake and AVX-512

By: Jörn Engel (joern.delete@this.purestorage.com),
Room: Moderated Discussions
Jukka Larja (roskakori2006.delete@this.gmail.com) on July 13, 2020 8:38 am wrote:
> Jörn Engel (joern.delete@this.purestorage.com) on July 12, 2020 11:35 am wrote:
>
> > Simple parsers.
>
> Don't take this the wrong way, but do you think a parser is still simple, if you use SIMD to implement it? If
> I wrote a parser like that at work, either of two things would happen: 1) I'd be the only one ever touching
> the code, or 2) someone else would need to touch the code, and would promptly reimplement it without SIMD.

Any code you vectorize ends up less pleasant to read or work with. Not sure if simple is the right term, but just like assembler, you end up with a small subset of programmers still willing to look at the code and work with it.

I have vectorized simple parsers. If they had been much more complicated it would have overflowed both my brain capacity and the available registers.

> > Data modifications like matrix transpose or similar. Dot-products.
>
> We do some vector and matrix algebra with SIMD, but I can't say much about
> it. It's mostly based on vector4, so only makes use of four wide SIMD.

That sounds like you have 32bit or 64bit types. I agree, going 4x faster isn't that exciting. If you can get by with smaller data types and go 16x or 32x faster, you are willing to suffer a bit more for that advantage.

> > I think of vector programming similar to object orientation
> > or functional programming. If you read an article
> > and play around with it for a day you probably won't get it or see any benefit. But if you commit some
> > time and allow your brain to rewire you start to see more and more applications where it helps.
>
> I'm sure if I spent significant time with SIMD, I'd see more places where it could make sense. However, I've
> already spent more time with it than most programmers ever will. If I can't name a single place in our million
> line codebase to make real use of it, how could I expect it will have significance in the future?

Run a profiler and see what stands out. If you have one thing responsible for 10% of runtime, it might be worth it. Or if you have one thing you don't do because it costs too much. And just like OO or functional programming, you don't have to do it just because the cool kids seem to. Only do it if it makes sense to you.

> > And the biggest impediment is that we don't have a nice way to express vector code.
> > Assembler is, well, assembler. Intel intrinsics are assembler disguised as C functions
> > with a syntax that seems universally detested. I ended up writing my own small library
> > simply to be able to read my own code two months later without going crazy.
>
> The problem for me is that pretty much only abstraction that I know could be easily used
> would be Vec3 operations, and that at the best gives just 3x improvement[1]. Even the amount
> of matrix calculations in a game engine are low. All the hard work happens on GPU.

The abstraction I wanted and eventually noticed I could get is pretty much C syntax.

a += b;
a >>= 4;

That is code I can read and work with. It doesn't make a huge difference whether "a" is a u8, u64 or vector of u16. It took me about a year of suffering until I realized that it's possible to do that, you basically have to define your own types and then provide wrapper functions every time you want to use Intel intrinsics to do the type casting back and forth.

typedef uint16_t u16_256 __attribute__((vector_size(32), may_alias));
typedef uint8_t u8_256u __attribute__((vector_size(32), may_alias, aligned(1)));
static inline u8_256 read256(const void *buf) { return *(const u8_256u *)buf; }
...

Now I have all intrinsics confined inside a header-library. If I come across some old code using intrinsics, I convert it before I even start reading. To me it dramatically reduces the brain-tax I have to pay for vectorization. As a result I started using it more.

I think C syntax is a wonderful thing and Ken Thomson was absolutely right when he decided that BCPL was mostly a fine language, except for the syntax. It is absolutely important to express simple things in simple terms without a ton of noise distracting you.

a = _mm256_add_epi16(a, b);
a = _mm256_srl_epi32(b, 4);

Be honest, did you spot the two bugs I slipped into this code? If you didn't you were probably distracted by the noise. Having a single type for integer vectors of any size is another mistake. Typically if you start with u16, you want to continue with u16. That's why you select an appropriate type instead of specifying it with every single instruction. There are exceptions and you want the exceptions to stand out. If I see a cast I know that I need to pay attention. I also know that the programmer meant to do a cast instead of just typing epi32 when it should have been epi16.
< Previous Post in ThreadNext Post in Thread >
Thread (327 posts)
TopicPosted ByPosted
Alder Lake and AVX-512me
  Alder Lake and AVX-512Linus Torvalds
    informative (NT)blue
    grumpyMichael S
      grumpyme
    area and power cost of AVX-512Michael S
      area and power cost of AVX-512Anon
        area and power cost of AVX-512Michael S
          area and power cost of AVX-512Travis Downs
      area and power cost of AVX-512Travis Downs
    Alder Lake and AVX-512Maynard Handley
      Alder Lake and AVX-512Ungo
        Alder Lake and AVX-512Maynard Handley
      Alder Lake and AVX-512Linus Torvalds
        Alder Lake and AVX-512⚛
          Alder Lake and AVX-512Michael S
          HDRAnon3
            HDR10 in Kaby Lake?David Kanter
              HDR10 in Kaby Lake?Maynard Handley
                Thanks for the link (NT)David Kanter
              HDR10 in Kaby Lake?Anon3
        Alder Lake and AVX-512Dummond D. Slow
        AVX-512 with narrow ex units?m
          AVX-512 with narrow ex units?Anon
            AVX-512 with narrow ex units?Paul A. Clayton
              AVX-512 with narrow ex units?Anon
                AVX-512 with narrow ex units?Paul A. Clayton
                  AVX-512 with narrow ex units?Anon
                    AVX-512 with narrow ex units?Jukka Larja
                      AVX-512 with narrow ex units?Gabriele Svelto
                        AVX-512 with narrow ex units?Jouni Osmala
                          AVX-512 with narrow ex units?Jukka Larja
                      AVX-512 with narrow ex units?Eugene Nalimov
                        AVX-512 with narrow ex units?Jukka Larja
                        AVX-512 with narrow ex units?Gabriele Svelto
                          AVX-512 with narrow ex units?Jukka Larja
          AVX-512 with narrow ex units?-.-
            AVX-512 with narrow ex units?Travis Downs
    Alder Lake and AVX-512Jörn Engel
      Alder Lake and AVX-512Chester
        Alder Lake and AVX-512Jörn Engel
        Alder Lake and AVX-512Michael S
        Alder Lake and AVX-512Travis Downs
      Alder Lake and AVX-512Linus Torvalds
        Alder Lake and AVX-512Jörn Engel
          Alder Lake and AVX-512N Owen
            Alder Lake and AVX-512Michael S
            Alder Lake and AVX-512anon2
          Alder Lake and AVX-512Travis Downs
            Alder Lake and AVX-512Jörn Engel
      Alder Lake and AVX-512Doug S
        Alder Lake and AVX-512Michael S
    Alder Lake and AVX-512Travis Downs
      Alder Lake and AVX-512Veedrac
        Alder Lake and AVX-512anon2
          Alder Lake and AVX-512Veedrac
            Alder Lake and AVX-512anon2
              Alder Lake and AVX-512Anon3
                Alder Lake and AVX-512anon2
              Alder Lake and AVX-512Veedrac
                Alder Lake and AVX-512anon2
                  Alder Lake and AVX-512Veedrac
                    Alder Lake and AVX-512anon2
                  Alder Lake and AVX-512David Hess
                    Alder Lake and AVX-512anon2
                Alder Lake and AVX-512⚛
                  Alder Lake and AVX-512anon2
                    PentiumMMX vs Transmeta's VLIW in hindsight⚛
                      PentiumMMX vs Transmeta's VLIW in hindsightMaynard Handley
                      PentiumMMX vs Transmeta's VLIW in hindsightanon2
                      VLIW, OOO, Pairing, and FusionChester
                        Poulson was in-order (NT)anon2
                        VLIW, OOO, Pairing, and FusionMichael S
                        Itanium is NOT VLIWHeikki Kultala
                          Itanium is NOT VLIWAdrian
                            Itanium crappiness and EPIC - and could EPIC still have something good in it?Heikki Kultala
                              Itanium crappiness and EPIC - and could EPIC still have something good in it?anon2
                                Itanium crappiness and EPIC - and could EPIC still have something good in it?dmcq
                              Itanium crappiness and EPIC - and could EPIC still have something good in it?j
                                Itanium crappiness and EPIC - and could EPIC still have something good in it?Tim McCaffrey
                              Itanium crappiness and EPIC - and could EPIC still have something good in it?Linus Torvalds
                                Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architectureHeikki Kultala
                                  Turn that on its head?Ray
                                    Turn that on its head?Anon
                                    Turn that on its head?Maynard Handley
                                    Turn that on its head?anon2
                                    Turn that on its head?anon3
                                    Turn that on its head?Heikki Kultala
                                      Turn that on its head?Anon
                                        Turn that on its head?Heikki Kultala
                                          Turn that on its head?Brett
                                            Turn that on its head?Brett
                                      Bundling OOO entries does this implicitlyDavid Kanter
                                      Turn that on its head?anon
                                  Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architectureMaynard Handley
                                  Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architecturewumpus
                                    Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architectureDoug S
                                      what Intel would have doneMichael S
                                        what Intel would have doneDoug S
                                        what Intel would have doneAnon
                                          what Intel would have doneMichael S
                                            what Intel would have doneMontaray Jack
                                    Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architectureHeikki Kultala
                                      Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architecturewumpus
                                  Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architectureMichael S
                                    Itanium is not synomym of EPIC. Itanium is just the most common EPIC-style architectureHeikki Kultala
                          thanksChester
      Alder Lake and AVX-512Linus Torvalds
        Alder Lake and AVX-512never_released
          Alder Lake and AVX-512Michael S
        Alder Lake and AVX-512anon2
      Alder Lake and AVX-512Doug S
      Alder Lake and AVX-512Michael S
        Alder Lake and AVX-512rwessel
      Alder Lake and AVX-512-.-
        Alder Lake and AVX-512Travis Downs
    Alder Lake and AVX-512Geoff Langdale
      Alder Lake and AVX-512anon
      Alder Lake and AVX-512Jörn Engel
        Alder Lake and AVX-512Michael S
        Alder Lake and AVX-512Jukka Larja
          Alder Lake and AVX-512Maynard Handley
            Alder Lake and AVX-512Jukka Larja
              Alder Lake and AVX-512Montaray Jack
                Alder Lake and AVX-512Jukka Larja
          Alder Lake and AVX-512Jörn Engel
            Alder Lake and AVX-512Linus Torvalds
              Alder Lake and AVX-512Linus Torvalds
                Alder Lake and AVX-512anonymou5
                  Alder Lake and AVX-512Linus Torvalds
                    Alder Lake and AVX-512anonymou5
                      Alder Lake and AVX-512Linus Torvalds
                        Alder Lake and AVX-512anonymou5
                          Alder Lake and AVX-512Jose
                  Alder Lake and AVX-512gallier2
                Alder Lake and AVX-512gallier2
                  Alder Lake and AVX-512Linus Torvalds
                    Alder Lake and AVX-512Doug S
                      Alder Lake and AVX-512Brett
                        Alder Lake and AVX-512Linus Torvalds
                          Alder Lake and AVX-512Maynard Handley
                            Alder Lake and AVX-512Michael S
                            Alder Lake and AVX-512Linus Torvalds
                              OS X file names normalizationMichael S
                                OS X file names normalizationSimon Farnsworth
                                  OS X file names normalizationMichael S
                                    OS X file names normalizationSimon Farnsworth
                                OS X file names normalizationDoug S
                                  OS X file names normalizationMichael S
                                    OS X file names normalizationLinus Torvalds
                                      OS X file names normalizationLinus Torvalds
                                      OS X file names normalizationgallier2
                                    OS X file names normalizationgallier2
                                  OS X file names normalizationRob Thorpe
                                    OS X file names normalizationDoug S
                                      OS X file names normalizationMaynard Handley
                                        OS X file names normalizationLinus Torvalds
                                          OS X file names normalizationAnon3
                                            OS X file names normalizationDoug S
                                              OS X file names normalizationLinus Torvalds
                                                OS X file names normalizationAnon3
                                                  OS X file names normalizationJukka Larja
                                                OS X file names normalizationgallier2
                                                  OS X file names normalizationLinus Torvalds
                                                    OS X file names normalizationDummond D. Slow
                                                      OS X file names normalizationLinus Torvalds
                                                      OS X file names normalizationSimon Farnsworth
                                              OS X file names normalizationAnon3
                                                OS X file names normalizationDoug S
                              Alder Lake and AVX-512Maynard Handley
                            File Systems and VC ProblemsRob Thorpe
                    vectorization of utf8Robert David Graham
                      vectorization of utf8anon2
                        vectorization of utf8Robert David Graham
                          vectorization of utf8anon2
                        vectorization of utf8Maynard Handley
                      vectorization of utf8Gabriele Svelto
                    Alder Lake and AVX-512gallier2
              Alder Lake and AVX-512Jörn Engel
                Alder Lake and AVX-512Linus Torvalds
                  Alder Lake and AVX-512Jörn Engel
                    Alder Lake and AVX-512-.-
                      Alder Lake and AVX-512Jörn Engel
            Alder Lake and AVX-512Jukka Larja
              Alder Lake and AVX-512Jörn Engel
                Alder Lake and AVX-512Michael S
                  Alder Lake and AVX-512Jörn Engel
                    Alder Lake and AVX-512Michael S
                      Alder Lake and AVX-512Jörn Engel
                Alder Lake and AVX-512Jukka Larja
      Alder Lake and AVX-512Linus Torvalds
        Alder Lake and AVX-512Brett
          Alder Lake and AVX-512David Hess
            Alder Lake and AVX-512anonymou5
              Alder Lake and AVX-512Brett
        Alder Lake and AVX-512Geert
          AMD's FPUChester
            Is 3|5 lower than 4?Michael S
              Is 3|5 lower than 4?Chester
        Alder Lake and AVX-512Geoff Langdale
          Alder Lake and AVX-512me
          Alder Lake and AVX-512Michael S
          Alder Lake and AVX-512Linus Torvalds
            ~80% of details are wrong. So what one can expect from conclusions? :( (NT)Michael S
              ~80% of details are wrong. So what one can expect from conclusions? :(anonymous2
            Alder Lake and AVX-512nobody in particular
              Alder Lake and AVX-512Linus Torvalds
                Alder Lake and AVX-512nobody in particular
                  Alder Lake and AVX-512me
                    Alder Lake and AVX-512Maynard Handley
            Alder Lake and AVX-512UnmaskedUnderflow
            AVX-512 vs SVE2-.-
              AVX-512 vs SVE2noko
                AVX-512 vs SVE2-.-
            Alder Lake and AVX-512Geoff Langdale
              Could you please stop top-posting (NT)Jukka Larja
              Alder Lake and AVX-512Romain Dolbeau
            Alder Lake and AVX-512Spiteful Sprites
              Alder Lake and AVX-512nobody in particular
                Alder Lake and AVX-512Spiteful Sprites
                  Alder Lake and AVX-512Jouni Osmala
                  RISC-V & commercial support (was: Alder Lake and AVX-512)Romain Dolbeau
                    RISC-V & commercial support (was: Alder Lake and AVX-512)Romain Dolbeau
              Alder Lake and AVX-512Linus Torvalds
            AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Romain Dolbeau
              AVX-512/SVE & HPC (was: Alder Lake and AVX-512)anon
                AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Romain Dolbeau
                  AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Maynard Handley
                  AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Doug S
                  AVX-512/SVE & HPC (was: Alder Lake and AVX-512)anon
              AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Linus Torvalds
                AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Romain Dolbeau
                  Configurable cache line size?Doug S
                    Configurable cache line size?dmcq
                    Configurable cache line size?Romain Dolbeau
                    Configurable cache line size?NoSpammer
                    Configurable cache line size?Pixie
                      Configurable cache line size?Etienne
                        Configurable cache line size?Hugo Décharnes
                  Cache line sizeMark Roulo
                    Cache line sizeanon
                  AVX-512/SVE & HPC (was: Alder Lake and AVX-512)Gabriele Svelto
                    AVX-512/SVE & HPC (was: Alder Lake and AVX-512)dmcq
                      AVX-512/SVE & HPC (was: Alder Lake and AVX-512)zArchJon
            Macro-instructions to the rescue⚛
              Some fundamentals haven't changedChester
                Some fundamentals haven't changed⚛
                  Some fundamentals haven't changeddmcq
                    Some fundamentals haven't changed⚛
                    Some fundamentals haven't changedBrett
                      Some fundamentals haven't changedBrett
                      What belt is.Heikki Kultala
                        What belt is.Michael S
                          What belt is.Brett
                            What belt is.Michael S
                              What belt is.Brett
                                What belt is.Doug S
                                  What belt is.Andrew Clough
                                    What belt is.dmcq
                                      Mill Compiler still MIA?Geoff Langdale
                                        If they release the compiler, how they will blame the still-in-development compiler for the lacklust (NT)Anon
                                          If they release the compiler, how they will blame the still-in-development compiler for the lacklustAnon
                                        Apparently they're busy writing a kernel...Anon
                                          Apparently they're busy writing a kernel...dmcq
                        What belt is.⚛
                          What belt is.anonymous2
                            What belt is.Doug S
                              What belt is.⚛
        gooduseruser
      Alder Lake and AVX-512-.-
        Alder Lake and AVX-512-.-
      Alder Lake and AVX-512j
        Alder Lake and AVX-512Michael S
          Alder Lake and AVX-512j
            Alder Lake and AVX-512dmcq
              Alder Lake and AVX-512Michael S
                Alder Lake and AVX-512Maynard Handley
                Alder Lake and AVX-512dmcq
                  Alder Lake and AVX-512dmcq
                    Alder Lake and AVX-512Michael S
                      Alder Lake and AVX-512dmcq
                        Alder Lake and AVX-512Michael S
                          Alder Lake and AVX-512dmcq
                            Alder Lake and AVX-512Michael S
                              Alder Lake and AVX-512dmcq
                                Alder Lake and AVX-512Michael S
                                  Alder Lake and AVX-512dmcq
                                    GV100 + POWER9Michael S
                                      GV100 + POWER9dmcq
                                        GV100 + POWER9dmcq
                        Alder Lake and AVX-512dmcq
    Alder Lake and AVX-512o
    Alder Lake and AVX-512⚛
      Alder Lake and AVX-512⚛
      Alder Lake and AVX-512Linus Torvalds
        Alder Lake and AVX-512⚛
        Alder Lake and AVX-512Michael S
          x87 crapHeikki Kultala
            x87 crapMichael S
              x87 crapHeikki kultala
                x87 crapMichael S
                  Sparc and PA-RISC vs pentium FP performanceHeikki Kultala
                    Sparc and PA-RISC vs pentium FP performanceanonymous2
          Alder Lake and AVX-512Doug S
            Alder Lake and AVX-512Michael S
    Alder Lake and AVX-512David Kanter
      Alder Lake and AVX-512anon
      ~0% of users do much FP outside of GPUs for games (NT)anonymous2
        ~0% of users do much FP outside of GPUs for gamesMaynard Handley
        not trueChester
          not trueMichael S
            not trueChester
              not trueanonymous2
                not trueMaynard Handley
                  not trueChester
            not trueDoug S
              not trueAnon
                not trueMaynard Handley
              not trueMaynard Handley
          not trueLinus Torvalds
            not trueDummond D. Slow
              not trueMaynard Handley
                not trueDummond D. Slow
            not true (about FP, not avx-512)Chester
  Alder Lake and AVX-512Travis Downs
    Alder Lake and AVX-512-.-
      Alder Lake and AVX-512-.-