Huge compiled size of the library

56 views
Skip to first unread message

Demetris Tziambazis

unread,
Mar 16, 2015, 5:35:14 AM3/16/15
to libfi...@googlegroups.com
Hi,

I am using libfixmath for matrix calculation. It states that the compiled size of the library is less than 5 kB. When I build my project on ARM Keil is like 16KB. Thats huge.

The output of Keil IDE is:

Program Size: Code=15100 RO-data=3696 RW-data=6016 ZI-data=4672  

As I saw some lines of code here and there that use libfixmath they all include the library like: #include <fixmath.h>
How can I do that?

When I try to include the library like that it doesnt compile. Currently I am including the lib like that, and also the declarations of my mf16 structs.
(maybe that has something to do with the size of the code thats too big)

#include <stdio.h>
#include <stdlib.h>

#include "libfixmatrix-master\fixmatrix.h"                     

int main ()
{
int i, j, c, d, k;
fix16_t sum;
fix16_t minAbsCos;
fix16_t mixedmean[DIM];
fix16_t mixedsigTrans[NUMOFSAMPLES][DIM];
fix16_t eigenvalues[DIM];
fix16_t whitesig[DIM][NUMOFSAMPLES];
fix16_t whitesigTrans[NUMOFSAMPLES][DIM];
mf16 covarianceMatrix =  {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_covarianceMatrix;
ptr_covarianceMatrix = &covarianceMatrix;
mf16 identity = {DIM, DIM, 0, {{fix16_from_int(1),0,0},
  {0,fix16_from_int(1),0},
  {0,0,fix16_from_int(1)}}};
mf16 *ptr_identity;
ptr_identity = &identity;

mf16 sqrtD = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_sqrtD;
ptr_sqrtD = &sqrtD;

mf16 inv_eigenvectors = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_inv_eigenvectors;
ptr_inv_eigenvectors = &inv_eigenvectors;

mf16 eigenvectors = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_eigenvectors;
ptr_eigenvectors = &eigenvectors;

mf16 whiteningMatrix = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_whiteningMatrix;
ptr_whiteningMatrix = &whiteningMatrix;

mf16 Bold = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_Bold;
ptr_Bold = &Bold;

mf16 tempMatrixOne = {DIM, DIM, 0, {{fix16_from_int(1),0,0},
  {0,fix16_from_int(1),0},
  {0,0,fix16_from_int(1)}}};
mf16 *ptr_tempMatrixOne;
ptr_tempMatrixOne = &tempMatrixOne;

mf16 tempMatrixTwo = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_tempMatrixTwo;
ptr_tempMatrixTwo = &tempMatrixTwo;
mf16 Btranspose = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_Btranspose;
ptr_Btranspose = &Btranspose;
mf16 Bnew = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_Bnew;
ptr_Bnew = &Bnew;

mf16 inv_Bnew = {DIM, DIM, 0, {{0,0,0},
  {0,0,0},
  {0,0,0}}};
mf16 *ptr_inv_Bnew;
ptr_inv_Bnew = &inv_Bnew;

mf16 B = {DIM, DIM, 0,{{fix16_from_int(rand()%16384),fix16_from_int(rand()%16384),fix16_from_int(rand()%16384)},
  {fix16_from_int(rand()%16384),fix16_from_int(rand()%16384),fix16_from_int(rand()%16384)},
  {fix16_from_int(rand()%16384),fix16_from_int(rand()%16384),fix16_from_int(rand()%16384)}}};

mf16 *ptr_B;
ptr_B = &B;

mf16 q;
mf16 *ptr_q;
ptr_q = &q;

mf16 r;
mf16 *ptr_r;
ptr_r = &r;

















Also some other guys proposed a documentation/tutorial for the newbies like me. That would be amazing. I wish I had better understanding of dependancies, libraries etc and i would write one...

Thank you

Petteri Aimonen

unread,
Mar 16, 2015, 5:51:43 AM3/16/15
to libfi...@googlegroups.com
Hi,

> Program Size: Code=15100 RO-data=3696 RW-data=6016 ZI-data=4672

Below is what I get with GCC, Cortex-M3 and -Os. Your results for
different compilers may vary.

petteri@raichu:~/libfixmatrix$ arm-none-eabi-size -t *.o
text data bss dec hex filename
242 0 0 242 f2 fixarray.o
2406 0 0 2406 966 fixmatrix.o
1058 0 0 1058 422 fixquat.o
416 0 0 416 1a0 fixstring.o
280 0 0 280 118 fixvector2d.o
352 0 0 352 160 fixvector3d.o
4754 0 0 4754 1292 (TOTALS)


> As I saw some lines of code here and there that use libfixmath they all
> include the library like: #include <fixmath.h>

Libfixmatrix is one library. Libfixmath is another one.

> *#include <stdio.h>*
> *#include <stdlib.h>*

These are from libc. It can also take quite some space, so check how
much each file takes (I don't use Keil so cannot say how to do it
there).

> Also some other guys proposed a documentation/tutorial for the newbies like
> me. That would be amazing. I wish I had better understanding of
> dependancies, libraries etc and i would write one...

Yeah, documentation could always be improved. However the questions
above are just basic embedded C development, which is not really
something that libfixmath/libfixmatrix has to document. I would
recommend a book to read but I don't know any good modern one.

--
Petteri
Reply all
Reply to author
Forward
0 new messages