1 #ifndef ARENA_RESOURCE_HH_
2 #define ARENA_RESOURCE_HH_
4 #include <memory_resource>
13 #include <Eigen/Dense>
17 template <
class Resource>
42 size_t bytes =
sizeof(T) * n_items;
49 size_t bytes =
sizeof(T) * n_items;
61 void* p =
resource_.allocate(bytes, alignment);
63 throw std::bad_alloc();
74 bool do_is_equal(
const std::pmr::memory_resource& other)
const noexcept
override {
75 return this == &other;
97 typedef Eigen::Matrix<T, Eigen::Dynamic, 1>
VecData;
155 Eigen::Map<VecData> result_map = res.
eigen_map();
163 Eigen::Map<VecData> result_map = res.
eigen_map();
170 Eigen::Map<VecData> result_map = res.
eigen_map();
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
#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.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
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(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)
const T * data_ptr() const
Smae as previous but return const pointer.
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.
ArenaVec< T > operator-(const ArenaVec< T > &other) const
T & operator()(std::size_t item)
For development only. TODO remove.
Eigen::Map< VecData > eigen_map() const
Smae as previous but with const modifier.
ArenaVec< T > operator+(const ArenaVec< T > &other) const
ArenaVec(FMT_UNUSED const ArenaVec< T > &other)
Forbidden copy constructor.
size_t data_size() const
Getter for data_size_.
T scalar_val_
Scalar value of T type.
T * data_ptr_
Pointer to data array.