Pyboard D double precision

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
User avatar
rcolistete
Posts: 312
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Pyboard D double precision

Post by rcolistete » Fri May 24, 2019 2:44 pm

Pyboard D SF6W has double precision in hardware. Is MicroPython pre-installed already supporting double precision as default ?

In MicroPython download page (http://micropython.org/download) I don't see any separate firmware for single and double precision for Pyboard D, only for Pyboard v1.x.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
jimmo
Posts: 1848
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Pyboard D double precision

Post by jimmo » Fri May 24, 2019 3:27 pm

Yes, it would appear so. I don't have an SF6 to confirm, but the config for the boards is below:

Code: Select all

$ grep MICROPY_FLOAT_IMPL boards/PYBD*/mpconfigboard.mk
boards/PYBD_SF2/mpconfigboard.mk:MICROPY_FLOAT_IMPL = single
boards/PYBD_SF3/mpconfigboard.mk:MICROPY_FLOAT_IMPL = single
boards/PYBD_SF6/mpconfigboard.mk:MICROPY_FLOAT_IMPL = double

User avatar
rcolistete
Posts: 312
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Pyboard D double precision

Post by rcolistete » Mon Oct 28, 2019 12:38 am

Changing "stm32/boards/PYBD_SF6/mpconfigboard.mk:MICROPY_FLOAT_IMPL = double" to have "single" value allows to compile the firmware for Pyboard D SF6W with FP32 (single precision).

But changing "stm32/boards/PYBD_SF2/mpconfigboard.mk:MICROPY_FLOAT_IMPL = single" to have "double" value gives an error while compiling the firmware for Pyboard D SF2W with FP64 (double precision) :

Code: Select all

CC ../../lib/libm_dbl/thumb_vfp_sqrt.c
/tmp/ccrXMM8q.s: Assembler messages:
/tmp/ccrXMM8q.s:30: Error: selected FPU does not support instruction -- `vsqrt.f64 d0,d0'
make: *** [../../py/mkrules.mk:47: build-PYBD_SF2/lib/libm_dbl/thumb_vfp_sqrt.o] Error 1
The same happens for Pyboard D SF3W.

Is this a bug or I'm not doing the right thing to compile firmware with FP64 for Pyboard D SF2W/SF3W ?
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
jimmo
Posts: 1848
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Pyboard D double precision

Post by jimmo » Mon Oct 28, 2019 12:50 am

Yeah I think this is a bug (likely my fault in PR #5197... need a better way to detect double-fp support).

In the meantime can you try modifying stm32/Makefile to

Code: Select all

SRC_LIBM += lib/libm_dbl/sqrt.c
instead of the if statement that's currently there.

User avatar
jimmo
Posts: 1848
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Pyboard D double precision

Post by jimmo » Mon Oct 28, 2019 2:58 am


User avatar
rcolistete
Posts: 312
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Pyboard D double precision

Post by rcolistete » Mon Oct 28, 2019 3:54 pm

Thanks for your (jimmo and dpgeorge) prompt response : the fix is already merged into micropython:master.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
rcolistete
Posts: 312
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Pyboard D double precision

Post by rcolistete » Tue Oct 29, 2019 5:51 pm

Complementing the "Benchmark comparison of MicroPython boards" topic with SP/DP (Single/Double Precision) calculations :

- hsquare.py (type Ia supernova calculation with float point for 50,000 points), mean time for each calculation in us :
* Pyboard D SF2W with MicroPython SP v1.11-499-gece4e21a5 (2019-10-28) : 82.6 (120 MHz) / 50.2 (216 MHz);
* Pyboard D SF2W with MicroPython DP v1.11-499-gece4e21a5 (2019-10-28) : 177.0 (120 MHz) / 110.3 (216 MHz);
* Pyboard D SF6W with MicroPython SP v1.11-499-gece4e21a5 (2019-10-28) : 60.4 (144 MHz) / 41.2 (216 MHz);
* Pyboard D SF6W with MicroPython DP v1.11-499-gece4e21a5 (2019-10-28) : 63.4 (144 MHz) / 42.8 (216 MHz).

Conclusions, @ 216 MHz (common speed) :
- Pyboard D SF6W is 22% faster than SF2W on SP;
- Pyboard D SF6W is 158% faster than SF2W on DP;
- Pyboard D SF2W is 120% faster on SP than on DP, because its STM32F722IEK MCU doesn't have double precision in hardware;
- Pyboard D SF6W is 4% faster on SP than on DP, because its STM32F767IIK MCU has double precision in hardware.

I've compiled firmwares for Pyboard v1.1/Lite v1.0/D SF2/3/6 with and without double precision and/or threads, which are available in my Pyboard MicroPython firmware repository.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
rcolistete
Posts: 312
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Pyboard D double precision

Post by rcolistete » Wed Jul 15, 2020 9:57 pm

See the topic 'Pyboard D firmwares with single/double precision, threads and ulab module' for MicroPython v1.12 firmwares for Pyboard D boards with single/double precision and 'ulab' module.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

Post Reply