rp2/CMakeLists.txt: Enable float-abi=hard on RP2350 ARM boards. - #19661
rp2/CMakeLists.txt: Enable float-abi=hard on RP2350 ARM boards.#19661dpgeorge wants to merge 1 commit into
Conversation
Prior to pico-sdk 2.3.0 all RP230 ARM boards were built unconditionally with `-mfloat-abi=softfp`, which uses hardware instructions for float operations but passes float arguments in integer registers. That's incompatible with MicroPython's native .mpy ABI, which expects float arguments to be passed in the float registers. In 2.3.0 pico-sdk added PICO_HARD_FLOAT_ABI which allows the build to select `-mfloat-abi=hard`, passing floats in float registers. Enable that option on all RP2350 ARM boards so they can import and use native .mpy files containing float code. Signed-off-by: Damien George <damien@micropython.org>
|
@robert-hh related to this PR, it looks like mimxrt boards ADAFRUIT_METRO_M7, MAKERDIARY_RT1011_NANO_KIT, MIMXRT1010_EVK, MIMXRT1015_EVK and OLIMEX_RT1010 use |
|
Code size report: |
|
Tested with MAKERDIARY_RT1011_NANO_KIT and MIMXRT1015_EVK. It builds fine. Ran the tests from tests/float/.py and tests/extmod/random.py. The results look clean. From tests/float the double test are skipped, and the divmod test. Result from random*.py below. |
|
Thanks! Please also run |
|
It seems that I need more instructions to run the tests. All of them are skipped with messages like |
|
To build the natmods use: ( |
s/still doesn't/can't/ :( The Hazard3 core has no floating point support whatsoever, unfortunately. |
|
Ok. Things improved. Before there have been fails for running out of memory, and one fail at |
Summary
Prior to pico-sdk 2.3.0 all RP230 ARM boards were built unconditionally with
-mfloat-abi=softfp, which uses hardware instructions for float operations but passes float arguments in integer registers. That's incompatible with MicroPython's native .mpy ABI, which expects float arguments to be passed in the float registers.In 2.3.0 pico-sdk added PICO_HARD_FLOAT_ABI which allows the build to select
-mfloat-abi=hard, passing floats in float registers. Enable that option on all RP2350 ARM boards so they can import and use native .mpy files containing float code.Testing
Built various RP2040 and RP2350 boards. RP2040 still uses
float-abi=softand RP2350-RISC-V still doesn't use that option (it's a different arch), but RP2350 now usesfloat-abi=hard.Tested on RPI_PICO2. Prior to this change running natmods would give:
But now with this PR it gives:
Performance benchmark shows:
misc_mandel.pyandmisc_raytrace.pyuse floats and they are up in performance.bm_float.pyis down... but not as much as mandel/raytrace are up. As usual performance is hard to measure on chips with caching, but the above looks pretty reasonable in terms of an overall small improvement (and at least it's not a big decrease).Will also be tested by Octoprobe, which previously failed the above
extmod/random_extra_float.pytest.Trade-offs and Alternatives
Could leave it using
softfpand then add a way for .mpy files to support working with that ABI. @projectgus had an idea how to do that (adding shim functions to convert floats between integer and float args), but IMO it's pretty complicated to do that.Generative AI
I did not use generative AI tools when creating this PR.