5 ms·
I mean, if you are being serious, there are tons of reasons to use the C API. I heavily use intrinsics in C++ templates. Clever use of templates allows me to wr
by stagger87 8y ago
I mean, if you are being serious, there are tons of reasons to use the C API. I heavily use intrinsics in C++ templates. Clever use of templates allows me to write a function once which can compile to SSE/AVX/AVX-512 and different data types (float/double) and different arch (x86/x64). In most situations this will be faster than assembly since I can inline everything wherever I want. When the need arises I will drop down to assembly to try to get any last perf gains, but otherwise I found that clang/icc/msvc are pretty good at generating assembly.
- obl 8y agoI simply meant that the bare xxxintrin.h stuff is annoying enough that if you're using it directly you might as well write assembly. I absolutely agree that once wrapped up there are good reasons to use a language-level interface instead of asm for most things.
- gameswithgo 8y agoAs I get more familiar with rust macros I may compress this down a bunch. It will make it easier to maintain.
- stagger87 8y agoAs another example, this morning I needed to perform a small convolution in an inner loop. Since I'm targeting x64 under the msvc compiler I can't write an external assembly function and have it inlined into the inner loop. Therefore I was left with just using the raw intrinsics from intrin.h for like, 10 lines of code. The simplicity of the convolution means the compiler will have no problems generating optimal code.
- gameswithgo 8y agoFor me the ugliness of the intrinsics has gone away, like parens do for a lisp programmer.
- burntsushi 8y ago> I simply meant that the bare xxxintrin.h stuff is annoying enough that if you're using it directly you might as well write assembly. The compiler is aware of many of those intrinsics and can perform optimizations around them. Hand rolling all of that in Assembly would be quite the chore. Using these intrinsics is, IMO, considerably easier.