giaf / blasfeo

Basic linear algebra subroutines for embedded optimization
Other
308 stars 84 forks source link

How can I build BLASFEO and HPIPM for microcontrollers? #173

Open xkhainguyen opened 6 months ago

xkhainguyen commented 6 months ago

Hi,

I am trying to build these 2 libraries for optimization on microcontrollers such as Arduino Teensy or STM32, using ARM Cortex-M7. Is it possible? If yes, could you give me some pointers?

Thank you very much!

giaf commented 6 months ago

Hi there,

I don't have direct experience with that but in principle BLASFEO and HPIPM have been designed to be as much as possible self contained and with low requirements regarding the supported C version.

The first question would be: does the ARM Cortex M7 in these microcontrollers have a double precision floating point unit? I see that this is optional. If this is the case, I would compile BLASFEO with the following options (from Makefile.rule, CMake should be similar but it is possible that some are still missing there):

For HPIPM:

If you don't have double precision floating point unit, then its software emulation is going to be very slow, while the single precision version of HPIPM is often cases not reliable as typically computations in interior point methods get quite ill conditioned close to the solution (clearly it also depends on the conditioning of the problem to be solved, difficult problems make it even harder).

As of now I don't recall other stuff. It would be very appreciated if you can share your findings about what works and what doesn't.