The core number specification function enables selection of data allocation area (the local memory in a specified core or the global memory shared by all cores) or selection of the core for function execution (a specified core or any core) when a multi-core device is used.
This function is specified by a combination of the #pragma directive described below and link options.
For example, to allocate variable x (assumed to be allocated to a data section) to the local memory for core number 1, specify as follows.
Specify a pragma directive as follows before the first definition or declaration of variable x in the file: |
This makes the compiler and assembler allocate variable x to section .data.pm1.
This makes the linker allocate section .data.pm1 to the local memory for core number 1 (This example assumes 0xfe8f0000 as an address in the local memory for core number 1).
Specifying core numbers for variables or functions has the following merits.
When a core number is added to each section name, the user can manage the correspondence between cores and variables or functions; that is, which variable is allocated to the local memory of which core and which function is executed in which core. |
As core numbers are added to all section names including the default section names, the user does not need to change the section names for every core. |
Specify a core number for a multi-core device in the following format.
This pragma directive is valid only when the -Xmulti_level=1 option is specified. If the -Xmulti_level=1 option is not specified, a warning is output and the core number specification is ignored.
The following table shows the available pm specification forms and the names of the corresponding allocated sections.
Only pm1 to pm255 or cmn can be written as pm specification. For a variable or a function with pm specification, a period (.) and the string used for pm specification is added at the end of the allocated section name.
Allocated to the global shared memory used in common for all cores. |
|||
A warning message is output and the core number specification is ignored. |
#pragma pmodule is applied to all static variable declarations, function declarations, and string literals that appear after the #pragma pmodule declaration line.Note |
This directive is not applied to the initial value data of structure-type, union-type, or array-type auto variables. |
The #pragma pmodule directive adds the string described above to both the default section names and user-specified section names. |
When there are variables or functions with different #pragma pmodule specifications other than cmn within a single translation unit, an error will occur. |
The possible combinations for referencing variables and functions with pm specification are shown in the following table. |
Variables with cmn specification need to be located in r0 relative sections. Therefore, if used in combination with the #pragma section directive, only the following attribute strings can be specified. |
r0_disp16, r0_disp23, r0_disp32, const, zconst, zconst23, default
There are no limitations on the allocation section for functions with cmn specification.
There are no limitations on the allocation section for variables with pmN specification or functions with pmN specification.
When any of the -pic, -pirod, and -pid options is specified, defining a variable or function with cmn specification will cause an error. |
The following shows specification examples.
These examples assume that the -Xmulti_level=1 is specified.