This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Memory_alloc of Bool 2d Array

Hi everyone,

I’m trying to allocate a 2D array (62 x 62) using Memory_alloc. I can do for a double array as below:

//create L

L = (double**)Memory_alloc(DDR_HEAP, band*sizeof(double), 4, NULL);

if(L == NULL)

{

System_printf("Out of memory during L allocation\n");

       returnn = 0;

       return returnn;

}

else

{

       for (i = 0; i < band; i++)

       {

              L[i] = (double*)Memory_alloc(DDR_HEAP, band*sizeof(double), 4, NULL);

              if(L[i] == NULL)

              {

                     System_printf("Out of memory during L allocation\n");

                     returnn = 0;

                     return returnn;

              }

       }

}

 

For verification, I use the following code to assign a value to the array:

 

double pointt=0;

 

for (i = 0; i < band; i++)

{

       for (j = 0; j < band; j++)

       {

              L[i][j] = pointt;

              pointt++;

 

       }

}

 

However, when I want to do the same for a Bool array (same size, 62 x 62):

//create P

P = (Bool**)Memory_alloc(DDR_HEAP, band*sizeof(Bool), 4, NULL);

if(P == NULL)

{

       System_printf("Out of memory during P allocation\n");

       returnn = 0;

       return returnn;

}

else

{

       for (i = 0; i < band; i++)

       {

              P[i] = (Bool*)Memory_alloc(DDR_HEAP, band*sizeof(Bool), 4, NULL);

              if(P[i] == NULL)

              {

                     System_printf("Out of memory during P allocation\n");

                     returnn = 0;

                     return returnn;

              }

       }

}

 

And use code snippet below for verification,

 

Bool pointt=1;

 

for (i = 0; i < band; i++)

{

       for (j = 0; j < band; j++)

       {

              P[i][j] = pointt;

       }

}

 

I received error message “memory prevented reading of target memory at ……….” When debugging P[61][61] location and some other location. No problem with the early location such as P[0][0], P[2][2] etc.

I don’t think this is due to insufficient heap memory because when I change the type of P to double, there is no such problem.

I also have tried other align parameter in the Memory_alloc but the problem is still there.

Can anyone point me the reason?  For the information, I’m using TMDSEVMC6678L, CGT 7.4.1. The project is using OpenMP but I don’t think this is related to OpenMP or MCSDK since this portion of code is outside the OpenMP pragma.

Kind regards,

Rizuan