-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache-line aligned allocation for OpenMP #920
Comments
Our system is not able to do that portably (and may not until C++ supports it natively) since you can't reconstruct the original pointer returned from |
Yes, that's why I propose to keep the original pointer in a struct/class and delete using it once we are done. For now, I'm thinking of a static scope-based object that can return the aligned pointer when needed, and it would have a destructor that would use the cached original pointer to delete the entire memory block. Maybe this is best done following the allocator interface, and the allocator can be passed to |
Wait, actually, |
With C++17, we could extend #1315 to also enable aligned allocation. |
We can query the L1 cache size using the "appropriately" named |
Currently, the OpenMP
raw_alloc
just usesmalloc
. Typically we would want to have allocated memory blocks aligned to cache-line boundaries, typically 64 bytes. Two things would be needed:OmpExecutor::raw_alloc
instead is not a nice option because it's protected, andExecutor::alloc
has logging that is not thread-safe. Another option to implement the alignment logic and proper deletion is to use the C11aligned_alloc
, which is easier.Especially, the semantics we need is allocation of a group of memory blocks, the beginning of each of which is aligned to 64-byte boundaries. Typically, this can be done by aligning the beginning of the large block and making the stride a multiple of 64.
The current use case on my mind is dynamic "shared memory" for batched openmp solvers.
The text was updated successfully, but these errors were encountered: