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.

LP-AM243: Interesting Behavior with Large Integer Arrays

Part Number: LP-AM243

I have been working on a data handling algorithm that requires decently large arrays (sized 64x64). I have tested for the most raw case possible to determine if maybe its running out of memory but theoretically 4096 integers should not take up anywhere near 2MB of RAM. Attached is a code snippet that I ran on my device. When inputting 48*48 into the array construction it takes 1209 microseconds just to make the array, but it does complete. When inputting 64*64, the initial debug message is slightly different and cannot complete. (ignore the words about compression it isnt doing anything but making the array here).

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(inside the main function)
uint32_t cycleCount;
uint64_t curTime;
/* Open drivers to open the UART driver for console */
Drivers_open();
Board_driversOpen();
CycleCounterP_reset();
curTime = ClockP_getTimeUsec(); /* get time as measured by timer associated with ClockP module */
cycleCount = CycleCounterP_getCount32(); /* get CPU cycle count */
DebugP_log("[HCWT V0.1] Running...\r\n");
int I[64*64];
cycleCount = CycleCounterP_getCount32() - cycleCount; /* get CPU cycle count and calculate diff, we dont expect any overflow for this short duration */
curTime = ClockP_getTimeUsec() - curTime; /* get time and calculate diff, ClockP returns 64b value so there wont be overflow here */
DebugP_log("[HCWT] Compression Execution ... DONE (Measured time = %d usecs, CPU cycles = %d ) !!!\r\n",
(uint32_t)curTime, cycleCount);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I have tested for the most raw case possible to determine if maybe its running out of memory but theoretically 4096 integers should not take up anywhere near 2MB of RAM.

    The I array, which is 16KB, is allocated on the stack and so maybe their is insufficient stack space.

    Can you try either increasing the stack size, or making I a global variable.

  • Hi Dylan,

    I agree with Chester. Your array I is defined in main(), so it will be allocated inside the stack. It also matters where do you put your stacks in. It can be in TCM, on chip SRAM. The performance will be different. In general, you should not put the large array in stack.

    Best regards,

    Ming

  • Thanks, I will keep that in mind!

    Defining it globally definitely works, and the execution time is good.