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;
134 typedef Eigen::Matrix<T, Eigen::Dynamic, 1>
VecData;
173 Eigen::Map<VecData> result_map = res.
eigen_map();
180 Eigen::Map<VecData> result_map = res.
eigen_map();
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
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(FMT_UNUSED size_t bytes, FMT_UNUSED 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(FMT_UNUSED void *p, FMT_UNUSED size_t bytes, FMT_UNUSED 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.
ArenaVec()
Default constructor, set invalid data pointer.
Eigen::Matrix< T, Eigen::Dynamic, 1 > VecData
Type definition.
ArenaVec(size_t data_size, AssemblyArena &arena)
T * data_ptr()
Return data pointer (development method)
ArenaVec< T > operator*(T multi) const
Eigen::Map< VecData > eigen_map()
size_t data_size_
Length of data array.
AssemblyArena * arena_
Pointer to Arena.
T & operator()(std::size_t item)
ArenaVec< T > operator+(const ArenaVec< T > &other) const
size_t data_size() const
Getter for data_size_.
T * data_ptr_
Pointer to data array.