Registered Member
|
I have a vector of dynamic Eigen matrices and a column vector that I want to add to one of them, but with large dimensions the compiler gives me an error about too big stack allocation. I didn't even know that stack allocation was going on. I tried putting noalias() in various places but it did not help. Can I do this in Eigen?
The error message of the last line is
|
Moderator
|
If parameter_dimension is too large, use Eigen::Dynamic for the template parameter of map_vector to avoid stack allocation:
|
Registered Member
|
Why is anything being allocated? Can't the addition be done in place? The target is already dynamically allocated, so why is a (temporary?) created?
|
Moderator
|
This is the result of very tricky internal implementation details which is gone in the devel branch. Basically, in your case a non initialized object of type Matrix<scalar,dim,dim> is declared in the body of the product expression. In your case this member is not used at all, so if dim=Dynamic, this really costs nothing, but if dim is a compile time constant, then we request static allocation on the stack. Since the variable is not used, in practice the compiler removes it and again there is zero overhead, but in Eigen we guard against too large stack allocation and produce a compilation error on purpose. You can control this limit with EIGEN_STACK_ALLOCATION_LIMIT (http://eigen.tuxfamily.org/dox/TopicPre ... tives.html). This member is needed when the product expression is nested within a more complicated expression for which a temporary is needed. Again, all this trick is not needed anymore in the devel branch.
|
Moderator
|
I pushed a workaround in the 3.2 branch: https://bitbucket.org/eigen/eigen/commits/879ca94e7363/
|
Registered Member
|
That sounds great! Thank you!
- Henrik |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]