37#ifndef NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
38#define NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
98#ifdef NEKTAR_MEMORY_POOL_ENABLED
102#ifdef NEKTAR_USE_ALIGNED_MEM
113#ifdef NEKTAR_MEMORY_POOL_ENABLED
121 template <
typename... Args>
static DataType *
Allocate(
const Args &...args)
130 new (result) DataType(args...);
149 template <typename... Args> static DataType *Allocate(const Args &...args)
151#ifdef NEKTAR_USE_ALIGNED_MEM
154 return new (ptr) DataType(args...);
156 return new DataType(args...);
166 template <
typename... Args>
172 template <
typename DeallocatorType,
typename... Args>
174 const DeallocatorType &d,
const Args &...args)
177 return std::shared_ptr<DataType>(data, [=](DataType *ptr) {
195#ifdef NEKTAR_MEMORY_POOL_ENABLED
196 return static_cast<DataType *
>(
199#ifdef NEKTAR_USE_ALIGNED_MEM
200 return static_cast<DataType *
>(
202 NumberOfElements *
sizeof(DataType)));
204 return static_cast<DataType *
>(
205 ::operator
new(NumberOfElements *
sizeof(DataType)));
218 [[maybe_unused]]
size_t NumberOfElements)
220#ifdef NEKTAR_MEMORY_POOL_ENABLED
223#ifdef NEKTAR_USE_ALIGNED_MEM
226 ::operator
delete(array);
274 new (p) DataType(val);
284 return std::numeric_limits<size_type>::max() /
sizeof(DataType);
299template <
typename DataType>
306template <
typename DataType>
310 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.
const_pointer address(const_reference r) const
pointer allocate(size_type n)
static DataType * Allocate(const Args &...args)
Allocates a single object from the memory pool.
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