1 #ifndef ARENA_RESOURCE_HH_
2 #define ARENA_RESOURCE_HH_
4 #include <memory_resource>
13 #include <Eigen/Dense>
20 template <
class Upstream>
31 void* p =
upstream_.allocate(bytes, alignment);
33 throw std::bad_alloc();
39 upstream_.deallocate(p, bytes, alignment);
42 bool do_is_equal(
const std::pmr::memory_resource& other)
const noexcept
override {
43 return this == &other;
55 template <
class Resource>
80 size_t bytes =
sizeof(T) * n_items;
88 size_t bytes =
sizeof(T) * n_items;
111 bool do_is_equal(
const std::pmr::memory_resource& other)
const noexcept
override {
112 return this == &other;
void * do_allocate(size_t bytes, size_t alignment) override
AlignedMemoryResource(std::pmr::monotonic_buffer_resource &upstream, size_t alignment)
bool do_is_equal(const std::pmr::memory_resource &other) const noexcept override
void do_deallocate(void *p, size_t bytes, size_t alignment) override
std::unique_ptr< char[]> buffer
T * allocate_8(size_t n_items)
Allocate and return data pointer of n_item array of type T (alignment to length 8 bytes)
ArenaResource(size_t buffer_size, size_t simd_alignment)
void * do_allocate(size_t bytes, size_t alignment) override
Override do_allocate to handle allocation logic.
T * allocate_simd(size_t n_items)
Allocate and return data pointer of n_item array of type T (alignment to length given by simd_alignme...
void do_deallocate(void *p, size_t bytes, size_t alignment) override
Override do_deallocate (no-op for monotonic buffer)
bool do_is_equal(const std::pmr::memory_resource &other) const noexcept override
Override do_is_equal for memory resource comparison.
Resource & resource()
Getter for resource.