Huge tables. full memory. Type Double vs Other. Optimization

Post Reply
Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Huge tables. full memory. Type Double vs Other. Optimization

Post by Ender » Fri Oct 31, 2008 8:07 am

Hello Lumbin
I’m trying to fit the huge tables in the static memory.

Example: 2 tables of 140 x 100 of doubles. So usually 112Ko. The target is a Dspic33FJ256MC710 (256K) and the compiler is a licensed C30 v10b.

For one table alone the compiler works fine and the report returns about 42K and 16% in the total program memory used.
How that is possible, just 42K ?
Does it changes the value in single or integer over the optimization ?

For two tables, it returns the message bellow :
_ error: size of variable 'memory_try_ConstP' is too large gmake: *** [memory_try_data.o] Error 255 _

I tried some options on the compiler line but I didn’t understand how the static datas work with the data space ?
Is it Possible to declare the data type as a integer in Mathlab table ?
Attachments
Table1_14000.mat
(104.91 KiB) Downloaded 466 times
Table2_14000.mat
(23.57 KiB) Downloaded 461 times
memory_try.mdl
(31.34 KiB) Downloaded 422 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Huge tables. full memory. Type Double vs Other. Optimization

Post by LubinKerhuel » Fri Oct 31, 2008 8:31 pm

Ender wrote:For one table alone the compiler works fine and the report returns about 42K and 16% in the total program memory used.
How that is possible, just 42K ?
Does it changes the value in single or integer over the optimization ?
programmable memory's elementary storage case is not 8 bits width. It is something like 12 or 14 or more ?
Ender wrote:Is it Possible to declare the data type as a integer in Mathlab table ?
Is is highly recommanded if you want your software to fin in the dsPIC !
convert your variable at the matlab prompt:

Code: Select all

Table_14000 = int16(Table_14000);
To store fixed point variable, you should multiply your variable by the 2^(Width of fractional part) before convertign it into a int8 or 16 or 32 datatype. Then, in Simulink, following the lookup table, use a convert block to convert the int8 into the fixed point format using 'Stored Integer' option. I advise to practise with simulation to understand how thinks works.

I also advise to use the 'Direct Lookup Table' block instead of the 'Lookup Table' since your index are integers.

Lubin

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Huge tables. full memory. Type Double vs Other. Optimization

Post by Ender » Tue Nov 04, 2008 1:11 am

LubinKerhuel wrote: To store fixed point variable, you should multiply your variable by the 2^(Width of fractional part) before convertign it into a int8 or 16 or 32 datatype. Then, in Simulink, following the lookup table, use a convert block to convert the int8 into the fixed point format using 'Stored Integer' option. I advise to practise with simulation to understand how thinks works.

I also advise to use the 'Direct Lookup Table' block instead of the 'Lookup Table' since your index are integers.
Hi .
I tried to convert the data to int8 or 16 data type, but the final size didn't change. The optimizations by Mathlab and the C30 compiler seem did this yet. But thank your advices and for the prompt command, it's useful.
I don't manage still to store more than 32K of Data, in one or many tables and to reuse them it the model. Could you help me please ?

Obviously the code use the PSV methodology to map 32KB of data space addresses into a page of Program Memory. And there are a limitation on the PSV method of 32K. So I understand why for one Table less than 32K the model work fine and for more than 32K it doesn't work.
But with two Tables less than 32K, I hoped that the data was mapped by the PSV process again when then code switched between the tables. But the compiler say always that the variable is too large.
Attachments
2tab10000_int.mat
(28.35 KiB) Downloaded 448 times
memory_try_direct.mdl
(29.52 KiB) Downloaded 525 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Huge tables. full memory. Type Double vs Other. Optimization

Post by LubinKerhuel » Thu Nov 06, 2008 12:07 am

Hi Ender,

A first look on the generated code shows that all constant from the two lookup table are stored into one varaible.
Thus, you may try to copy-past the two part of the generated code that correspond to the two array to create your own C function that will
- declare theses two table
- the two function to read the two array
This solution should be tested.

if modifying compilation parameters can solve the probleme, let me know.

Lubin

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests