I am having problem allocating large memory in C6x compiler. Below is the main code to illustrate the problem
#define PANELSIZE (128)
#define NUMBERPANEL (64)
#define MATRIXSIZE (PANELSIZE*NUMBERPANEL)
#pragma DATA_SECTION(matrix, ".data")
#pragma DATA_ALIGN(matrix, 128)
double matrix[MATRIXSIZE*MATRIXSIZE];
#pragma DATA_SECTION(vector, ".data")
#pragma DATA_ALIGN(vector, 128)
double vector[MATRIXSIZE];
void main(void) {
int i;
for(i=0;i<MATRIXSIZE*MATRIXSIZE;i++) matrix[i] = (double) i;
for(i=0;i<MATRIXSIZE;i++) vector[i] = (double) i;
}
The linker file is below
-heap 0x1000
-stack 0x1000
MEMORY
{
L2SRAM (RWX) : org = 0x00800000, len = 0x00080000
MSMCSRAM (RWX) : org = 0x0c000000, len = 0x00400000
DDR3 (RWX) : org = 0x80000000, len = 0x40000000
}
SECTIONS
{
.stack > L2SRAM
.sysmem: > L2SRAM
.data: > DDR3
GROUP: > L2SRAM
{
.bss:
.neardata:
.rodata:
}
.cinit: > L2SRAM
.const: > L2SRAM
.data: > L2SRAM
.fardata: > L2SRAM
.switch: > L2SRAM
.far: > L2SRAM
.cio: > L2SRAM
}
When I compile the above (compiler version 7.4.1) , I see the memory allocation for matrix and vector as follows in the map file
80000000 matrix
80000000 vector
Thus matrix and vector overlap; zero bytes are allocated for matirx
If I change the NUMBERPANEL to 63, The map file shows the following allocation of matrix and vector showing correctly allocated bytes for matrix
80000000 matrix
9f020000 vector
It appears the compiler is wrapping around 2^29 for large allocation size.
Murtaza