33#include "timemory/backends/device.hpp"
34#include "timemory/backends/memory.hpp"
48template <
typename Tp, std::
size_t AlignV = 8 * sizeof(Tp)>
79 TIMEMORY_NODISCARD Tp*
address(Tp& r)
const {
return &r; }
80 TIMEMORY_NODISCARD
const Tp*
address(
const Tp& s)
const {
return &s; }
82 TIMEMORY_NODISCARD std::size_t
max_size()
const
85 return (
static_cast<std::size_t
>(0) -
static_cast<std::size_t
>(1)) /
sizeof(Tp);
97 void*
const pv =
static_cast<void*
>(p);
101 template <
typename... ArgsT>
104 ::new((
void*) p) Tp(std::forward<ArgsT>(args)...);
109 TIMEMORY_NODISCARD Tp*
allocate(
const std::size_t n)
const
117 throw std::length_error(
118 "aligned_allocator<Tp>::allocate() - Integer overflow.");
122 void*
const ptr = memory::allocate_aligned<Tp, device::cpu>(n, AlignV);
127 std::cerr <<
"Allocation of type " <<
typeid(Tp).name() <<
" of size " << n
128 <<
" and alignment " << AlignV <<
" failed. ptr = " << ptr
130 throw std::bad_alloc();
133 return static_cast<Tp*
>(ptr);
138 memory::free_aligned<Tp, device::cpu>(ptr);
142 template <
typename U>
143 TIMEMORY_NODISCARD Tp*
allocate(
const std::size_t n,
const U* )
const
aligned_allocator(const aligned_allocator &)=default
aligned_allocator(const aligned_allocator< U, AlignV > &)
aligned_allocator< U, AlignV > other
bool operator!=(const aligned_allocator &other) const
Tp * allocate(const std::size_t n, const U *) const
void destroy(Tp *const p) const
aligned_allocator(aligned_allocator &&) noexcept
void deallocate(Tp *const ptr, const std::size_t) const
bool operator==(const aligned_allocator &) const
ptrdiff_t difference_type
Tp * address(Tp &r) const
std::size_t get_alignment()
aligned_allocator & operator=(const aligned_allocator &)=delete
aligned_allocator()=default
void construct(Tp *const p, ArgsT &&... args) const
void construct(Tp *const p, const Tp &t) const
const Tp & const_reference
Tp * allocate(const std::size_t n) const
const Tp * address(const Tp &s) const
aligned_allocator & operator==(aligned_allocator &&)=delete
std::size_t max_size() const
~aligned_allocator()=default