an allocator of objects of type T, on huge pages for the large blocks
More...
#include <ADS/memory/HugePageAllocator.h>
|
| | HugePageAllocator (void)=default |
| | the allocator, which has no state
|
| template<class U> |
| | HugePageAllocator (const HugePageAllocator< U > &) noexcept |
| | the allocator of objects of type T, from that of type U
|
| T * | allocate (std::size_t n) |
| | room for \( n \) objects, on huge pages if they fill one at least
|
| void | deallocate (T *p, std::size_t n) noexcept |
| | the room \( p \) of \( n \) objects given back: kept by the thread if it is of 8 MB or more and the cache has room, to the system otherwise
|
| template<class U> |
| bool | operator== (const HugePageAllocator< U > &) const noexcept |
| | true: the allocators are all equal
|
|
| static constexpr std::size_t | PAGE = std::size_t( 1 ) << 21 |
| | the size of a huge page, in bytes
|
template<class T>
class ADS::HugePageAllocator< T >
an allocator of objects of type T, on huge pages for the large blocks
◆ value_type
◆ HugePageAllocator() [1/2]
the allocator, which has no state
◆ HugePageAllocator() [2/2]
template<class T>
template<class U>
the allocator of objects of type T, from that of type U
◆ allocate()
room for \( n \) objects, on huge pages if they fill one at least
In pseudocode (Navarro et al., beyond the book), \( P = 2^{21} \) the bytes of a huge page:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{allocate}( n ) \cr
2 & \quad b \gets n \cdot \mathrm{sizeof}( T ) \cr
3 & \quad \textbf{if}\ b < P\ \textbf{then return}\ \text{the memory}
\text{ of std::allocator} \cr
4 & \quad r \gets P \lceil b / P \rceil \cr
5 & \quad \textbf{if}\ \text{this thread keeps a block of } r \text{ }
\text{bytes}\ \textbf{then return}\ \text{it, no longer kept} \cr
6 & \quad \textbf{return}\ \text{a block of } r \text{ bytes aligned}
\text{ to } P
\end{array}}
\]
◆ deallocate()
the room \( p \) of \( n \) objects given back: kept by the thread if it is of 8 MB or more and the cache has room, to the system otherwise
- Precondition
- \( p \) was given by allocate( n )
◆ operator==()
template<class T>
template<class U>
true: the allocators are all equal
◆ PAGE
the size of a huge page, in bytes
The documentation for this class was generated from the following file: