Hacker News new | ask | show | jobs
by neonsunset 573 days ago
Numerics in .NET are not a high-level abstraction and do out of box what many mature vectorized libraries end up doing themselves - there is significant overlap between NEON, SSE* and, if we overlook vector width, AVX2/512 and WASMs PackedSIMD.

.NET has roughly three vector APIs:

- Vector<T> which is platform-defined width vector that exposes common set of operations

- Vector64/128/256/512<T> which has wider API than the previous one

- Platform intrinsics - basically immintrin.h

Notably, platform intrinsics use respective VectorXXX<T> types which allows to write common parts of the algorithm in a portable way and apply platform intrinsics in specific areas where it makes sense. Also some method have 'Unsafe' and 'Native' variants to allow for vector to exhibit platform-specific behavior like shuffles since in many situations this is still the desired output for the common case.

The .NET's compiler produces competitive with GCC and sometimes Clang codegen for these. It's gotten particularly good at lowering AVX512.