← index #6813PR #13133
Related · high · value 0.462
QUERY · ISSUE

RP2040: floating point performance: switch to ROM libraries?

openby dhalbertopened 2021-01-29updated 2025-10-03
port-rp2proposed-close

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.

CANDIDATE · PULL REQUEST

rp2: Switch to locally provided math library.

mergedby dpgeorgeopened 2023-12-05updated 2023-12-06
port-rp2

This is an alternative to #13119 and fixes all known floating-point bugs with the pico-sdk. There are two things going on here:

  1. 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.
  2. Provide a wrapper for __aeabi_fadd to 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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied