SmartFactor alignment errors on 32-bit systems

Issue #234 resolved
Chris Beall created an issue

A GTSAM user reported crashes due to alignment problems in SmartFactors on a 32-bit system. These issues might be gone now due to refactoring, but we need to make sure that wherever we store fixed size matrices in STL containers we do so using the Eigen allocator. Info here: http://eigen.tuxfamily.org/dox/group__TopicStlContainers.html

User email:


I encountered a seg fault within gtsam when optimising a graph with SmartProjectionPoseFactors. I traced the issue back to the use of Fblocks:

typedef Eigen::Matrix<double, 2, D> Matrix2D;
typedef std::pair<Key, Matrix2D> KeyMatrix2D;
std::vector<KeyMatrix2D> Fblocks;

Any Matrix2D will activate AutoAlign (for any D as its size will be a multiple of the packet size, in this case D is 6). This means it requires 16 byte alignment.

For now I've turned vectorisation off and it works fine, but maybe I am losing some performance.

I think Eigen vectors should be used or at least the Eigen allocator, i.e: std::vector<KeyMatrix2D, Eigen::aligned_allocator<KeyMatrix2D>> Fblocks;

This looks like it's a bit more wide spread than Smart Factors, I see a fair bit of use of std::vector with Eigen objects, so not sure why others haven't had this problem.

Comments (1)

  1. Log in to comment