4 ms·
> FFmpeg team has a weird vendetta against intrinsics To be fair, ffmpeg is really old software. Wikipedia says they released their initial version in the end
by Const-me 2y ago
> FFmpeg team has a weird vendetta against intrinsics
To be fair, ffmpeg is really old software. Wikipedia says they released their initial version in the end of 2000. The software landscape was very different.
Back then, there were multiple competing CPU architectures. In modern world we only have two mainstream ones, AMD64 and ARM64, two legacy ones in the process of being phased out, x86 and 32-bit ARM, and very few people care about any other CPUs.
Another thing, C compilers of 2000 weren’t good in terms of performance of the generated code. Clang only arrived in 2007. In 2000, neither GCC nor VC++ had particularly good optimizers or code generators.
Back in 2000, it was reasonable to use assembly for performance-critical code like that. It just they never questioned that decision later, despite they should have done that many years ago.
- astrange 2y agoFFmpeg developers aren't stupid and aren't doing things because of historical accident. If you don't mind writing platform specific code, it simply works better this way. Here's clang messing up x86 intrinsics code. https://x.com/ffmpeg/status/1852913590258618852 https://x.com/ffmpeg/status/1852913590258618852 The other reason to do it is that, since x86 intrinsics are named in Hungarian notation, they're so hard to read that the asm is actually more maintainable.
- Const-me 2y ago> it simply works better this way That is simply not true. > clang messing up x86 intrinsics code The code is correct, and on some processors runs slightly faster than the original. Clang is the only compiler which does anything like that. And the example is irrelevant to ffmpeg because it operates on FP64 numbers, video codecs mostly do integer math. > they're so hard to read that the asm is actually more maintainable That’s subjective, I’m using SIMD intrinsics for years and I find them way better than assembly. Another thing, you can treat C as a high-level language as opposed to portable assembler. If you define structures, functions and classes in C++ which use these SIMD vectors, readability of intrinsics becomes way better than assembly. Here’s a good example of a library designed that way: https://github.com/microsoft/DirectXMath https://github.com/microsoft/DirectXMath