Stack Overflow Asked by Catree on December 7, 2020
Recently, I was made aware of the potential issues of memory alignment for Fixed-size vectorizable Eigen objects.
The correct code as stated in the doc:
class Foo
{
...
Eigen::Vector2d v;
...
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
...
Foo *foo = new Foo;
I would like to know if this code is ok or not?
class Foo2
{
...
Foo foo;
...
};
...
Foo2 *foo = new Foo2; //?
Or should EIGEN_MAKE_ALIGNED_OPERATOR_NEW
be again added in the Foo2
class?
This is what is suggested here I think:
If we were to add EIGEN_MAKE_ALIGNED_OPERATOR_NEW this would only solve the problem for the Cartographer library itself. Users of the library would also have to add EIGEN_MAKE_ALIGNED_OPERATOR_NEW to classes containing vectorized Cartographer classes. This sounds like a maintenance nightmare.
I have no experience with new operator overloading. I think the question is more general and would somehow be related to how new operator works in C++. For instance is the overloaded new operator in Foo
be called by the default new operator in Foo2
? What about inheritance? If Foo2
inherits from Foo
, should we put also EIGEN_MAKE_ALIGNED_OPERATOR_NEW
in Foo2
?
Since I was only aware of this topic recently, I did many research and found the following:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
(if only SSE is enabled)-march=native
to have all the optimizations on a local computer), EIGEN_MAKE_ALIGNED_OPERATOR_NEW
is now neededEIGEN_MAKE_ALIGNED_OPERATOR_NEW
and NEON is enabled?template <typename Scalar> using Isometry3 = Eigen::Transform<Scalar, 3, Eigen::Isometry | Eigen::DontAlign>
instead of Isometry
Isometry3d
) in the code without the alignment issue. So add a new type MyIsometry3d
that inherits from Eigen::Transform<double, 3, Eigen::Isometry | Eigen::DontAlign>
for instance?More generally, I would like to "disable alignment" (or vectorization) in fixed-size Eigen type:
Isometry3d
in the codeIsometry3d
in a class or when using std::vector<Isometry3d>
_loadu_
/_storeu_
for x86-64 intrinsics, what about the other architecture, is there an equivalent?) for all fixed-size Eigen type?#define EIGEN_UNALIGNED_VECTORIZE 0
, is it correct? So I have to put this #define
everywhere before any Eigen/Dense
include?Matrix<double,2,2,DontAlign>
or a new classFinally, looking at Fixed-size vectorizable Eigen objects page, I think some types are missing. For the types I am using:
Eigen::Isometry3d
, Eigen::Isometry3f
?Eigen::AngleAxisd
, Eigen::AngleAxisf
?Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP