Re: [eigen] Matrix product crashes when compiled with MSVC 2010 in release

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


2010/8/13 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Here is the failing assembly:
>
>        if(nr==4) traits.acc(C3, alphav, R3);
> 00123465  movapd      xmm6,xmm0
> 00123469  mulpd       xmm6,xmmword ptr [C3]
> 0012346E  addpd       xmm6,xmm7
> 00123472  add         dword ptr [ebp-3Ch],20h
> 00123476  add         eax,dword ptr [k]
>                  traits.acc(C4, alphav, R4);
> 00123479  movapd      xmm7,xmm0
> 0012347D  mulpd       xmm7,xmm4
> 00123481  movupd      xmm4,xmmword ptr [edi-70h]
> 00123486  addpd       xmm7,xmm4
> 0012348A  movapd      xmm2,xmm0
> 0012348E  mulpd       xmm2,xmmword ptr [C1]
> 00123496  addpd       xmm2,xmmword ptr [esi+edx]
> 0012349B  lea         edx,[esi+edx+10h]
>                  traits.acc(C5, alphav, R5);
>
> The second last command, the aligned addition creates the mentioned
> error.

Thanks for finding this!

> I could only circumventing the crash by changing the
> computation of acc(...) - just check the patch I attached.

Unfortunately, the patch creates a wrong result:

+#if defined(EIGEN_VECTORIZE) && defined(_MSC_VER) && !defined(_WIN64)
+    const AccPacket tmp1 = ei_pmul(alpha,c);
+    const AccPacket tmp2 = ei_pmul(alpha,r);
+    r = ei_padd(tmp1,tmp2);
+#else
     r = ei_pmadd(c,alpha,r);
+#endif

Here, the current code r=pmadd(c,alpha,r) does (in pseudocode):

    r = alpha*c+r.

But your variant does instead:

    r = alpha*c + alpha*r

So it's wrong, right? Moreover, even if it was right, it would have
the effect of causing matrix products to do twice more
multiplications, hence be twice slower, on MSVC. I guess we wouldn't
want to do that just to work around an obscure bug with a non-default
option.

>
> Just a short question to you Ilya - do you rely on disabling the whole
> program optimization? Per default it is enabled if you create a new
> solution. That's why we never hit that issue so far. I am saying for
> all our unit tests, the compiler settings are mostly on default for
> MSVC builds. Testing against all combinations of compiler settings is
> not really possible. ;)

Spot on!
Even if the people at everyone's favorite corporation are not very
responsive to bug reports, I would still say it's about the only thing
to do about it, unless Hauke finds an applicable work-around!

Cheers,
Benoit

>
> - Hauke
>



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