1#ifndef HALIDE_RUNTIME_LINKED_LIST_H
2#define HALIDE_RUNTIME_LINKED_LIST_H
58 void clear(
void *user_context);
59 void destroy(
void *user_context);
69 void reclaim(
void *user_context,
EntryType *entry_ptr);
75 size_t entry_count = 0;
110 link_arena =
nullptr;
111 data_arena =
nullptr;
135 EntryType *entry_ptr = reserve(user_context);
137 front_ptr = entry_ptr;
138 back_ptr = entry_ptr;
143 front_ptr = entry_ptr;
151 EntryType *entry_ptr = reserve(user_context);
153 front_ptr = entry_ptr;
154 back_ptr = entry_ptr;
159 back_ptr = entry_ptr;
183 if (next_ptr !=
nullptr) {
186 front_ptr = next_ptr;
187 reclaim(user_context, remove_ptr);
195 if (prev_ptr !=
nullptr) {
199 reclaim(user_context, remove_ptr);
204 if (
empty() ==
false) {
206 while (remove_ptr !=
nullptr) {
208 reclaim(user_context, remove_ptr);
209 remove_ptr = prev_ptr;
221 if (entry_ptr->
prev_ptr !=
nullptr) {
228 if (entry_ptr->
next_ptr !=
nullptr) {
235 reclaim(user_context, entry_ptr);
241 if (entry_ptr !=
nullptr) {
243 EntryType *new_ptr = reserve(user_context);
247 if (prev_ptr !=
nullptr) {
256 return append(user_context);
262 if (entry_ptr !=
nullptr) {
264 EntryType *new_ptr = reserve(user_context);
268 if (next_ptr !=
nullptr) {
300 return entry_count == 0;
314LinkedList::reserve(
void *user_context) {
315 EntryType *entry_ptr =
static_cast<EntryType *
>(
316 link_arena->
reserve(user_context,
true));
317 entry_ptr->
value = data_arena->
reserve(user_context,
true);
318 entry_ptr->next_ptr =
nullptr;
319 entry_ptr->prev_ptr =
nullptr;
323void LinkedList::reclaim(
void *user_context, EntryType *entry_ptr) {
324 void *value_ptr = entry_ptr->value;
325 entry_ptr->value =
nullptr;
326 entry_ptr->next_ptr =
nullptr;
327 entry_ptr->prev_ptr =
nullptr;
328 data_arena->
reclaim(user_context, value_ptr);
329 link_arena->
reclaim(user_context, entry_ptr);
This file declares the routines used by Halide internally in its runtime.
void initialize(void *user_context, uint32_t entry_size, uint32_t capacity=default_capacity, const SystemMemoryAllocatorFns &allocator=default_allocator())
EntryType * prepend(void *user_context)
const SystemMemoryAllocatorFns & current_allocator() const
EntryType * append(void *user_context)
void clear(void *user_context)
void pop_front(void *user_context)
LinkedList & operator=(const LinkedList &)=delete
static const SystemMemoryAllocatorFns & default_allocator()
EntryType * insert_after(void *user_context, EntryType *entry_ptr)
void remove(void *user_context, EntryType *entry_ptr)
void pop_back(void *user_context)
void destroy(void *user_context)
static constexpr uint32_t default_capacity
LinkedList(const LinkedList &)=delete
EntryType * insert_before(void *user_context, EntryType *entry_ptr)
void * reserve(void *user_context, bool initialize=false)
static MemoryArena * create(void *user_context, const Config &config, const SystemMemoryAllocatorFns &allocator=default_allocator())
const Config & current_config() const
static constexpr uint32_t default_capacity
const SystemMemoryAllocatorFns & current_allocator() const
static void destroy(void *user_context, MemoryArena *arena)
void reclaim(void *user_context, void *ptr)
static const SystemMemoryAllocatorFns & default_allocator()
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Expr max(const FuncRef &a, const FuncRef &b)
#define halide_debug_assert(user_context, cond)
halide_debug_assert() is like halide_assert(), but only expands into a check when DEBUG_RUNTIME is de...
void * memcpy(void *s1, const void *s2, size_t n)
unsigned __INT32_TYPE__ uint32_t