Showing results for 
Search instead for 
Did you mean: 

STM32U5 SIMD usage (or any other trick to speedup math)

Linas L
Senior II

In my application i need to run double for loop for data inside SRAM. and I would love to speed up my program as much as possible.

uint32_t xs = 0, yx = 0, sum =0, i = 0;

for(uint32_t x = 0 ; x<600 ; x++)
    for(uint32_t y = 0 ; y<600 ; y++)

Any insight into how I can make this faster ? Optimization is already at highest setting, and I am getting 33Hz loop speed with data acquisition.
Last resort is going into inline ASM somehow, just don't understand how do I know if compiler is using some particular CPU registers, that could hold registers longer.




You can also get a sense for how optimized a loop is by looking at the generated assembly code. Use that to guide how the code is written.

You can use a pointer to DATA instead of an index. Might save a little.

const uint32_t* ptr = &DATA[0];


xs += *ptr * x;




If you feel a post has answered your question, please click "Accept as Solution".

And try also :

  • Manual Loop unrolling (see for example or use if possible CMSIS DSP)
  • Locate DATA in a SRAM and temporary var in DTCMRAM
  • Give a look to FMAC/DMA of STM32U5 if DATA is not 32bits.