3 ms·
I just converted a big fixed point algorithm to float on Cortex-M4f. It runs very close to the same speed, but significantly more readable. In the fixed code I
by phkahler 2y ago
I just converted a big fixed point algorithm to float on Cortex-M4f. It runs very close to the same speed, but significantly more readable.
In the fixed code I used straight c but wrote functions for sin, cos, and reciprocal square root.
I can't see getting just a 2x improvement over soft float, while using llvm specific features and modifying libraries just eliminates portability.
- jonathrg 2y agoCortex-M4F has an FPU, i.e., hardware floating point support (albeit single precision only). You likely would see a much greater performance drop without it.
- phkahler 2y ago>> Cortex-M4F has an FPU, i.e., hardware floating point support Maybe I wasn't clear. I know it has an FPU. I originally wrote the code in fixed point because I knew it would be fast and didn't trust the FPU performance on such a small chip. Now I converted it to float and get the same performance. I also used an "f" suffix on all constants to avoid accidental software double precision. Also used the GCC flags to force it all to single precision and use the hard float libs. On smaller chips I used to expect fixed point to be faster than a hardware FPU, but that's no longer the case. They are about equal for me.
- jonathrg 2y agoI think I misread the comment (I thought you meant that 2x improvement seemed like too much, but perhaps you meant the opposite)
- Dylan16807 2y ago> On smaller chips I used to expect fixed point to be faster than a hardware FPU, but that's no longer the case. What kind of chip do you have in mind where that would be true? Notably, M4 is the first of its line to have an FPU option at all.
- magicalhippo 2y agoThis[1] page claims the M4F has about 25M FLOPS vs 1.5M FLOPS for the M4 thanks to the FPU, in single precision mode at least. [1]: https://s-o-c.org/cortex-m4f-vs-m4-how-do-these-arm-cores-compare/ https://s-o-c.org/cortex-m4f-vs-m4-how-do-these-arm-cores-co...