4 ms·
We actually do use ternlog in several places in Highway :) Whenever we want to use a new immediate arg, we add new ops such as Not, Xor3, Or3, OrAnd, IfVecThenE
by janwas 3y ago
We actually do use ternlog in several places in Highway :) Whenever we want to use a new immediate arg, we add new ops such as Not, Xor3, Or3, OrAnd, IfVecThenElse that also do something reasonable on other platforms.
BTW this reminds me of a colleague grumbling that what should have been a 20-minute patch to ffmpeg took a day, because it was written in assembly.
It is also quite possible to have large slowdowns due to assembly - all it takes is to forget a v prefix (VEX encoding), whereas intrinsics take care of that.
- kierank 3y agoDo you actually implement all permutations of vpternlogd? The lightweight macro layer in ffmpeg takes care of v prefixes. In FFmpeg, x264 and dav1d there are many different examples of code that couldn't be written in intrinsics or other abstraction layer. https://twitter.com/FFmpeg/status/1705543447245988245?t=Ul9ePc-raW4R5Acu8rhRSA&s=19 https://twitter.com/FFmpeg/status/1705543447245988245?t=Ul9e...
- anonymoushn 3y agoYeah, I think non-asm users have to use inlining to avoid clobbering all the vector registers on sysv ABI. I haven't really encountered cases where avoiding inlining is super important though.
- janwas 3y agoAs mentioned, we implement what applications are using/requesting. Do we know how many permutations are used in ffmpeg? hm, I vaguely remember there was a vzeroupper problem, perhaps one fell through the cracks. Interesting, can you share more details on the magic? Looks mainly like function call overhead. If functions aren't called often, we can inline (by moving into headers or enabling LTCG/LTO). If they are called often, are visible to the compiler, have internal linkage, but shouldn't be inlined, I'd be curious to learn why, and also why the compiler is then generating the full prolog/epilog.