Registered Member
|
I'm working on a quite complex, fully grid adapted, numerical Poisson equation solver. The data I'm operating on sometimes needs to be access as vectors and sometimes as sub-matrices of the vectors. For this reason all numerical data is stored as VectorXd objects. However, in the innermost loop I need to do a matrix-matrix multiply of fixed size (not compile time) matrices consisting of data residing in sub-blocks of the vectors. For this purpose I use the vector.data() method, some pointer arithmetic and the Eigen::Map<MatrixXd> facility to access the relevant coefficients as matrices. The matrices are not very big, typically of the order 10x10 and 10x100. Unfortunately the contraction routine gets called in the order of 10^7-10^9 times, and I have a distinct feeling that the creation and destruction of 3 * 10^9 Map objects is hurting my performance. What I would like to do is to create the (fixed sized) Map objects outside of the loop structure, and just update the data pointers in the innermost loop. I have not figured out how to do this in any easy way. Or is there some other smart solution I'm overlooking?
Best regards, Jonas Juselius |
Registered Member
|
First of all, I doubt that you're paying any cost for the creation/destruction of Map objects, as they are normally completely optimized out by the compiler (provided you enabled optimization, and are using a good compiler).
The constructor of Map is just copying the pointer and the sizes. Very easy for a compiler to optimize out. The destructor is not doing anything at all. The first thing to do would probably to 1) either study assembly output or, second choice, 2) dump a list of symbols from your executable, to see if Map constructors/destructors survive non-inlined. If you're using GCC, you could do:
We don't have a method to change the pointer in a Map object. I don't know if that would be a good idea, because using such a method is precisely what could prevent the compiler to optimize Map object out. What you can do is using the placement new syntax (not that I really recommend going this route...). http://eigen.tuxfamily.org/dox-devel/cl ... _1Map.html
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Thank you for a fast reply!
You are of course entirely correct: The constructors/destructors have been optimized out, no sign of them I had simply run the profiler on the "-O0 -g3" development binary, and that is of course not a good idea... I guess I need to work harder on my screening and thresholding routines to get things to fly .jonas. |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]