As an experiment, I tagged a fairly costly function with
__RAMFUNC(SRAM_ITC)
To my surprise, it ran about 10% slower. Could anyone share any insight on why that might be?
This is on an iMXRT1062, running from flash (XIP) if not running from ITC.
解決済! 解決策の投稿を見る。
This was indeed it.
The full situation was:
Having selected a double precision ABI, the function is now twice as fast and doesn't slow down when in ITCM. It doesn't get any faster either, but I'm sure there are more mundane reasons for that.
I find it odd that the project was created with the wrong ABI - it was created from a iMXRT1062 template.
This thread was useful regarding the FP ABI:
Hello @expertsleepers,
does the code you execute from the ITCM call functions that are located in flash or SDRAM/OCRAM? These are now more expensive because the compiler inserts a veneer function.
When calling Std-Lib functions, it is also not quite obvious where they are located.
Regards
This was indeed it.
The full situation was:
Having selected a double precision ABI, the function is now twice as fast and doesn't slow down when in ITCM. It doesn't get any faster either, but I'm sure there are more mundane reasons for that.
I find it odd that the project was created with the wrong ABI - it was created from a iMXRT1062 template.
This thread was useful regarding the FP ABI:
Hello @expertsleepers,
The FPU setting for all M7 cores of the iMXRT family should be FPv5-D16. The only exception is the iMXRT1011, here it must be FPv5-SP-D16.
For the M4 and M33 cores it is also FPv5-SP-D16.
The reason why it is not faster in the ITCM than when executing from the flash is that the function is probably so small that it fits completely into the cache.
However, if the code base increases in size, cache trashing occurs. This means that the speed at which the function is executed is no longer deterministic.
Regards
Hello @expertsleepers,
If the function to be called is a maximum of four megabytes “away” in the address range, a direct jump “BL” can be used without veneer.
Regards
It is possible that the function has some routine that expects data contained on another memory inducing some wait states to the execution.
Best regards,
Omar
But would that not also be true if the function was executing from flash?
The function accesses OC SRAM and external DRAM. Both will cause waits, I'm sure, but I can't see how that would make ITC slower than XIP.
Unfortunately the code in question is part of a very large project. I'd have to try to isolate it into a fresh project - which of course may not exhibit the same behaviour. I'll post if I manage to create a small test case.