MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / LHD_init

Function LHD_init

libCacheSim/cache/eviction/LHD/LHD_Interface.cpp:56–101  ·  view source on GitHub ↗

* @brief initialize the cache * * @param ccache_params some common cache parameters * @param cache_specific_params cache specific parameters, see parse_params * function or use -e "print" with the cachesim binary */

Source from the content-addressed store, hash-verified

54 * function or use -e "print" with the cachesim binary
55 */
56cache_t *LHD_init(const common_cache_params_t ccache_params,
57 const char *cache_specific_params) {
58#ifdef SUPPORT_TTL
59 if (ccache_params.default_ttl < 30 * 86400) {
60 ERROR("LHD does not support expiration\n");
61 abort();
62 }
63#endif
64
65 cache_t *cache = cache_struct_init("LHD", ccache_params, cache_specific_params);
66 cache->cache_init = LHD_init;
67 cache->cache_free = LHD_free;
68 cache->get = LHD_get;
69 cache->find = LHD_find;
70 cache->insert = LHD_insert;
71 cache->evict = LHD_evict;
72 cache->to_evict = LHD_to_evict;
73 cache->remove = LHD_remove;
74 cache->can_insert = cache_can_insert_default;
75 cache->get_occupied_byte = LHD_get_occupied_byte;
76 cache->get_n_obj = LHD_get_n_obj;
77 cache->to_evict_candidate =
78 static_cast<cache_obj_t *>(malloc(sizeof(cache_obj_t)));
79
80 if (ccache_params.consider_obj_metadata) {
81 cache->obj_md_size = 8 * 3 + 1; // two age, one time stamp
82 } else {
83 cache->obj_md_size = 0;
84 }
85
86 auto *params = my_malloc(LHD_params_t);
87 memset(params, 0, sizeof(LHD_params_t));
88 cache->eviction_params = params;
89
90 if (params->admission == 0) {
91 params->admission = 8;
92 }
93 if (params->associativity == 0) {
94 params->associativity = 32;
95 }
96
97 params->LHD_cache = static_cast<void *>(
98 new LHD(params->associativity, params->admission, cache));
99
100 return cache;
101}
102
103/**
104 * free resources used by this cache

Callers 8

run_multiple_cachesFunction · 0.85
create_test_cacheFunction · 0.85
S3FIFOd_initFunction · 0.85
QDLP_initFunction · 0.85
WTinyLFU_initFunction · 0.85
flashProb_initFunction · 0.85
create_cacheFunction · 0.85
mainFunction · 0.85

Calls 1

cache_struct_initFunction · 0.85

Tested by

no test coverage detected