Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest -C ${{env.BUILD_TYPE}} --output-on-failure
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel

ubuntu:
runs-on: ubuntu-latest
Expand All @@ -44,7 +44,7 @@ jobs:
working-directory: ${{github.workspace}}/build
run: |
export ASAN_OPTIONS="detect_leaks=1:halt_on_error=1:verbosity=1"
ctest -C ${{env.BUILD_TYPE}} --output-on-failure
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel

selfhosted:
runs-on: self-hosted
Expand All @@ -56,7 +56,7 @@ jobs:
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} -j
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel



1 change: 1 addition & 0 deletions libCacheSim/cache/eviction/Belady.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static void Belady_free(cache_t *cache) {
node = pqueue_pop(params->pq);
}
pqueue_free(params->pq);
my_free(sizeof(Belady_params_t), params);

cache_struct_free(cache);
}
Expand Down
144 changes: 73 additions & 71 deletions test/test_admissionAlgo.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
#include "common.h"

static const uint64_t g_req_cnt_true = 113872, g_req_byte_true = 4368040448;
// Constants
static const uint64_t g_req_cnt_true = 113872;
static const uint64_t g_req_byte_true = 4368040448;
static const uint64_t NUM_TEST_SIZES = 8;

// Test data structure
typedef struct {
const char *cache_name;
uint64_t hashpower;
uint64_t req_cnt_true;
uint64_t req_byte_true;
uint64_t miss_cnt_true[8];
uint64_t miss_byte_true[8];
} admission_test_data_t;

// Test data definitions (ordered alphabetically by algorithm name)
static const admission_test_data_t test_data_truth[] = {
{.cache_name = "AdaptSize",
.hashpower = 20,
.req_cnt_true = 113872,
.req_byte_true = 4368040448,
.miss_cnt_true = {83204, 80907, 77835, 77086, 76173, 76158, 76158, 76158},
.miss_byte_true = {3996894720, 3916923392, 3790021120, 3751927808,
3695680512, 3695609344, 3695609344, 3695609344}},
{.cache_name = "BloomFilter",
.hashpower = 20,
.req_cnt_true = 113872,
.req_byte_true = 4368040448,
.miss_cnt_true = {94816, 90386, 88417, 85744, 82344, 79504, 77058, 76979},
.miss_byte_true = {4193502720, 3979631104, 3877562880, 3716727296,
3503820288, 3323299328, 3257762304, 3254848512}},
{.cache_name = "Size",
.hashpower = 20,
.req_cnt_true = 113872,
.req_byte_true = 4368040448,
.miss_cnt_true = {93374, 89783, 83572, 81722, 72494, 72104, 71972, 71704},
.miss_byte_true = {4214303232, 4061242368, 3778040320, 3660569600,
3100927488, 3078128640, 3075403776, 3061662720}},
{.cache_name = "SizeProb",
.hashpower = 20,
.req_cnt_true = 113872,
.req_byte_true = 4368040448,
.miss_cnt_true = {93371, 89122, 83635, 81935, 73293, 72963, 72737, 71949},
.miss_byte_true = {4214365696, 4030683648, 3781775872, 3671897088,
3151684096, 3133195264, 3123936256, 3078763520}}};

