Re: [eigen] Problem with g++-4.4 -O2 and Eigen3 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Problem with g++-4.4 -O2 and Eigen3
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sun, 17 Jul 2011 21:44:09 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=rRE75hcNXl4cgtesY8JTbLoxa9cEpkAc93nT9wSdfGU=; b=ViYBTS2WrpCI87hd0hBI3hYLpBztXoqMfys40owCPS7Z01DZx+xkRgU5f2W93xwmak A5wQnaI9Y5XzpCuVI2j0b/4X9rNZqwQRudPUQj8RYO9cdr3/tjLt2k+OyrRFiFxidqAQ m7jTJtVy04++fjFDhh6XKulquHVIrs0VFO25o=
see this threads for more details about this bug:
http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2011/04/msg00013.html
gael
On Sun, Jul 17, 2011 at 11:46 AM, Bastien ROUCARIES
<roucaries.bastien@xxxxxxxxx> wrote:
> Do you have a test case for reporting bug ?
>
> On Wed, Jun 1, 2011 at 4:42 PM, Gael Guennebaud
> <gael.guennebaud@xxxxxxxxx> wrote:
>> I'm afraid there is nothing we can do on our side. It's clearly a
>> compiler bug. For the record, and for the others, on your initial
>> example I found that a double value was wrongly modified to -1 in
>> between function calls, something like:
>>
>> foo(1);
>>
>> void foo(double alpha)
>> {
>> // here alpha still equal 1)
>> bar(alpha);
>> }
>>
>> void bar(double alpha)
>> {
>> // here alpha == -1
>> }
>>
>> and even worse, this behavior was dependent on the order of the .o
>> files in the linking command line, i.e., the bug only appeared for
>> some orders.
>>
>> Valgrind did not reported any issue.
>>
>> All other version of gcc was fine.
>>
>> So I'd recommend you to upgrade your compiler. At least you could try
>> with the latest version of 4.4, i.e., 4.4.6 if that's not already the
>> one you are using.
>>
>> gael
>>
>> On Wed, Jun 1, 2011 at 4:29 PM, Boris Lau
>> <lau@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>> Hi,
>>> sorry, but no, adding the 1 and/or the noalias doesn't change anything.
>>>
>>> Here are some more interesting matrix multiplication results. In short, 3x3
>>> * 3x9 gives a mess, while 3x9 * 9x3 and 9x3 * 3x9 does not.
>>>
>>> Best, Boris
>>>
>>> Eigen::Matrix<double,3,9> J;
>>> J.fill(1.0);
>>>
>>> std::cout << J << std::endl;
>>> 1 1 1 1 1 1 1 1 1
>>> 1 1 1 1 1 1 1 1 1
>>> 1 1 1 1 1 1 1 1 1
>>>
>>> std::cout << Eigen::Matrix3d::Identity()*J << std::endl;
>>> -1 -1 -1 -1 -1 -1 -1 -1 -1
>>> -1 -1 -1 -1 -1 -1 -1 -1 -1
>>> -1 -1 -1 -1 -1 -1 -1 -1 -1
>>> wrong!
>>>
>>> std::cout << J.transpose()*J << std::endl;
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> 3 3 3 3 3 3 3 3 3
>>> correct!
>>>
>>> std::cout << J*J.transpose() << std::endl;
>>> 9 9 9
>>> 9 9 9
>>> 9 9 9
>>> correct!
>>>
>>> Best, Boris
>>>
>>> On 05/29/2011 05:08 PM, Gael Guennebaud wrote:
>>>>
>>>> ok, so just like before, the default value of the multiplicative
>>>> factor alpha gets transformed into a -1.... that's really crasy.
>>>>
>>>> Does that change anything if explicitly put a multiplicative factor, e..g.:
>>>>
>>>> C.noalias() = 1 * A * B;
>>>>
>>>> Regarding the matrix size, this is because for matrices smaller than 8
>>>> we use another product implementation.
>>>>
>>>>
>>>> gael
>>>>
>>>>
>>>> On Sun, May 29, 2011 at 2:45 PM, Boris Lau
>>>> <lau@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>>>
>>>>> Hi folks,
>>>>>
>>>>> after updating Eigen to the newest version in the repository, I now
>>>>> compile
>>>>> my code with Eigen including the "no inlining of the GEBP product kernel"
>>>>> change by Gael.
>>>>>
>>>>> However, still a simple matrix multiplication goes awfully wrong when
>>>>> using
>>>>> -O2 in g++-4.4:
>>>>>
>>>>> // a code snipped
>>>>> Eigen::Matrix<double,3,9> J;
>>>>> J.fill(1.0);
>>>>> Eigen::Matrix<double,3,9> Jprime = Eigen::Matrix3d::Identity() * J;
>>>>> std::cout<< "J\n"<< J<< std::endl;
>>>>> std::cout<< "Jprime\n"<< Jprime<< std::endl;
>>>>>
>>>>> // output
>>>>> J
>>>>> 1 1 1 1 1 1 1 1 1
>>>>> 1 1 1 1 1 1 1 1 1
>>>>> 1 1 1 1 1 1 1 1 1
>>>>> Jprime
>>>>> -1 -1 -1 -1 -1 -1 -1 -1 -1
>>>>> -1 -1 -1 -1 -1 -1 -1 -1 -1
>>>>> -1 -1 -1 -1 -1 -1 -1 -1 -1
>>>>>
>>>>> As for Hauke, this only occurs only when used deeper inside a project, in
>>>>> the main function it works alright. The problem also occurs for a matrix
>>>>> size of 3x8, and disappears for 3x7 and smaller. Using dynamic sizes does
>>>>> not help.
>>>>> I also could not find a working order of .o files during linking.
>>>>>
>>>>> Maybe the no onlining fix didn't go far enough?
>>>>>
>>>>> Boris
>>>>>
>>>>> --
>>>>> Boris Lau
>>>>>
>>>>> Albert-Ludwigs-University Freiburg
>>>>> Institute of Computer Science, Autonomous Intelligent Systems Group
>>>>> Georges-Koehler-Allee 079, D-79110 Freiburg, Germany
>>>>>
>>>>> Building 079, Room 1005
>>>>> Phone: +49 761 203-8012 | Mobile: +49 174 9436758
>>>>> http://www.informatik.uni-freiburg.de/~lau
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Boris Lau
>>>
>>> Albert-Ludwigs-University Freiburg
>>> Institute of Computer Science, Autonomous Intelligent Systems Group
>>> Georges-Koehler-Allee 079, D-79110 Freiburg, Germany
>>>
>>> Building 079, Room 1005
>>> Phone: +49 761 203-8012 | Mobile: +49 174 9436758
>>> http://www.informatik.uni-freiburg.de/~lau
>>>
>>>
>>>
>>
>>
>>
>
>
>