Skip to content

Conversation

@lahwaacz
Copy link

The first commit fixes #1. Also added another commit with some style changes/fixes.

The purpose of the cacheline-size padding between class members is to
avoid false sharing when threads modify the atomic members, but they do
not have to be aligned exactly to the cacheline-size. The atomic members
are very small (just 4 or 8 bytes) compared to the cacheline. As far as
I can tell, their explicit alignment does not matter, they can be placed
anywhere on the cacheline - we just need to ensure they are mapped to
different cachelines.

To avoid problems with misaligned dynamic allocation, the alignment must
not be stricter than alignof(std::max_align_t), which is 16 bytes on
x86_64 Linux. The value was added to the traits structs.

Fixes d36u9#1
- use std::size_t instead of size_t and std::uint64_t instead of
  uint64_t
- avoid useless static_cast<int> with an argument of the type int
- avoid useless creation of std::vector<bool> which was used only for
  counting iterations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage in dynamic objects fails due to alignment

1 participant