Summary: | infer dimensions of Dynamic-sized temporaries from the entire expression (if possible) | ||
---|---|---|---|
Product: | Eigen | Reporter: | Emily <el> |
Component: | Core - matrix products | Assignee: | Nobody <eigen.nobody> |
Status: | RESOLVED WONTFIX | ||
Severity: | Optimization | CC: | chtz, gael.guennebaud |
Priority: | Low | ||
Version: | 3.4 (development) | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Bug Depends on: | 99 | ||
Bug Blocks: | 814 |
Description
Emily
2015-04-20 15:33:50 UTC
X0.transpose() is not allocated on the heap, but m_coeff.matrix() * X1 is because it results in a Dynamic-sized vector. This will eventually be fixed with evaluator-tree optimizations, but certainly not in 3.2. If you know the size of the block (and the Ref) at compile-time, write: Ref<const Array<double, 4, 4> > m_coeff(data.block<4,4>(30,30)); If you access m_coeff always in a matrix-like manner, you can also use Ref<const Matrix4d> m_coeff(data.block<4,4>(30,30)); Furthermore, you may want to replace the last line by X0.dot(m_coeff.matrix() * X1) / 4.0; Thanks, those tips gave me another 30% on top of the 50% or so I gained from removing the temporary by hand (evaluated into a vector4d temporary). I love you guys! I renamed the bug to describe the remaining issue. Further examples, that might eventually be influenced: MatrixXd A, B; Matrix4d C; Vector4d x,y; C+A*B; // A*B must be 4x4 x+A*y; // A must be 4x4, A*y must be 4x1 Probably not important enough to block 3.3 I'm not sure this is worth the effort: increase in internal logic complexity, increase compilation time for very little gain in practice because this is something that is expected to be handled by user code. There are many more interesting optimization opportunities, e.g., mat*mat*vec just to name one. -- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1001. |