GTSAM Alignment

Issue #231 new
Frank Dellaert created an issue

@abachrac says that it would be a huge win to get GTSAM types aligned.

Comments (5)

  1. Chris Beall

    Unfortunately there was some issue with boost pool allocator (used in Values) not playing nice with Eigen's aligned allocator, and for this reason we had to explicitly disable alignment for all Value types. Quaternion is one such example. At the time a work-around that didn't require giving up memory pools wasn't obvious, and I'm not sure if there are better options now.

  2. Frank Dellaert reporter

    Question after a long pause, as this came up again: I understand the above, but it seems GTSAM is not explicitly disabling Eigen alignment, so how come we don't have alignment problems every time someone optimizes for a Vector2 unknown?

  3. Chris Beall

    Actually, we have run into this problem before (see issues #309, #313 etc.). Pull request #291 fixes the problem by disabling alignment for Vector2/Point2 entirely. I don't really like that solution, but it's the best I could come up with without revisiting our usage of boost pool allocators altogether. There might also be better options now.

    Whether you encounter the issue seems to depend in part on the platform and the compiler, and how you are storing vectorizable elements. My observations:

    • Linux w/ gcc 5 and O3: often crashes on Vector2d and Quaterniond, especially when they're stored in containers like std::vector.
    • Mac OS/clang: haven't seen a crash, except through python wrapper
    • iOS/Android. I've never seen crashes here, and my guess is this is due to architectural/compiler differences.
  4. Frank Dellaert reporter

    Hmmmmm.... Indeed, not a solution I love. What is the disadvantage of disallowing boost allocators? will then all alignment magically work or do we have to add aligned allocators all over the place? Curse Eigen for this !!!!!

  5. Chris Beall

    Ditching boost allocators would mean a performance hit. I don't remember how much this buys us. And no, alignment wouldn't just magically work. We'd still have to add the alignment macro and provide eigen's allocator where appropriate.

  6. Log in to comment