I am still rather new on here and I hope question is suitable for this forum otherwise please help me migrate it to greener pastures.
I am an electrical engineer specializing in applying mathematics for building cool algorithms. Sometimes in my work I try to write code that helps compiler generate code that would run as fast as hardware would allow it to. The other day, I realized that when I changed type from 32 bit float to 64 bit doubles and compiled my code.. it ran much faster.
Is it true that modern CPU architectures SIMD instructions and other quirks in CPUs are more optimized for double than for single precision floating point arithmetics?
To me it seems to be true, at least my local machine. I was surprised by it as I figured you would be able to fit twice the amount of floats on same logics. Maybe it is because of demand in industry, that people in general use double precision so much more than float, which makes them focus on good support for double precision arithmetics?
Or if I am wrong and it is not the prioritization of the CPU design maybe it is the prioritization of the compiler?
Here is some minimal godbolt example with matrix-vector multiplication of Nx8 matrices https://godbolt.org/z/gPR9wj
It is interesting for me to see for example how clang 9.1.0 and gcc 8.1 produce very different output w.r.t. code size.
I am not able to conclude very much regarding float vs double though. (We can change scal typedef to float or double as we desire.)