This page goes over how to use manual smart placement. Manual smart placement goes with the assumption that the information on function criticality is already known by the developer.
In general, there are following steps involved in applying smart placement:
Here, the developer needs to decide what all functions in the application are critical.
Once critical functions are identified, now it is required to put a priority function. For Manually identified functions, it is known that they are critical functions. So, we can start with assigning highest priority.
Priority
and Priority Number
are both different. A highest Priority
function would have lowest Priority Number
.priority number
will be placed by the linker in the faster memory first.Compiler provides a feature where any function can be annotated which is essentially controlling its placement in memory.
C/C++ Source-level function attributes:
__attribute__(({local,onchip,offchip}(priority)))
Here local
, onchip
and offchip
are corresponding to TCMx, MSRAM/OCRAM, FLASH.
Example:
void __attribute__((local(1))) func0(void) { .. } // Place in TCM with priority 1 void __attribute__((local(2))) func1(void) { .. } // Place in TCM with priority 2 void __attribute__((onchip)) func2(void) { .. } // Place in MSRAM/OCRAM with implied priority 1
The attributes can be added to a function definition or a function declaration (if that function is called/referenced in the same compilation unit).
Assembly metainfo directives:
Functions can also be annotated by adding an assembly metainfo directive in an assembly file that is compiled and linked with the project using the following format:
.global <global function symbol> .sym_meta_info <global function symbol>, “of_placement”, {“local”,”onchip”,”offchip”}, <priority>
e.g.
.global strcmp .sym_meta_info strcmp, “of_placement”, “local”, 1
Here in C, strcmp is the symbol name given to function strcmp.
This would allow users to avoid having to compile 3rd party source code.
Please go through Changes in linker/Memory Configurator for Smart Placement document to do relevant changes.
This example provides a basic overview of applying smart placement and compares run time of functions with smart placement and without smart placement.
The Aim of this example is to: