Skip to content

Instantly share code, notes, and snippets.

@jackmott
Last active March 28, 2017 16:19
Show Gist options
  • Select an option

  • Save jackmott/89893aa4e88616af0563103cf8bad669 to your computer and use it in GitHub Desktop.

Select an option

Save jackmott/89893aa4e88616af0563103cf8bad669 to your computer and use it in GitHub Desktop.
SIMD and jits
With no JIT that I am aware of (not jvm, not ryujit, not v8) can you make say, _mm256_sll_epi32 happen, at all.
With C++ I can call that with an intrinsic: `_mm_and_ps(x,y);` Now is it a pain, because to hit the various SIMD targets, I have
to write the SSE2 and AVX512 equivalents and detect which to use at runtime? Yes, it is a pain, though libraries like bSIMD exist
to remove that pain.
Also, no JIT that I am aware of can autovectorize something simple like a for loop adding up floats. The JVM doesn't do it, .NET doesn't
auto vectorize any user code ever. There isn't time to figure those out at runtime.
GCC, MSVCC, and LLVM, and Intel AOT compilers can all auto-vectorize simple cases like that, and Intel can sometimes do rather
amazing autovectorization.
The only bright spot that actually exists is that .NET (and Haskell apparently) let you hit a *small subset* of available SIMD operations,
and you can write that code one time and the JIT figures out which SIMD instruction set to use at runtime. Which is great. But
you still can't ceil or floor or shift or convert. Ceil, Floor, and Convert appear to be coming, which is great, instructions introduced
10? years ago you can finally use from C# and F#. It sounds like shift will not be possible to implement in C# though.
Which is kind of a problem.
So, the claim that "without JIT it would be hard to take advantage of AVX, etc." is misleading. There are some potential advantages, maybe, in theory, that doesn't exist yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment