1#ifndef HALIDE_RUNTIME_HASHMAP_H
2#define HALIDE_RUNTIME_HASHMAP_H
15#define hashmap_malloc(user_context, size) halide_malloc(user_context, size)
19#define hashmap_free(user_context, memory) halide_free(user_context, memory)
32 for (
size_t i = 0;
i < key_size;
i++) {
33 h = (
h << 5) +
h + key[
i];
55 bool init(
void *user_context,
60 void destroy(
void *user_context,
83 const size_t alignment = 8;
199 if (more_recent !=
nullptr) {
259 while (entry !=
nullptr) {
302 debug(
user_context) <<
"halide_memoization_cache_store\n";
325 entry = entry->
next) {
326 if (entry->hash ==
h && entry->key_size == (
size_t)size &&
361 debug(
user_context) <<
"Exiting halide_memoization_cache_store\n";
365 debug(
user_context) <<
"halide_memoization_cache_release\n";
368 debug(
user_context) <<
"Exited halide_memoization_cache_release.\n";
372 debug(
nullptr) <<
"halide_memoization_cache_cleanup\n";
376 while (entry !=
nullptr) {
389template<
typename KeyType,
typename ValueType>
399 ValueType *
D =
reinterpret_cast<ValueType *
>(dst);
400 const ValueType *
S =
reinterpret_cast<const ValueType *
>(src);
406 ValueType *
V =
reinterpret_cast<ValueType *
>(value);
#define hashmap_malloc(user_context, size)
#define hashmap_free(user_context, memory)
bool keys_equal(const uint8_t *key1, const uint8_t *key2, size_t key_size)
void(* copy_value_func)(uint8_t *dst, const uint8_t *src, size_t size)
uint32_t djb_hash(const uint8_t *key, size_t key_size)
void(* destroy_value_func)(uint8_t *value, size_t size)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
unsigned __INT64_TYPE__ uint64_t
signed __INT64_TYPE__ int64_t
#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...
signed __INT32_TYPE__ int32_t
unsigned __INT8_TYPE__ uint8_t
int memcmp(const void *s1, const void *s2, size_t n)
void * memset(void *s, int val, size_t n)
unsigned __INT32_TYPE__ uint32_t
bool init(void *user_context, const uint8_t *cache_key, size_t cache_key_size, uint32_t key_hash, const uint8_t *cache_value, size_t cache_value_size, copy_value_func copy_value)
uint8_t * metadata_storage
void destroy(void *user_context, destroy_value_func destroy_value)
void set_size(int64_t size)
destroy_value_func destroy_value
CacheEntry * cache_entries[kHashTableSize]
halide_mutex memoization_lock
CacheEntry * most_recently_used
CacheEntry * least_recently_used
void release(void *user_context, void *host)
int64_t current_cache_size
bool init(void *user_context, copy_value_func copy_value, destroy_value_func destroy_value)
copy_value_func copy_value
static const size_t kHashTableSize
uint64_t kDefaultCacheSize
void store(void *user_context, const uint8_t *cache_key, int32_t size, const uint8_t *cache_value, size_t cache_value_size)
int lookup(void *user_context, const uint8_t *cache_key, int32_t size, uint8_t *cache_value, size_t cache_value_size)
static void destroy_value_func(uint8_t *value, size_t size)
bool init(void *user_context)
static void copy_value_func(uint8_t *dst, const uint8_t *src, size_t size)
int lookup(void *user_context, const uint8_t *cache_key, int32_t key_size, ValueType *cache_value)
void store(void *user_context, const uint8_t *cache_key, int32_t key_size, const ValueType *cache_value)
The raw representation of an image passed around by generated Halide code.