1 #ifndef ARENA_RESOURCE_HH_
2 #define ARENA_RESOURCE_HH_
4 #include <memory_resource>
13 #include <Eigen/Dense>
17 template <
class Resource>
23 return std::pmr::null_memory_resource();
25 return std::pmr::get_default_resource();
52 size_t bytes =
sizeof(T) * n_items;
59 size_t bytes =
sizeof(T) * n_items;
76 void* p =
resource_.allocate(bytes, alignment);
79 throw std::bad_alloc();
90 bool do_is_equal(
const std::pmr::memory_resource& other)
const noexcept
override {
91 return this == &other;
115 typedef Eigen::Matrix<T, Eigen::Dynamic, 1>
VecData;
188 Eigen::Map<ArrayData> result_map = res.
array_map();
196 Eigen::Map<ArrayData> result_map = res.
array_map();
197 result_map = this->
array_map().inverse();
204 Eigen::Map<ArrayData> result_map = res.
array_map();
227 Eigen::Map<VecData> result_map = res.
eigen_map();
237 Eigen::Map<ArrayData> result_map = res.
array_map();
245 Eigen::Map<ArrayData> result_map = res.
array_map();
255 Eigen::Map<ArrayData> result_map = res.
array_map();
263 Eigen::Map<ArrayData> result_map = res.
array_map();
273 Eigen::Map<ArrayData> result_map = res.
array_map();
311 Eigen::Map<typename ArenaVec<T>::VecData> result_map = res.
eigen_map();
320 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> MatData;
323 Eigen::Map<MatData> result_map = Eigen::Map<MatData>(res.
data_ptr(), this->data_size_, other.
data_size());
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_PERMANENT_EQ(a, b)
Definition of comparative assert macro (EQual)
#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.
Outer product - only proposal of multi operator.
ArenaOVec< T > operator+(const ArenaOVec< T > &other) const
ArenaOVec(ArenaVec< T > &vec)
ArenaOVec< T > operator*(const ArenaOVec< T > &other) const
ArenaVec< T > & vec_
Reference to ArenaVec.
std::pmr::memory_resource * upstream_
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, std::pmr::memory_resource *upstream=ArenaResource< Resource >::upstream_resource())
void * do_allocate(size_t bytes, size_t alignment) override
Override do_allocate to handle allocation logic.
static std::pmr::memory_resource * upstream_resource()
Returns different upstream resource in debug / release mode.
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.
size_t free_space() const
Eigen::Array< T, Eigen::Dynamic, 1 > ArrayData
ArenaVec()
Default constructor, set invalid data pointer.
Eigen::Matrix< T, Eigen::Dynamic, 1 > VecData
Type definition.
ArenaVec< T > operator/(const ArenaVec< T > &other) const
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)
const T & operator()(std::size_t item) const
For development only. TODO remove.
const Eigen::Map< ArrayData > array_map() const
Smae as previous but with const modifier.
ArenaVec< T > sqrt() const
ArenaVec< T > operator*(T multi) const
ArenaVec< T > operator*(const ArenaVec< T > &other) const
Eigen::Map< VecData > eigen_map()
ArenaVec< T > abs() const
Eigen::Map< ArrayData > array_map()
size_t data_size_
Length of data array.
AssemblyArena * arena_
Pointer to Arena.
const Eigen::Map< VecData > eigen_map() const
Smae as previous but with const modifier.
ArenaVec< T > operator/(T div_by) const
ArenaVec< T > inverse() const
ArenaVec(T *data_ptr, size_t data_size, AssemblyArena &arena)
Constructor. Allows create ArenaVec from ArenaOVec.
ArenaVec< T > operator-(const ArenaVec< T > &other) const
T & operator()(std::size_t item)
For development only. TODO remove.
ArenaVec< T > operator+(const ArenaVec< T > &other) const
ArenaVec(const ArenaVec< T > &other)
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.