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

Function run_multiple_caches

example/cacheSimulatorConcurrent/main.cpp:38–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void run_multiple_caches(reader_t *reader) {
39 reset_reader(reader);
40
41 common_cache_params_t cc_params = default_common_cache_params();
42 cc_params.cache_size = 1 * GiB;
43 cc_params.hashpower = 16;
44
45 cache_t *caches[8] = {
46 LRU_init(cc_params, nullptr), LFU_init(cc_params, nullptr),
47 FIFO_init(cc_params, nullptr), Sieve_init(cc_params, nullptr),
48 LHD_init(cc_params, nullptr), LeCaR_init(cc_params, nullptr),
49 ARC_init(cc_params, nullptr), NULL};
50
51 // Hyperbolic samples eviction candidates from the cache,
52 // so the hash table needs to be small
53 cc_params.hashpower = 12;
54 caches[7] = Hyperbolic_init(cc_params, nullptr);
55
56 cache_stat_t *result = simulate_with_multi_caches(
57 reader, caches, 8, nullptr, 0.0, 0,
58 static_cast<int>(std::thread::hardware_concurrency()), 0, false);
59
60 printf(
61 " cache name cache size num_miss num_req"
62 " miss ratio byte miss ratio\n");
63 for (int i = 0; i < NUM_SIZES; i++) {
64 printf("%16s %16lu %16lu %16lu %16.4lf %16.4lf\n", result[i].cache_name,
65 result[i].cache_size, result[i].n_miss, result[i].n_req,
66 (double)(result[i].n_miss) / (double)result[i].n_req,
67 (double)(result[i].n_miss_byte / (double)result[i].n_req_byte));
68 }
69 free(result);
70 for (int i = 0; i < 8; i++) {
71 caches[i]->cache_free(caches[i]);
72 }
73}
74
75int main(int argc, char *argv[]) {
76 reader_init_param_t init_params = default_reader_init_params();

Callers 1

mainFunction · 0.85

Calls 11

reset_readerFunction · 0.85
LRU_initFunction · 0.85
LFU_initFunction · 0.85
FIFO_initFunction · 0.85
Sieve_initFunction · 0.85
LHD_initFunction · 0.85
LeCaR_initFunction · 0.85
ARC_initFunction · 0.85
Hyperbolic_initFunction · 0.85

Tested by

no test coverage detected