robotology/bayes-filters-lib

Fixed-size vectorizable Eigen matrices in WhiteNoiseAcceleration

travek opened this issue · 13 comments

Hi!

I'm using MS VS 2015.
I compiled example from test_UKF and started running it.
On the following line of code from example file:
std::unique_ptr<AdditiveStateModel> wna = utils::make_unique<WhiteNoiseAcceleration>(T, tilde_q);
I got assert error (from Eigen DenseStorage):

EIGEN_DEVICE_FUNC
plain_array() 
{ 
  EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(15);
  check_static_allocation_size<T,Size>();
}

Could you advice how to fix example code quickly?

Hi @travek!
Are you compiling 32 or 64 bit?

I tried x86 in MS VS

Can you by chance try to compile it for x64 and let us know? Thanks!

@claudiofantacci
It works when compiling in x64. Thanks!

Is it possible to have Eigen works correctly in x86 ? Do you know what needs to be changed ?

@claudiofantacci
I tried with preprocessing options, it works with x86, too
Thanks

Hi travek, do you mind giving us details of your findings to have the code compiled under x86? This could be useful to other users as well! Anyway, I’ll add to our pipeline this issue.

I compile with this preprocessing definitions:
EIGEN_DONT_ALIGN_STATICALLY
EIGEN_DONT_VECTORIZE
EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT

A small note: if I am not wrong, compiling a library that uses Eigen classes in its public interfaces changes the ABI of the Eigen classes, that means that it may create run-time crashes if the library is used/linked in a compilation unit that uses Eigen and is not compiled with that options.

The problem is related to the fixed-size Eigen::Matrix4d matrices in WhiteNoiseAcceleration.h header file. This is, of course, an error and I will fix as soon as possible.
We are undergoing an heavy maintenence on the library and I plan to fix it within the next release.
Thanks for reporting this 👍

See this Eigen reference page.

@traversaro
Recommendation is taken from
https://eigen.tuxfamily.org/dox/group__TopicUnalignedArrayAssert.html

Exactly this document explains that defining EIGEN_DONT_ALIGN_STATICALLY: "note that this breaks ABI compatibility with the default behavior of static alignment."
This ABI incompatibility is what causes the run-time crashes in the cases I was describing.

I changed the implementation of WhiteNoiseAcceleration using the PIMPL pattern and by generalizing it a bit for 1D, 2D and 3D position + velocity state space. You can see the new implementation here. It is still WIP and consequently the implementation may change until it is merged into devel.