4.2.4.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.

 

-

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.

 

-

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.

-

The compiler can check the correspondence between core numbers and data or functions (If a function that should be executed only in core 1 calls a function that should be executed only in core 2, the compiler can detect it as an error).

(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 option is specified. If the -Xmulti_level 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

pm1

Data or function for core 1

***.pm1

:

:

:

pm255

Data or function for core 255

***.pm255

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 cmn or pm1 to pm255 is written, a compilation error is generated.

-

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

Note

This directive is applied to all items allocated to the section; it is also applied to the string literals allocated to the const section.

 

-

#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 the same variable or function declaration is specified multiple times within a single translation unit, if different #pragma pmodule specifications are written for them, the first specification is valid.

#pragma pmodule pm1
extern  int     i;
#pragma pmodule pm2
int     i = 5;          //pm1 is valid

 

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 pm2
extern  int     i;
#pragma pmodule pm3
int     i;                      //.bss.pm2 (No warning)