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

why eigen is so fast

Tags: None
(comma "," separated)
pidanchen
Registered Member
Posts
20
Karma
0

why eigen is so fast

Wed Nov 23, 2011 6:49 pm
I need to create a super large 2D float array of size width*height. However, the exact size (around 2million by 50) of the array is only known at runtime.

I compared simple C++ array with Eigen Matrix

1.
Code: Select all
float **A = new float*[width]
for (int iter=0; iter!=width; iter++)
A[iter] = new float[height]();


2.
Code: Select all
MatrixXf A = MatrixXf::Constant(width,height,0);


I am using MSVC2008 with Win7. Under Debug mode, the performance of allocating such a HUGE matrix is similar, around 1.5 seconds. However, under release mode, Eigen is much much faster than C++ array. 0.05s vs 1s.
Why is eigen so fast? Is it because of some special instruction used in Eigen?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: why eigen is so fast

Wed Nov 23, 2011 7:37 pm
In this particular case this is because we allocate a single chunk of memory and address the elements like this: data[i+j*nb_cols].
pidanchen
Registered Member
Posts
20
Karma
0

Re: why eigen is so fast

Wed Nov 23, 2011 8:10 pm
I see. Is this what is called "automatic vectorization"?

ggael wrote:In this particular case this is because we allocate a single chunk of memory and address the elements like this: data[i+j*nb_cols].
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: why eigen is so fast  Topic is solved

Wed Nov 23, 2011 10:06 pm
Not at all. Automatic vectorization refers to the explicit uses of SSE (or similar) SIMD instructions.


Bookmarks



Who is online

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