Eigen alignment issues
Asked Answered
A

2

9

Do the memory alignment issues with Eigen listed in the documentation still apply with C++11? It seems that C++11 can already take care of properly aligning objects on the stack and on the heap, with alignas and std::allocator which supports alignment.

Adeliaadelice answered 9/4, 2015 at 10:44 Comment(2)
Are you talking about the part of the documentation that references a gcc bug?Disapprove
Also that you can't pass Eigen object by value, need use a custom allocator for container, a spezialized std::vector, and the macro to overload operator new in classes that contain Eigen objects. Because in C++11 memory alignment seems to be supported for for stack and heap memory.Adeliaadelice
E
8

Yes, the alignment issues are still present in C++11. The alignas specifier has no effect on dynamic allocations, which can thus still cause misalignments resulting in assertions thrown by Eigen.

You will have to continue to use the facilities Eigen provides for aligned allocation, such as EIGEN_MAKE_ALIGNED_OPERATOR_NEW for allocating objects or Eigen::aligned_allocator<T> for aligning containers.

Eccles answered 15/8, 2016 at 14:15 Comment(0)
W
1

While the question is about C++11 specifically, it is worth noting that a combination of the upcoming Eigen version 3.4 with a C++17 compliant compiler will free us from the need to use EIGEN_MAKE_ALIGNED_OPERATOR_NEW and Eigen::aligned_allocator<T>. The former macro is actually even empty then. This is possible by a new form of operator new that is specifically designed to support overalignment.

Wakashan answered 8/4, 2021 at 5:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.