STMCUBEIDE - H7 series force use of SMLAL (Signed Multiply with Accumulate (32 × 32 + 64), 64-bit result) instruction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 2:45 AM
Code is :
int16_t OscPhase[NumOsc];
int32_t OscInc[NumOsc];
int32_t OscVol[NumOsc];
int32_t Sine[65536];
int64_t OscTotal;
and then in main() :
OscTotal = 0;
for (i = 0; i < NumOsc; i++)
{
OscPhase[i] = OscPhase[i] + OscInc[i];
OscTotal = OscTotal + Sine[OscPhase[i]] * OscVol[i];
}
I was expecting the H7 to use the SMLAL instruction for the final multiply and accumulate but instead it performs a MUL.W which only gives a 32 bit result and then uses an ADD.W and ADC.W to add these 32 bits into the final 64 bit result.
Any suggestions on how to force it to use the correct code ?
- Labels:
-
STM32CubeIDE
-
STM32H7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 2:59 AM
Use inline assembler.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 3:03 AM
Oh come on, this is the 21st century. Even the Arduino compiler produces better code than this managed so I'm sure it's just a compiler directive or something I am missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 3:18 AM
Then use Arduino.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 3:20 AM
It doesn't support the full M7 instruction set. Only the M0/3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 3:59 AM
Does the shiny new STMCubeIDE support the M7 fully ? Including the H7 ?
Else, get a proper toolchain.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 4:03 AM
I had assumed that as it was ST's newest introduction that it would be worth a try so I decided to install it yesterday and give it a good run-through with existing code. But with debugging not working and the code being not fully optimised I am indeed on the point of reverting to my previous toolchain.
Have any STM people on here actually used it yet ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 4:39 AM
It seems to be the refurbished (downscaled ???) Atollic toolchain, now under ST control.
And remarkably, there appear to be developers present here (former Atollic staff, as it seems).
Perhaps you can catch their attention.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 4:54 AM
From their video
If it's the ~ OFFICIAL ~ STM32 IDE then I'd expect it to work and work well !!
I've tried every optimisation level and the best it can manage is
mul.w r2, r2, r3
adds r4, r4, r2
adc.w r5, r5, r2, asr #31
which of course is both inefficient and fundamentally wrong as it's thrown away active bits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-02 5:10 AM
Try casting Sine with (int64_t) in the computaion.
Up vote any posts that you find helpful, it shows what's working..
