|
HAMR
The Heterogeneous Accelerator Memory Resource
|
1 #ifndef hamr_new_allocator_h
2 #define hamr_new_allocator_h
29 void operator()(T *ptr);
40 #if defined(HAMR_VERBOSE)
43 std::cerr <<
"created new_deleter for array of " << n
44 <<
" objects of type " <<
typeid(T).name() << std::endl;
55 #if defined(HAMR_VERBOSE)
58 std::cerr <<
"new_deleter deleting array of " << m_elem
59 <<
" objects of type " <<
typeid(T).name() << std::endl;
78 static std::shared_ptr<T> allocate(
size_t n);
85 static std::shared_ptr<T> allocate(
size_t n,
const T &val);
93 static std::shared_ptr<T> allocate(
size_t n,
const U *vals);
100 #if defined(HAMR_VERBOSE)
103 std::cerr <<
"new_allocator allocating array of " << n
104 <<
" objects of type " <<
typeid(T).name() << std::endl;
116 template <
typename T>
119 #if defined(HAMR_VERBOSE)
122 std::cerr <<
"new_allocator allocating array of " << n
123 <<
" objects of type " <<
typeid(T).name() <<
" initialized"
129 T *ptr = (T*)
new unsigned char[n*
sizeof(T)];
132 for (
size_t i = 0; i < n; ++i)
133 new (&ptr[i]) T(val);
140 template <
typename T>
141 template <
typename U>
144 #if defined(HAMR_VERBOSE)
147 std::cerr <<
"new_allocator allocating array of " << n
148 <<
" objects of type " <<
typeid(T).name() <<
" initialized"
154 T *ptr = (T*)
new unsigned char[n*
sizeof(T)];
157 for (
size_t i = 0; i < n; ++i)
158 new (&ptr[i]) T(vals[i]);
a deleter for arrays allocated with new
Definition: hamr_new_allocator.h:16
constexpr HAMR_EXPORT int get_verbose()
returns the value of the HAMR_VERBOSE environment variable
Definition: hamr_env.h:14
new_deleter(T *ptr, size_t n)
Definition: hamr_new_allocator.h:38
static std::shared_ptr< T > allocate(size_t n)
Definition: hamr_new_allocator.h:98
void operator()(T *ptr)
Definition: hamr_new_allocator.h:51
heterogeneous accelerator memory resource
Definition: hamr_buffer.h:40
a class for allocating arrays with new
Definition: hamr_new_allocator.h:72