Open NikolausDemmel opened 6 years ago
Thx for your feedback.
From what I remember when I look in detail to this I think this is related to the memory allocation model of the c++11 object of std::unordered_map
.
So adding the aligned_allocator
should not hurt.
BTW, any help you can provide to provide the best usage of Eigen is more than welcome.
-> As you said perhaps I made mistake in some place like with the PointFeature
struct.
@NikolausDemmel Any new comment?
Sorry for the late reply.
BTW, any help you can provide to provide the best usage of Eigen is more than welcome. -> As you said perhaps I made mistake in some place like with the PointFeature struct.
Unfortunately, I'm not expert in this and still trying to find out myself all the intricacies of alignment.
IIUC, if missing alignment is an issue, it should always result in a segfault / crash. I.e. hopefully it should not result in silent failures.
Since there seem to be none of those, maybe there is no need to take action.
I could still add the aligned allocator to unordered_map
or remove it from map
in a PR, if you want.
When working with the code I was wondering about how Eigen alignment is dealt with in OpenMVG.
For example, in https://github.com/openMVG/openMVG/blob/master/src/openMVG/types.hpp in the definition of
Hash_Map
the variant usingstd::map
usesEigen::aligned_allocator
, but the variant usingstd::unordered_map
does not. Briefly checking the usages ofHash_Map
, it seems there might actually not be any instances where the alignment would actually be needed.It seems the only types where
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
is used areTrifocalTensorModel
andPointFeature
(+sub classes). The former does not appear in a hash map. The latter does, but it seems to me the alignment is actually not needed forPointFeature
, since it has a singleVec2f
member, which does not seem to be a vectorizable fixed-size Eigen type (size is 8 byte, which is no multiple of 16, see https://eigen.tuxfamily.org/dox/group__TopicFixedSizeVectorizable.html).So is the aligned_allocator needed for
std::map
? And if so, why is it not used forstd::unordered_map
?