37 #ifndef NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H 38 #define NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H 41 #include <type_traits> 43 #include <boost/core/ignore_unused.hpp> 82 template<
typename DataType>
101 #ifdef NEKTAR_MEMORY_POOL_ENABLED 111 #ifdef NEKTAR_MEMORY_POOL_ENABLED 119 template<
typename... Args>
120 static DataType*
Allocate(
const Args &...args)
122 DataType* result =
static_cast<DataType*
>(
129 new (result) DataType(args...);
141 #else //NEKTAR_MEMORY_POOL_ENABLED 148 template<
typename... Args>
151 return new DataType(args...);
153 #endif //NEKTAR_MEMORY_POOL_ENABLED 160 template<
typename... Args>
166 template<
typename DeallocatorType,
typename... Args>
168 const DeallocatorType& d,
const Args &...args)
171 return std::shared_ptr<DataType>(
172 data, [=](DataType *ptr){
190 #ifdef NEKTAR_MEMORY_POOL_ENABLED 192 #else //NEKTAR_MEMORY_POOL_ENABLED 193 return static_cast<DataType*
>(::operator
new(NumberOfElements *
sizeof(DataType)));
194 #endif //NEKTAR_MEMORY_POOL_ENABLED 206 #ifdef NEKTAR_MEMORY_POOL_ENABLED 208 #else //NEKTAR_MEMORY_POOL_ENABLED 209 ::operator
delete(array);
210 #endif //NEKTAR_MEMORY_POOL_ENABLED 231 boost::ignore_unused(rhs);
235 pointer
address(reference r)
const {
return &r; }
236 const_pointer
address(const_reference r)
const {
return &r; }
238 pointer
allocate(size_type n, std::allocator<void>::const_pointer hint = 0)
240 boost::ignore_unused(hint);
251 new(
p) DataType(val);
261 return std::numeric_limits<size_type>::max()/
sizeof(DataType);
278 template<
typename DataType>
281 boost::ignore_unused(lhs,rhs);
285 template<
typename DataType>
288 return !(lhs ==
rhs);
293 #endif //NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
static std::shared_ptr< DataType > AllocateSharedPtrD(const DeallocatorType &d, const Args &...args)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static void RawDeallocate(DataType *array, size_t NumberOfElements)
Deallocates memory allocated from RawAllocate.
static DataType * RawAllocate(size_t NumberOfElements)
Allocates a chunk of raw, uninitialized memory, capable of holding NumberOfElements objects...
void Deallocate(void *p, size_t bytes)
Deallocate memory claimed by an earlier call to allocate.
bool operator==(const Array< OneD, NekDouble > &lhs, const Array< OneD, NekDouble > &rhs)
const DataType * const_pointer
void * Allocate(size_t bytes)
Allocate a block of memory of size ByteSize.
void deallocate(pointer p, size_type n)
ptrdiff_t difference_type
bool operator!=(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
pointer allocate(size_type n, std::allocator< void >::const_pointer hint=0)
void construct(pointer p, const_reference val)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
MemPool & GetMemoryPool()
const DataType & const_reference
MemoryManager(const MemoryManager< T > &rhs)
static void Deallocate(DataType *&data)
Deallocate a pointer allocated by MemoryManager::Allocate.
static DataType * Allocate(const Args &...args)
Allocates a single object from the memory pool.
const_pointer address(const_reference r) const
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
pointer address(reference r) const