DASH  0.3.0
Allocator.h
1 #ifndef DASH__ALLOCATOR_H__INCLUDED
2 #define DASH__ALLOCATOR_H__INCLUDED
3 
4 #include <dash/allocator/AllocatorTraits.h>
5 #include <dash/allocator/GlobalAllocator.h>
6 
7 #include <dash/allocator/EpochSynchronizedAllocator.h>
8 
9 #include <dash/memory/MemorySpace.h>
10 
11 #include <dash/memory/SimpleMemoryPoolResource.h>
12 
13 namespace dash {
14 
21 inline void * align(
22  std::size_t alignment,
23  std::size_t size,
24  void * & ptr,
25  std::size_t & space)
26 {
27  auto pn = reinterpret_cast< std::uintptr_t >(ptr);
28  auto aligned = (pn + alignment - 1) & - alignment;
29  auto new_space = space - ( aligned - pn );
30  if (new_space < size) return nullptr;
31  space = new_space;
32  return ptr = reinterpret_cast<void *>(aligned);
33 }
34 
35 } // namespace dash
36 
37 #endif // DASH__ALLOCATOR_H__INCLUDED
size_t size()
Return the number of units in the global team.
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
void * align(std::size_t alignment, std::size_t size, void *&ptr, std::size_t &space)
Replacement for missing std::align in gcc < 5.0.
Definition: Allocator.h:21