Re: [eigen] A not so simple product |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] A not so simple product
- From: "Benoit Jacob" <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 9 Dec 2008 17:51:37 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=5ZiImjNAGN44F3dIgpwAVVjLqrxmLtFH6H/7mNjGRMk=; b=ht53RiOBzVDMcWYNxGakYRVQXIX8BFZHGY78GXcJspqI9i4JOtBrsRGVB1/dGUWIXU NBmKNqRjF7lc3SHnZLb+ukoKTuIHk8f0jnY9Wlx++qRCIJKhQVMkOUeX9RFARd0vbtdc ycOqGbN/FOFR3SkIhhttWrm0BYvNTo4WSYelo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=MUdO17EfNJ+r27Uquy8ZO5TV6Rv1JLpQjkls+5MV8GReViw9aqkG5sDyoV7Jz3BJmO 3dsXUa1+LFbYBwZ3fPDbY4ZJq3dRiLIJFQMmZ1eGXItzbaAZZP5u8uGPu3dWRWH4zXZr ksF8aa5Sp4Lj4ON/7/2FOaS8cmSlZ1KPYVF7o=
[17:42] <bschindler|deskt> test:
/home/bschindl/env/include/eigen2/Eigen/src/Core/DiagonalProduct.h:81:
Eigen::Product<LhsNested, RhsNested, 2>::Product(const Lhs&, const
Rhs&) [with Lhs =
Eigen::DiagonalMatrix<Eigen::CwiseUnaryOp<Eigen::ei_scalar_inverse_op<float>,
Eigen::Map<Eigen::Matrix<float, 10000, 1, 0, 10000, 1>, 1> > >, Rhs =
Eigen::Map<Eigen::Matrix<float, 10000, 10000, 0, 10000, 10000>, 1>,
LhsNested = Eigen::Matrix<float, 10000, 10000, 0, 10000, 10000>, Rh
[SNIP]
[17:44] <bjacob> oooooooooh, I see
[17:44] <bjacob> hehe, you found a real, bad bug in Eigen. Thank you !!
[17:44] <bschindler|deskt> well, glad to help :)
[17:44] <bjacob> See, in this product expression we have:
[17:44] <bjacob> Lhs =
Eigen::DiagonalMatrix<Eigen::CwiseUnaryOp<Eigen::ei_scalar_inverse_op<float>
[17:45] * bschindler|deskt is interested in this
[17:45] <bjacob> Lhs =
Eigen::DiagonalMatrix<Eigen::CwiseUnaryOp<Eigen::ei_scalar_inverse_op<float>
[17:45] <bjacob> oops
[17:45] <bjacob> LhsNested = Eigen::Matrix<float, 10000, 10000, 0, 10000, 10000>
[17:45] <bjacob> what does this say?
[17:45] <bjacob> that the left hand side of the product (Lhs), which
was the huge diagonal matrix, gets evaluated !
[17:46] <bjacob> so Eigen tries to allocate a 670000x670000 matrix,
which fails. Eigen doesn't catch the mem alloc failure, so the
segfault occurs on the subsequent write.
[17:46] <bschindler|deskt> uh... I thought eigen wouldn't produce that
temporary object?
[17:46] <bjacob> why did Eigen want to evaluate the Lhs here (which
was the wrong decision) ?
[17:46] <bjacob> exactly good question
[17:46] <bjacob> the answer is that:
[17:47] <bjacob> in a NORMAL matrix product, as soon as the Lhs or Rhs
is an expression involving a computation, it is an optimization to
evaluate it into a temporary, because each coefficient is used N times
[17:47] <bjacob> here things are different:
[17:47] <bjacob> this is an OPTIMIZED DIAGONAL matrix product
[17:48] <bjacob> so I need to change Eigen's logic to take this into
account, as in this case,
[17:48] <bjacob> 1) there's no point in evaluating Lhs into a temporary
[17:48] <bjacob> 2) Lhs can be so large anyway that it can't be evaluated
[17:48] <bjacob> Thank you!
[17:48] <bschindler|deskt> and what does the fix look like?
[17:49] <bjacob> For now you have to stay with your old approach,
until I fix Eigen
[17:49] <bjacob> the fix will look like changes in src/Core/Product.h
and perhaps src/Core/util/XprHelper.h (the ei_nested struct perhaps)
---