static void _verify_profiler_results(const cache_stat_t *res,
uint64_t num_of_sizes,
Expand Down Expand Up @@ -39,88 +83,45 @@ static void print_results(const cache_t *cache, const cache_stat_t *res) {
printf("};\n");
}

static void test_AdaptSize(gconstpointer user_data) {
uint64_t miss_cnt_true[] = {83204, 80907, 77835, 77086,
76173, 76158, 76158, 76158};
uint64_t miss_byte_true[] = {3996894720, 3916923392, 3790021120, 3751927808,
3695680512, 3695609344, 3695609344, 3695609344};

// Generic test function that works for all admission algorithms
static void test_admission_algorithm(gconstpointer user_data,
const admission_test_data_t *test_data) {
reader_t *reader = (reader_t *)user_data;
common_cache_params_t cc_params = {
.cache_size = CACHE_SIZE, .hashpower = 20, .default_ttl = DEFAULT_TTL};
cache_t *cache = create_test_cache("AdaptSize", cc_params, reader, NULL);
g_assert_true(cache != NULL);
cache_stat_t *res = simulate_at_multi_sizes_with_step_size(
reader, cache, STEP_SIZE, NULL, 0, 0, _n_cores(), false);

print_results(cache, res);
_verify_profiler_results(res, CACHE_SIZE / STEP_SIZE, g_req_cnt_true,
miss_cnt_true, g_req_byte_true, miss_byte_true);
cache->cache_free(cache);
my_free(sizeof(cache_stat_t), res);
}
common_cache_params_t cc_params = {.cache_size = CACHE_SIZE,
.hashpower = test_data->hashpower,
.default_ttl = DEFAULT_TTL};

static void test_Size(gconstpointer user_data) {
uint64_t miss_cnt_true[] = {93374, 89783, 83572, 81722,
72494, 72104, 71972, 71704};
uint64_t miss_byte_true[] = {4214303232, 4061242368, 3778040320, 3660569600,
3100927488, 3078128640, 3075403776, 3061662720};

reader_t *reader = (reader_t *)user_data;
common_cache_params_t cc_params = {
.cache_size = CACHE_SIZE, .hashpower = 20, .default_ttl = DEFAULT_TTL};
cache_t *cache = create_test_cache("Size", cc_params, reader, NULL);
cache_t *cache =
create_test_cache(test_data->cache_name, cc_params, reader, NULL);
g_assert_true(cache != NULL);

cache_stat_t *res = simulate_at_multi_sizes_with_step_size(
reader, cache, STEP_SIZE, NULL, 0, 0, _n_cores(), false);

print_results(cache, res);
_verify_profiler_results(res, CACHE_SIZE / STEP_SIZE, g_req_cnt_true,
miss_cnt_true, g_req_byte_true, miss_byte_true);
_verify_profiler_results(res, CACHE_SIZE / STEP_SIZE, test_data->req_cnt_true,
test_data->miss_cnt_true, test_data->req_byte_true,
test_data->miss_byte_true);

cache->cache_free(cache);
my_free(sizeof(cache_stat_t), res);
}

static void test_SizeProb(gconstpointer user_data) {
uint64_t miss_cnt_true[] = {93371, 89122, 83635, 81935,
73293, 72963, 72737, 71949};
uint64_t miss_byte_true[] = {4214365696, 4030683648, 3781775872, 3671897088,
3151684096, 3133195264, 3123936256, 3078763520};

reader_t *reader = (reader_t *)user_data;
common_cache_params_t cc_params = {
.cache_size = CACHE_SIZE, .hashpower = 20, .default_ttl = DEFAULT_TTL};
cache_t *cache = create_test_cache("SizeProb", cc_params, reader, NULL);
g_assert_true(cache != NULL);
cache_stat_t *res = simulate_at_multi_sizes_with_step_size(
reader, cache, STEP_SIZE, NULL, 0, 0, _n_cores(), false);

print_results(cache, res);
_verify_profiler_results(res, CACHE_SIZE / STEP_SIZE, g_req_cnt_true,
miss_cnt_true, g_req_byte_true, miss_byte_true);
cache->cache_free(cache);
my_free(sizeof(cache_stat_t), res);
// Individual test functions (ordered alphabetically)
static void test_AdaptSize(gconstpointer user_data) {
test_admission_algorithm(user_data, &test_data_truth[0]);
}

static void test_BloomFilter(gconstpointer user_data) {
uint64_t miss_cnt_true[] = {94816, 90386, 88417, 85744,
82344, 79504, 77058, 76979};
uint64_t miss_byte_true[] = {4193502720, 3979631104, 3877562880, 3716727296,
3503820288, 3323299328, 3257762304, 3254848512};
test_admission_algorithm(user_data, &test_data_truth[1]);
}

reader_t *reader = (reader_t *)user_data;
common_cache_params_t cc_params = {
.cache_size = CACHE_SIZE, .hashpower = 20, .default_ttl = DEFAULT_TTL};
cache_t *cache = create_test_cache("BloomFilter", cc_params, reader, NULL);
g_assert_true(cache != NULL);
cache_stat_t *res = simulate_at_multi_sizes_with_step_size(
reader, cache, STEP_SIZE, NULL, 0, 0, _n_cores(), false);
static void test_Size(gconstpointer user_data) {
test_admission_algorithm(user_data, &test_data_truth[2]);
}

print_results(cache, res);
_verify_profiler_results(res, CACHE_SIZE / STEP_SIZE, g_req_cnt_true,
miss_cnt_true, g_req_byte_true, miss_byte_true);
cache->cache_free(cache);
my_free(sizeof(cache_stat_t), res);
static void test_SizeProb(gconstpointer user_data) {
test_admission_algorithm(user_data, &test_data_truth[3]);
}

static void empty_test(gconstpointer user_data) { ; }
Expand All @@ -139,13 +140,14 @@ int main(int argc, char *argv[]) {

reader = setup_oracleGeneralBin_reader();

// Test registrations (ordered alphabetically)
g_test_add_data_func("/libCacheSim/admissionAlgo_AdaptSize", reader,
test_AdaptSize);
g_test_add_data_func("/libCacheSim/admissionAlgo_BloomFilter", reader,
test_BloomFilter);
g_test_add_data_func("/libCacheSim/admissionAlgo_Size", reader, test_Size);
g_test_add_data_func("/libCacheSim/admissionAlgo_SizeProb", reader,
test_SizeProb);
g_test_add_data_func_full("/libCacheSim/admissionAlgo_BloomFilter", reader,
test_BloomFilter, test_teardown);
g_test_add_data_func_full("/libCacheSim/admissionAlgo_SizeProb", reader,
test_SizeProb, test_teardown);

return g_test_run();
}
Loading
Loading