16 #ifndef MALLOC_ALLOCATOR_H
17 #define MALLOC_ALLOCATOR_H
27 typedef value_type* pointer;
28 typedef const value_type* const_pointer;
29 typedef value_type& reference;
30 typedef const value_type& const_reference;
31 typedef std::size_t size_type;
32 typedef std::ptrdiff_t difference_type;
52 pointer address(reference x)
const
55 void construct(pointer p,
const value_type& x)
60 void destroy(pointer p)
65 const_pointer address(const_reference x)
const
70 pointer allocate(size_type n, const_pointer = 0)
75 #ifdef USE_PINNED_MEMORY
76 DEBUG_TEXT_LEVEL1(
"malloc_pinned_possible StarPU ******\n")
77 starpu_malloc((
void **)&p, n * sizeof(T));
80 p = std::malloc(n *
sizeof(T));
85 std::cerr<<
"*** Error Malloc **************\n";
86 throw std::bad_alloc();
88 return static_cast<pointer
>(p);
91 void deallocate(pointer p, size_type)
93 #ifdef USE_PINNED_MEMORY
101 size_type max_size()
const
103 return static_cast<size_type
>(-1) /
sizeof(value_type);
126 typedef void value_type;
127 typedef void* pointer;
128 typedef const void* const_pointer;
A custom memory allocator used with std::vector.