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

Function LRB_init

libCacheSim/cache/eviction/LRB/LRB_Interface.cpp:64–124  ·  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

62 * function or use -e "print" with the cachesim binary
63 */
64cache_t *LRB_init(const common_cache_params_t ccache_params,
65 const char *cache_specific_params) {
66#ifdef SUPPORT_TTL
67 if (ccache_params.default_ttl < 30 * 86400) {
68 ERROR("LRB does not support expiration\n");
69 abort();
70 }
71#endif
72
73 cache_t *cache =
74 cache_struct_init("LRB", ccache_params, cache_specific_params);
75 cache->cache_init = LRB_init;
76 cache->cache_free = LRB_free;
77 cache->get = LRB_get;
78 cache->find = LRB_find;
79 cache->insert = LRB_insert;
80 cache->evict = LRB_evict;
81 cache->to_evict = LRB_to_evict;
82 cache->remove = LRB_remove;
83 cache->can_insert = cache_can_insert_default;
84 cache->get_occupied_byte = LRB_get_occupied_byte;
85 cache->get_n_obj = LRB_get_n_obj;
86 cache->to_evict_candidate =
87 static_cast<cache_obj_t *>(malloc(sizeof(cache_obj_t)));
88
89 if (ccache_params.consider_obj_metadata) {
90 cache->obj_md_size = 180;
91 } else {
92 cache->obj_md_size = 0;
93 }
94
95 LRB_params_t *params = my_malloc(LRB_params_t);
96 cache->eviction_params = params;
97
98 if (cache_specific_params != NULL) {
99 LRB_parse_params(cache, cache_specific_params);
100 } else {
101 LRB_parse_params(cache, DEFAULT_PARAMS);
102 }
103
104 auto *lrb = new lrb::LRBCache();
105 params->LRB_cache = static_cast<void *>(lrb);
106
107 lrb->setSize(ccache_params.cache_size);
108
109 std::map<string, string> params_map;
110
111 params_map["objective"] = params->objective;
112
113 if (strcmp(params->objective, "object-miss-ratio") == 0) {
114 snprintf(cache->cache_name, CACHE_NAME_ARRAY_LEN, "%s", "LRB-OMR");
115 } else if (strcasecmp(params->objective, "byte-miss-ratio") == 0) {
116 snprintf(cache->cache_name, CACHE_NAME_ARRAY_LEN, "%s", "LRB-BMR");
117 } else {
118 ERROR("LRB does not support objective %s\n", params->objective);
119 }
120
121 lrb->init_with_params(params_map);

Callers 1

create_cacheFunction · 0.85

Calls 4

cache_struct_initFunction · 0.85
LRB_parse_paramsFunction · 0.85
setSizeMethod · 0.45
init_with_paramsMethod · 0.45

Tested by

no test coverage detected