Skip to content

very bad performance with small dynamic pre-allocated matrices

Submitted by lau..@..il.com

Assigned to Nobody

Link to original bugzilla bug (#469)
Version: 3.0

Description

Created attachment 271

41 lines of C++ showing the problem with small dynamic matrices

The attached file show a difference of x130 in speed on my laptop between fixed and dynamic pre-allocated matrices. I don't see any reason for such discrepancy (I would expect few percents difference) since it takes care of intermediate temporaries. Dynamic matrices seems to systematically reallocate the storage instead of reuse it when storage sizes are compatible, which is a killer for small matrices. In many problems, matrices sizes are unknown (input-defined) but size of intermediate results can be computed and storages pre-allocated. This is a very important "real life" case. Maybe I have missed some Eigen trick to solve the problem...

Timings on my laptop Intel Core i5 2.3 Ghz with g++ 4.7 and -O3 -DNDEBUG -msse4:

C (naive): 10 sec

Eigen fixed size: 1.2 sec (very impressive!)

Eigen dynamic size: 163 sec (very bad!)

g++-4.7 -msse4.2 -std=c++11 -O3 -Ieigen-3.0.5/ -DNDEBUG matrix.cpp -o matrix

Attachment 271, "41 lines of C++ showing the problem with small dynamic matrices":

matrix.cpp

Blocking

#404 (closed)