4 ms·
> This is a bit ironic because on x64 all math is SIMD math, it is just inefficient SIMD math. I don't understand this statement at the end of the article? Can
by noelwelsh 2y ago
> This is a bit ironic because on x64 all math is SIMD math, it is just inefficient SIMD math.
I don't understand this statement at the end of the article? Can anyone explain? TIA.
- mcraiha 2y agoI assume it means "SSE2 is baseline / non-optional for x86-64, so compilers can always use SSE1/SSE2 instructions when targeting x86-64." https://stackoverflow.com/a/50786881 https://stackoverflow.com/a/50786881
- au8er 2y agoThere is no independent scalar floating point unit for most modern CPUs. When scalar floating point arithmetic is needed, it is send to the SIMD unit. This pretty means that scalar and vectorised floating point operations usually have the same latency. If you do any scalar floating point operations, the CPU is just doing vectorised operations except with only 1 useful value.
- kbolino 2y agoIs it really true that there's no scalar FPU at all? What about x87? The instructions are still there even in 64-bit long mode, they use their own registers, and there are enough idiosyncrasies (80-bit extended-double precision, stack-based operations, etc.) that I would expect it to be easier to just include a dedicated scalar x87 FPU than try to shoehorn x87 compatibility into the SIMD units.
- xoranth 2y agoOn x86-64, compilers use SIMD instructions and registers to implement floating point math, they just use the single lane instructions. E.g. (https://godbolt.org/z/94b3r8dMn https://godbolt.org/z/94b3r8dMn): float my_func(float lhs, float rhs) { return 2.0f * lhs - 3.0f * rhs; } Becomes: my_func(float, float): addss xmm0, xmm0 mulss xmm1, DWORD PTR .LC0[rip] subss xmm0, xmm1 ret (addss, mulss and subss are SSE2 instructions.)