1#ifndef HALIDE_RUNTIME_BLOCK_STORAGE_H
2#define HALIDE_RUNTIME_BLOCK_STORAGE_H
4#include "../HalideRuntime.h"
40 void resize(
void *user_context,
size_t entry_count,
bool realloc =
true);
46 void remove(
void *user_context,
size_t index);
48 void fill(
void *user_context,
const void *array,
size_t array_size);
49 void insert(
void *user_context,
size_t index,
const void *array,
size_t array_size);
50 void replace(
void *user_context,
size_t index,
const void *array,
size_t array_size);
51 void prepend(
void *user_context,
const void *array,
size_t array_size);
52 void append(
void *user_context,
const void *array,
size_t array_size);
53 void remove(
void *user_context,
size_t index,
size_t entry_count);
58 void clear(
void *user_context);
59 void destroy(
void *user_context);
74 const void *
data()
const;
75 const void *
front()
const;
76 const void *
back()
const;
85 void allocate(
void *user_context,
size_t capacity);
95 : config(
cfg), allocator(
sma) {
118 if (ptr !=
nullptr) {
121 capacity = count = 0;
128 capacity = count = 0;
136 if (&
other !=
this) {
137 config =
other.config;
139 if (count != 0 &&
other.ptr !=
nullptr) {
150 if (count !=
other.count) {
157 return !(*
this ==
other);
161 if (array_size != 0) {
162 resize(user_context, array_size);
218#ifdef DEBUG_RUNTIME_INTERNAL
219 debug(user_context) <<
"BlockStorage: Resize ("
225 <<
"realloc=" << (
realloc ?
"true" :
"false") <<
")...\n";
232 if (capacity > count) {
250 remove(user_context, index, 1);
261#ifdef DEBUG_RUNTIME_INTERNAL
262 debug(user_context) <<
"BlockStorage: Remove ("
263 <<
"index=" << (
int32_t)index <<
" "
264 <<
"entry_count=" << (
int32_t)entry_count <<
" "
269 <<
"bytes=" << (
int32_t)bytes <<
")...\n";
284 debug(user_context) <<
"BlockStorage: Replace ("
285 <<
"index=" << (
int32_t)index <<
" "
286 <<
"array_size=" << (
int32_t)array_size <<
" "
288 <<
"offset=" << (
int32_t)offset <<
" "
290 <<
"capacity=" << (
int32_t)capacity <<
")...\n";
312 replace(user_context, index, array, array_size);
316 insert(user_context, 0, array, array_size);
329 return (count >= capacity);
333 return (index < capacity);
365 size_t index = count - 1;
380 size_t index = count - 1;
384void BlockStorage::allocate(
void *user_context,
size_t new_capacity) {
392#ifdef DEBUG_RUNTIME_INTERNAL
393 debug(user_context) <<
"BlockStorage: Allocating ("
395 <<
"block_size=" << (
int32_t)block_size <<
" "
396 <<
"block_count=" << (
int32_t)block_count <<
" "
400 if (count != 0 && ptr !=
nullptr &&
new_ptr !=
nullptr) {
403 if (ptr !=
nullptr) {
412const SystemMemoryAllocatorFns &
414 return this->allocator;
const Config & current_config() const
BlockStorage & operator=(const BlockStorage &other)
void * operator[](size_t index)
logical entry index (returns ptr = data() + (index * stride())
void shrink_to_fit(void *user_context)
void pop_front(void *user_context)
void destroy(void *user_context)
void clear(void *user_context)
static constexpr size_t default_capacity
bool operator!=(const BlockStorage &other) const
void resize(void *user_context, size_t entry_count, bool realloc=true)
static const Config & default_config()
void replace(void *user_context, size_t index, const void *array, size_t array_size)
void prepend(void *user_context, const void *entry_ptr)
void remove(void *user_context, size_t index)
void assign(void *user_context, size_t index, const void *entry_ptr)
void insert(void *user_context, size_t index, const void *entry_ptr)
void initialize(void *user_context, const Config &cfg, const SystemMemoryAllocatorFns &sma=default_allocator())
static const SystemMemoryAllocatorFns & default_allocator()
const SystemMemoryAllocatorFns & current_allocator() const
bool operator==(const BlockStorage &other) const
void append(void *user_context, const void *entry_ptr)
BlockStorage(void *user_context, const Config &cfg, const SystemMemoryAllocatorFns &sma=default_allocator())
bool is_valid(size_t index) const
void fill(void *user_context, const void *array, size_t array_size)
void reserve(void *user_context, size_t capacity, bool free_existing=false)
void pop_back(void *user_context)
ALWAYS_INLINE void * native_system_malloc(void *user_context, size_t bytes)
ALWAYS_INLINE void native_system_free(void *user_context, void *ptr)
ALWAYS_INLINE const void * offset_address(const void *address, size_t byte_offset)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
void * memmove(void *dest, const void *src, size_t n)
signed __INT32_TYPE__ int32_t
void * memcpy(void *s1, const void *s2, size_t n)
int memcmp(const void *s1, const void *s2, size_t n)
unsigned __INT32_TYPE__ uint32_t
#define halide_abort_if_false(user_context, cond)
uint32_t minimum_capacity
DeallocateSystemFn deallocate
AllocateSystemFn allocate