Re: [eigen] Inlining (or lack thereof) on msvc 2013 |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Hello,
we are observing some inlining issues with MSVC from Visual Studio 2013 (Update 5).
On many occasions the compiler does not inline any of the Eigen function calls.
This seems to be somehow related to the size of the function that is using Eigen.
I have attached an example (eigen_inline.cpp) where the compiler does not inline
any of the Eigen operations (see eigen_inline.asm, search for ENDP ; compute):
....
call ?functor@?$CwiseUnaryOp@U?$scalar_multiple_op@N@internal@Eigen@@$$CBV?$Block@$$CBV?$Matrix@N$02$00$0A@$02$00@Eigen@@$01$00$0A@@3@@Eigen@@QEBAAEBU?$scalar_multiple_op@N@internal@2@XZ ; Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>,Eigen::Block<Eigen::Matrix<double,3,1,0,3,1> const ,2,1,0> const >::functor
.....
That of course results in a considerable performance hit.
However if we remove one single line of source code from the sample function,
or alternatively replace "inline" with "EIGEN_STRONG_INLINE" in all of Eigen,
then all calls are properly inlined (see eigen_strong_inline.asm):
....
movsdx QWORD PTR tmp2$[rsp], xmm6
movsdx xmm1, QWORD PTR [r9+24]
movsdx xmm0, QWORD PTR [r9+32]
mulsd xmm1, xmm4
mulsd xmm0, xmm3
subsd xmm0, xmm1
All code was compiled with:
cl.exe -c /O2 /FA /DNDEBUG -I..\Eigen eigen_inline.cpp
Do you have any insights into this kind of behavior? A less invasive solution that does not include
patching all of Eigen would be preferable...
Best
Simon
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |