RP2040: floating point performance: switch to ROM libraries?
Hi - @kevinjwalters benchmarked MicroPython and CircuitPython on a Pico, and noticed CP was twice as fast doing floating point: https://forums.adafruit.com/viewtopic.php?f=60&t=170425#p850554 and following.
From looking at the makefiles, appears this is because we (CircuitPython) are using the custom float libraries that RPi commissioned. I thought there might be a license issue for you, but the src/rp2_common/pico_float/ files are all BSD. I think the libraries themselves are all in ROM.
Tagging @tannewt for interest.
rp2: Switch to locally provided math library.
This is an alternative to #13119 and fixes all known floating-point bugs with the pico-sdk. There are two things going on here:
- Use a custom pico float component so that the pico-sdk doesn't include its math functions, and then provide our own from
lib/libm. - Provide a wrapper for
__aeabi_faddto fix the infinity addition bug
Prior to this PR, the following tests failed on the rp2 port: cmath_fun float_parse math_domain math_domain_special math_fun_special
With this PR, all the above tests pass.
Thanks to @projectgus for the approach.