Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xkhainguyen opened this issue Feb 24, 2024 · 1 comment
Open

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

xkhainguyen opened this issue Feb 24, 2024 · 1 comment

Comments

@xkhainguyen
Copy link

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
Copy link
Owner

giaf commented Feb 27, 2024

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):

  • TARGET: GENERIC
  • LA: REFERENCE (you can also try out HIGH_PERFORMANCE but this requires more available registers to perform well, and in some routines it internally uses malloc - even though likely not the routine you would employ in HPIPM).
  • MF: COLMAJ if you went for REFERENCE LA, PANELMAJ if you went for HIGH_PERFORMANCE LA
  • BLAS_API to LAPACKE_API: 0
  • EXTERNAL_BLAS_API: 0
  • OS: this affects the assembly language conventions (that is not used for the GENERIC TARGET that is pure C), and the choice of the compilation flags (that you may have to customize yourself)
  • USE_C99_MATH: here you can give a try, if 1 gives you problems you can try to turn this off at the cost of a little performance deficit in some special cases.
  • EXT_DEP: setting to 0 you avoid the compilation of functions with external dependencies for printing and memory allocation.
  • afterwards you will need to customize C compiler, CFLAGS and the like.

For HPIPM:

  • TARGET: GENERIC
  • USE_C99_MATH: same story as BLASFEO's one
  • OS: only affects compilation flags and the like as there is no assembly here
  • again afterwards you will need to customize C compiler, CFLAGS and the like.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants