This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Minimize compilation size

Tags: None
(comma "," separated)
amills
Registered Member
Posts
1
Karma
0

Minimize compilation size

Fri Sep 05, 2014 11:12 pm
I am hoping to load a program which uses Eigen onto a microcontroller with limited memory. I am only using the core, LU, and Cholsky headers, which puts the binary at about 400kb without using any compiler optimization; about 200k with -Os. I don't include any other libs. might anyone have any general advice for further reduction of static code size?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Minimize compilation size

Mon Sep 08, 2014 9:22 am
I think that enabling inlining (-O2) is also very important to help the compiler removing boilerplate code.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Minimize compilation size

Mon Sep 08, 2014 9:34 am
If your matrices are not very large, you might also compile with:

-D__CUDACC__ -D__host__=" " -D__device__=" "

(using the devel branch). This will disable the heavy matrix product code. The following example:

Code: Select all
#include <Eigen/LU>
#include <Eigen/Cholesky>

using namespace Eigen;
int main() {
  MatrixXf M;
  VectorXf b, x;
  M.setRandom(100,100);
  b.setRandom(100);
  x = PartialPivLU<MatrixXf>(M).solve(b);
  x += LLT<MatrixXf>(M).solve(b);
  return int(x(0));
}

takes 47k with the devel branch and:
Code: Select all
clang++ -Os -O2 -D__CUDACC__ -D__host__=" " -D__device__=" "

and 65k without the "CUDA" trick and Eigen 3.2.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]