Re:Prefix Sum with SIMD
by udbhavs on Saturday February 12, 2022 @06:17AM
(#30311894)
The whole book looks very full of interesting low level techniques. Do high level JIT compilers like the V8 or JVM apply vectorisation or any of the other optimisations mentioned there, or is that level of fine-tuned performance only possible if you code them manually in C++?
[ Parent
| on HN ]
People claim that the JVM is able to auto-vectorize simple loops:
https://stackoverflow.com/questions/59725341/java-auto-vecto...
That said, I tried the matrix-multiplication example from section 1.2 on different computers and with different jdk version, but I didn't manage to convince the JVM JIT to emit SIMD instructions. No idea whether the loop is too complex for the JIT or whether there is some secret JVM option that I'm not aware of.
It is not technically legal to use SIMD on most floating-point loops, including the inner product in matrix multiplication, because rounding errors are not commutative. C compilers don't vectorize such loops either unless you pass the -ffast-math flag. I'm sure the JIT compiler of JVM has a similar option.
(read the article I linked below, it's all explained there)
Author here. I wrote a separate section trying to answer this question: https://en.algorithmica.org/hpc/complexity/languages/
tl;dr: to some extent, but mostly no
Hey author. This looks like a very approachable book given the subject.
Still on chapter 2, but really enjoying it. Instant buy for me.
Thanks for your effort.
Most JITs have basic autovectorization support, but it's generally not that good.
Re:Prefix Sum with SIMD
by khoobid_shoma on Saturday February 12, 2022 @09:11AM
(#30312949)
I think topics are nicely explained in C and assembly but not C++.