37#ifndef NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
38#define NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
43#include <boost/core/ignore_unused.hpp>
100#ifdef NEKTAR_MEMORY_POOL_ENABLED
104#ifdef NEKTAR_USE_ALIGNED_MEM
105 boost::alignment::aligned_free(data);
114#ifdef NEKTAR_MEMORY_POOL_ENABLED
122 template <
typename... Args>
static DataType *
Allocate(
const Args &...args)
131 new (result) DataType(args...);
150 template <typename... Args> static DataType *Allocate(const Args &...args)
152#ifdef NEKTAR_USE_ALIGNED_MEM
153 void *ptr = boost::alignment::aligned_alloc(
155 return new (ptr) DataType(args...);
157 return new DataType(args...);
167 template <
typename... Args>
173 template <
typename DeallocatorType,
typename... Args>
175 const DeallocatorType &
d,
const Args &...args)
178 return std::shared_ptr<DataType>(data, [=](DataType *ptr) {
196#ifdef NEKTAR_MEMORY_POOL_ENABLED
197 return static_cast<DataType *
>(
200#ifdef NEKTAR_USE_ALIGNED_MEM
201 return static_cast<DataType *
>(boost::alignment::aligned_alloc(
203 NumberOfElements *
sizeof(DataType)));
205 return static_cast<DataType *
>(
206 ::operator
new(NumberOfElements *
sizeof(DataType)));
220#ifdef NEKTAR_MEMORY_POOL_ENABLED
223 boost::ignore_unused(NumberOfElements);
224#ifdef NEKTAR_USE_ALIGNED_MEM
225 boost::alignment::aligned_free(array);
227 ::operator
delete(array);
264 std::allocator<void>::const_pointer hint =
267 boost::ignore_unused(hint);
278 new (
p) DataType(val);
288 return std::numeric_limits<size_type>::max() /
sizeof(DataType);
303template <
typename DataType>
307 boost::ignore_unused(lhs, rhs);
311template <
typename DataType>
315 return !(lhs == rhs);
void Deallocate(void *p, size_t bytes)
Deallocate memory claimed by an earlier call to allocate.
void * Allocate(size_t bytes)
Allocate a block of memory of size ByteSize.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static DataType * RawAllocate(size_t NumberOfElements)
Allocates a chunk of raw, uninitialized memory, capable of holding NumberOfElements objects.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void deallocate(pointer p, size_type n)
pointer address(reference r) const
ptrdiff_t difference_type
const DataType * const_pointer
const DataType & const_reference
static void RawDeallocate(DataType *array, size_t NumberOfElements)
Deallocates memory allocated from RawAllocate.
MemoryManager(const MemoryManager< T > &rhs)=delete
void construct(pointer p, const_reference val)
static std::shared_ptr< DataType > AllocateSharedPtrD(const DeallocatorType &d, const Args &...args)
static void Deallocate(DataType *&data)
Deallocate a pointer allocated by MemoryManager::Allocate.
pointer allocate(size_type n, std::allocator< void >::const_pointer hint=0)
const_pointer address(const_reference r) const
static DataType * Allocate(const Args &...args)
Allocates a single object from the memory pool.
std::vector< double > d(NPUPPER *NPUPPER)
The above copyright notice and this permission notice shall be included.
bool operator==(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
MemPool & GetMemoryPool()
bool operator!=(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
typename abi< ScalarType, width >::type simd