Re: [eigen] Inlining (or lack thereof) on msvc 2013 |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] Inlining (or lack thereof) on msvc 2013*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Tue, 22 Mar 2016 13:31:36 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=pA62KhP0aZIJXYan9GT1Ia8XVbMkD3CxhmTlPMXyhbI=; b=d+YQzoUf94GppvUmARxRUODvaaPMVUNgxOFnYaPFK6GiBC17FFSeRwDnfjMvtEuRqe AONCQWWZsRIv/uGyo0GSnbUhl0r7wTxUtLsR/sBp9k8WrX11JEmUmuAdjePMxEnOaZFP eUpvsIltMwuk3Z28WU+ZL2pJ09Pn68jFFmYm+bS4pthnXlKNICmh0kF+xlgcvVdqj2Gm Gkuxs1pl0V/qKHfEUfk4GoPOl4JrzOrrLU1SfNr58GSbrqWRleUXm1EdAWv2qpJAhRZf EKMrOyecwzXYe5zU8kejUITWBOpmlKb+B+rBx15RrnSFmoSivap127i8r6rhraCpCjSV 0aHQ==

Hi,

sorry for late reply.. Yes, MSVC is not very good at inlining. I did not known that it was affected by the user code length, though. Good to know.

I know that other major compilers (GCC,ICC,clang) allows to tweak the inlining thresholds to workaround such issues, however, MSVC does not seem to offer such a flexibility. So the only solution seems to add more EIGEN_STRONG_INLINE in Eigen's code as we currently do on a case by cas basis....

gael

On Tue, Mar 15, 2016 at 4:38 PM, Simon Rutishauser <simon.rutishauser@xxxxxxxxx> wrote:

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

**References**:**[eigen] Inlining (or lack thereof) on msvc 2013***From:*Simon Rutishauser

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Adding general (dense matrix) expressions and diagonal matrix expressions** - Next by Date:
**Re: [eigen] DenseBase::NullaryExpr - Functor requirements** - Previous by thread:
**[eigen] Inlining (or lack thereof) on msvc 2013** - Next by thread:
**[eigen] Adding general (dense matrix) expressions and diagonal matrix expressions**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |