29 int64_t debug_allocated_amount_ = 0;
34 constexpr
static inline int64_t large_buffer_threshold = 4096;
45 for (
void *
ptr : owned_buffers_) {
46 allocator_.deallocate(
ptr);
62 const uintptr_t alignment_mask = alignment - 1;
63 const uintptr_t potential_allocation_begin = (current_begin_ + alignment_mask) &
65 const uintptr_t potential_allocation_end = potential_allocation_begin +
size;
67 if (potential_allocation_end <= current_end_) {
69 debug_allocated_amount_ +=
size;
71 current_begin_ = potential_allocation_end;
72 return reinterpret_cast<void *
>(potential_allocation_begin);
74 if (
size <= large_buffer_threshold) {
75 this->allocate_new_buffer(
size + alignment, alignment);
76 return this->
allocate(size, alignment);
78 return this->allocator_large_buffer(
size, alignment);
88 return static_cast<T *
>(this->
allocate(
sizeof(
T),
alignof(
T)));
113 T *value =
new (
buffer)
T(std::forward<Args>(args)...);
122 template<
typename T,
typename... Args>
127 new (&
array[i])
T(std::forward<Args>(args)...);
137 if (
src.is_empty()) {
152 char *
buffer =
static_cast<char *
>(this->
allocate(alloc_size, 1));
161 void *pointer_buffer = this->
allocate(element_amount *
sizeof(
void *),
alignof(
void *));
162 void *elements_buffer = this->
allocate(element_amount * element_size, element_alignment);
165 void *next_element_buffer = elements_buffer;
167 pointers[i] = next_element_buffer;
168 next_element_buffer =
POINTER_OFFSET(next_element_buffer, element_size);
174 template<
typename T,
typename... Args>
178 n,
sizeof(
T),
alignof(
T));
182 new (
static_cast<void *
>(pointers[i]))
T(std::forward<Args>(args)...);
197 template<
size_t Size,
size_t Alignment>
204 void allocate_new_buffer(
int64_t min_allocation_size,
int64_t min_alignment)
208 if (
buffer.size() >= min_allocation_size) {
219 int64_t size_in_bytes = min_allocation_size;
220 if (size_in_bytes <= large_buffer_threshold) {
222 const int grow_size = 1 << std::min<int>(owned_buffers_.
size() + 6, 20);
223 size_in_bytes =
std::min(large_buffer_threshold,
224 std::max<int64_t>(size_in_bytes, grow_size));
227 void *
buffer = allocator_.allocate(size_in_bytes, min_alignment, __func__);
230 current_end_ = current_begin_ + size_in_bytes;
235 void *
buffer = allocator_.allocate(
size, alignment, __func__);
MINLINE int is_power_of_2_i(int n)
#define POINTER_OFFSET(v, ofs)
#define BLI_NO_UNIQUE_ADDRESS
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
MutableSpan< T > construct_array_copy(Span< T > src)
MutableSpan< void * > allocate_elements_and_pointer_array(int64_t element_amount, int64_t element_size, int64_t element_alignment)
StringRefNull copy_string(StringRef str)
void provide_buffer(AlignedBuffer< Size, Alignment > &aligned_buffer)
Span< T * > construct_elements_and_pointer_array(int64_t n, Args &&...args)
void provide_buffer(void *buffer, uint size)
MutableSpan< T > allocate_array(int64_t size)
destruct_ptr< T > construct(Args &&...args)
void * allocate(const int64_t size, const int64_t alignment)
MutableSpan< T > construct_array(int64_t size, Args &&...args)
constexpr MutableSpan< NewT > cast() const
constexpr T * data() const
void remove_and_reorder(const int64_t index)
void append(const T &value)
IndexRange index_range() const
SyclQueue void void * src
ccl_global float * buffer
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr
void uninitialized_copy_n(const T *src, int64_t n, T *dst)
_W64 unsigned int uintptr_t