vorner / slipstream

Nudging the compiler to auto-vectorize things
Apache License 2.0
71 stars 4 forks source link

Shuffles/swizzles #8

Open HadrienG2 opened 1 year ago

HadrienG2 commented 1 year ago

While many algorithms can get by with only arithmetic operations, as soon as things get more complex, the need to move things across vector lanes or from vector to vector arises. For now, of those operations, slipstream only supports masked blend.

Now, in my experience, compilers are not very good at autovectorizing those operations, so you may want to exclude them from slipstream or at least put a warning on them for this reason. But since these are commonly used SIMD operations, I thought you might want to consider exposing them in the hope that compilers later get good at optimizing them, as you already do for gather and scatter.

Common shuffles that tend to have pretty good hardware support or require nontrivial code, which may thus call for special casing in the API, are...

The experimental std::simd API exposes some of those and may be used as a source of inspiration for naming and method signatures.

vorner commented 1 year ago

Hello

I must admit, I don't really have the time to put into writing it. But I have no objection to these APIs existing.

Would you want to send a pull request for these (preferably, in smaller chunk, let's say each API separately)? It would probably mean finding an example/test algorithm for each and seeing how bad the compiler is in auto-vectorizing it, etc.

HadrienG2 commented 1 year ago

Well, I have the same time problem, so it may take a while, but I'll try to contribute some of those.