Re: [eigen] Matrix product crashes when compiled with MSVC 2010 in release |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Matrix product crashes when compiled with MSVC 2010 in release
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 13 Aug 2010 10:00:26 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=IOnD7yqeQHFFvBm1pcWs3FS9KfDijm9ezrQNnfxpX7A=; b=Vy10M9zeNKd9Z4Bs8gzrqA/nAMxEWjWQteD+6AzkMSUX1a4sAvwUoWA0wmSRR3DDNO pgA98P//cOhAmHGrj3+EqIAuexMV2ujietmDn36Ar6yrzpHuFjjWZZsV8S/25NqbKesO pLNxl9FimIYcYs36BR4V7Cn0DXjCA2U3r7Yz0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=eKfPsnrlp6Ifcs765y/4AeWz3oPV5rFj+VZ3GpAAB1IXK5umDUbnripz2T2Tf640Kd U05BVvWSkx7jpFZ3MB5rMJVYfvD86ynoR7aoqp7W0TqTv/dto18JndQrbmdoYVsXjNIY TR9kobx+fFtX996D2STDCz8SFZBHPZ3C5xvhg=
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
>