Skip to content

ATLASRECTS-7660 : Fix the alignment for DataPool

The added tests could show the possible problem described in ATLASRECTS-7660.

In short the block is 4096 aligned and this is fine.

The Header size was ~ 32 and we were subtracting 8 for the payload.

So we were starting allocating elements at ~24 after the start of the block.

This is fine for most of the basic types but we might have issues for items that have overaligned data members. Imagine a struct holding a fixed size Eigen vector of size 2.

Here we try to solve this.

The discussion with @ssnyder is below and prb he needs to take a look.

Various steps :

  • Add a header ArenaBlockAlignDetail.h . Where we place the padding struct. The payload is still a double. We just overalign it so the struct has the appropriate alignment and size for that alignment.
  • The effect can be seen in [https://godbolt.org/z/qzs1dcjoM], [https://godbolt.org/z/vecfMfnGn] for avx512f .
  • gcc can do maximum alignment based on arch. For the rest we keep 32.
  • The other bit is adding a static assert to try and catch issues during compile time. if one tries to use the block allocator for a type that needs a "larger" alignement this should fire.
  • Also we add a test that in runtime tries to assert alignment of the ptr we get from the pool vs the std allocator (this is what was failing before if we were using an over-aligned type)
Edited by Christos Anastopoulos

Merge request reports