Re: [eigen] Bug in Mercury version ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Bug in Mercury version ?
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Tue, 23 Jun 2009 23:09:43 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=FVzB0KeoD+rDgDKmQB91WAWagAP7TQf6yQD3WkpqNgo=; b=yFFmqpofOpNfN8SMtCyf6WOubu6upAg6hguxosQV5UsKrTDbKPCKlxqJjbHVzihwvW X0jD36V7eDlDiK8Ac2sVL+D0YZXi4GTDIVvoUjL4BJ9yFRbPnIxHKlnhyFCQWhMJen6s Ob9on7UqbqIo3PvEWY+hgqDHgRKImWwwc8/Wo=
- 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=UxXIVT5tOzUG5lWr2oMp4EaQZGJWV34K5k74S2BRm2o6uAI0vp/IP1ir+i+iCIZF8D qSxz+1pI0l4rp0XUTCS5poFATgWUyB+Xp8glv1oAY623meajlfgD2l0lVwPH7qEYjCdG 6jhEvvc6layE03+PWj6U54DmhxlxLjYGYNO5I=
Hi,
thanks a lot for reporting this very hard to spot bug ! Actually this
is a GCC's bug. Here is the generated ASM:
movsd 272(%rsp), %xmm0
movl $3, 280(%rsp)
movl $4, 284(%rsp)
movl $1, 272(%rsp)
movhps 280(%rsp), %xmm0
movl $2, 276(%rsp)
movdqa %xmm0, 256(%rsp)
as you can see it first loads the first two integers of "data" in
%xmm0 before initializing data itself !
This is probably because GCC gets confused by the use of floating
point instructions to load integer values in ei_ploadu(int*). I used
them because they are faster). Using the cleaner _mm_loadu_si128
intrinsics in ei_ploadu(int*) fixes the issue. I'll commit the fix
very soon.
gael.
On Tue, Jun 23, 2009 at 8:04 PM, Helmut
Jarausch<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> I've tried the following test case with today's Mercury version of Eigen
> (taken from the documentation, except braces around 1,2,3,4 are missing
> in the documentation.)
>
> #include <iostream>
> #include <Eigen/Core>
> // import most common Eigen types
> USING_PART_OF_NAMESPACE_EIGEN
>
> // first column of mat2x2 contains garbage if the following line is commented out
> //#define THIS_WORKS
> int main() {
> int data[4] = {1, 2, 3, 4};
> #ifdef THIS_WORKS
> std::cout << data[0] << '|' << data[1] << '|'
> << data[2] << '|' << data[3] << std::endl;
> #endif
> Matrix2i mat2x2(data);
> std::cout << mat2x2 << std::endl;
> }
>
>
> If THIS_WORKS is undefined, I get an output where the first column
> of mat2x2 contains garbage.
>
> Am I missing something?
>
> (I'm using gcc-4.3.3 on a Gentoo Linux AMD64 machine)
> compiler options:
> -O3 -mtune=native -msse2
>
> Compiling without these options gives a running binary.
> Is this an Eigen or a g++ bug?
>
> (The same problem occurs with gcc-4.4.0)
>
>
> Thanks for any hints,
> Helmut.
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany
>
>
>