JeffersonLab / JANA2

Multi-threaded HENP Event Reconstruction
https://jeffersonlab.github.io/JANA2/
Other
6 stars 9 forks source link

Null definition of `alignas` in Utils/JResourcePool.h prevents using boost small_vector in Acts #238

Closed wdconinc closed 12 months ago

wdconinc commented 1 year ago

The definition of alignas in https://github.com/JeffersonLab/JANA2/blob/master/src/libraries/JANA/Utils/JResourcePool.h#L43-L46 prevents the use of boost/container/small_vector.hpp as part of Acts in EICrecon. A workaround has been to load boost/container/small_vector.hpp before any JANA2 headers (e.g. indirectly in Navigator.hpp at https://github.com/eic/EICrecon/blob/main/src/global/tracking/tracking.cc#L6), but this is not tenable.

Reproducer: remove that Navigator.hpp include, and the following error appears upon compilation with clang:

In file included from /home/wdconinc/git/EICrecon/.worktree/main/src/global/tracking/tracking.cc:10:
In file included from /usr/local/include/boost/container/small_vector.hpp:27:
In file included from /usr/local/include/boost/container/vector.hpp:27:
In file included from /usr/local/include/boost/container/allocator_traits.hpp:32:
In file included from /usr/local/include/boost/container/detail/mpl.hpp:26:
/usr/local/include/boost/move/detail/type_traits.hpp:1285:4: error: static_assert failed due to requirement 'value >= 8UL' "value >= Align"
   BOOST_MOVE_STATIC_ASSERT(value >= Align);
   ^                        ~~~~~~~~~~~~~~
/usr/local/include/boost/move/detail/workaround.hpp:108:46: note: expanded from macro 'BOOST_MOVE_STATIC_ASSERT'
#     define BOOST_MOVE_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__)
                                             ^             ~~~~~~~~~~~
/usr/local/include/boost/container/small_vector.hpp:303:26: note: in instantiation of template class 'boost::move_detail::aligned_storage<960, 8>' requested here
   typedef typename dtl::aligned_storage
                         ^
/usr/local/include/boost/container/small_vector.hpp:534:14: note: in instantiation of template class 'boost::container::small_vector_storage<Acts::ObjectIntersection<Acts::Surface>, 10, 8>' requested here
   , private small_vector_storage_definer<T, N, Options>::type
             ^
/usr/local/include/Acts/Propagator/Navigator.hpp:125:33: note: in instantiation of template class 'boost::container::small_vector<Acts::ObjectIntersection<Acts::Surface>, 10>' requested here
  using NavigationSurfaceIter = NavigationSurfaces::iterator;
                                ^

Possible solution: maybe clang has by now progressed to having a suitable alignas that this can be imposed as a requirements (__cxx_align).

veprbl commented 1 year ago

This looks a bit odd to me: https://github.com/JeffersonLab/JANA2/blob/22a0323f66efec616e000264a64e76b027eff291/src/libraries/JANA/Utils/JResourcePool.h#L127-L134 It can't be that spreading every possible variable to a different cache line will always improve performance.