Everything
4.2.6.10 Core number specification (for a multi-core device)

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.

 

(a)

Specify a pragma directive as follows before the first definition or declaration of variable x in the file:

#pragma pmodule pm1

 

This makes the compiler and assembler allocate variable x to section .data.pm1.

 

(b)

Specify the following link option:

-start=.data.pm1/fe8f0000

 

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.
This information can be viewed through CS+.

-

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.

(1)

Format for specifying core number

Specify a core number for a multi-core device in the following format.

#pragma pmodule pm-specification

 

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.

-Xmulti_level Value

pm Specification Value

Meaning

Name of Allocation Section

1

None

Default (cmn) is specified.

***.cmn

cmn

-

For data

Allocated to the global shared memory used in common for all cores.

-

For a function

The function can be executed in any core

***.cmn

pmN

Data or function for core N

***.pmN

0

A warning message is output and the core number specification is ignored.

***

(No string is added at the end of the section name.)

 

-

If a pm specification other than the specifications below is made, a compilation error will occur.

-

cmn, pm1 to pm255 [V1.07.00 or earlier]

-

cmn, pm0 to pm255 [V2.00.00 or later]

-

#pragma pmodule is applied to all static variable declarations, function declarations, and string literals that appear after the #pragma pmodule declaration line.Note

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.

Example

.data -> .data.pm1
mydata.data -> mydata.data.pm1

 

-

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.

 

Reference Destination Object

Function with pmN Specification

Function with cmn Specification

Variable with pmN Specification

Variable with cmn Specification

Reference source object

Function with pmN specification

Can be called

Can be called

Can be referenced

Can be referenced

Function with cmn specification

Cannot be called

Can be called

Can be referenced to only R0 relative variable

Can be referenced

-

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.

 

Example 1.

#pragma section r0_disp16
int     i;                      //.zbss.cmn
--------------------------------------------------------------------------------
#pragma pmodule pm2
int     i;                      //.bss.pm2
int     j = 5;                  //.data.pm2
const int       k = 10;         //.const.pm2
void func(void)                 //.text.pm2
{
        func2("abcde");         //"abcde" = .const.pm2
}
--------------------------------------------------------------------------------
#pragma pmodule pm2
#pragma section r0_disp16
int     i;                      //.zbss.pm2
--------------------------------------------------------------------------------
#pragma section r0_disp16
#pragma pmodule pm2
int     i;                      //.zbss.pm2

Example 2.

extern  int     i;
#pragma pmodule pm2
int     i;                      //.bss.pm2 (No warning)

Example 3.

#pragma pmodule pm2
extern  int     i;
int     i;                      //.bss.pm2 (No warning)

Example 4.

#pragma pmodule cmn
extern  int     i;
#pragma pmodule pm2
int     i;                      //.bss.cmn (No warning)