Skip to content

Refactor cache_init.h for better extensibility#196

Merged
haochengxia merged 4 commits into1a1a11a:developfrom
laustam:make_extendable
Jun 21, 2025
Merged

Refactor cache_init.h for better extensibility#196
haochengxia merged 4 commits into1a1a11a:developfrom
laustam:make_extendable

Conversation

@laustam
Copy link
Copy Markdown
Contributor

@laustam laustam commented Jun 18, 2025

Currently, cache_init.h consists of a large if-else statement to determine which initialization function to use, depending on the cache eviction algorithm that is specified when running cachesim, in the form:

if (strcasecmp(eviction_algo, "alg1") == 0) {
    cache = ALG1_init(cc_params, eviction_params);
} else if (strcasecmp(eviction_algo, "alg2") == 0) {
    cache = ALG2_init(cc_params, eviction_params);
} ... {
} else if (strcasecmp(eviction_algo, "algN") == 0) {
    cache = ALGN_init(cc_params, eviction_params);
}

To make this more easily extensible, it is better to create a jump table, which is implemented in this PR.

@sonarqubecloud
Copy link
Copy Markdown

@1a1a11a
Copy link
Copy Markdown
Owner

1a1a11a commented Jun 18, 2025

LGTM. Thank you!

@1a1a11a
Copy link
Copy Markdown
Owner

1a1a11a commented Jun 18, 2025

it look like clang-format is reporting an error, can you install the hooks and fix the format issue?
https://github.com/1a1a11a/libCacheSim/blob/develop/scripts/setup-hooks.sh

@1a1a11a 1a1a11a requested a review from Copilot June 18, 2025 20:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@laustam laustam requested a review from haochengxia as a code owner June 20, 2025 20:18
Comment thread libCacheSim/bin/cachesim/cache_init.h
Comment thread libCacheSim/bin/cachesim/cache_init.h
Copy link
Copy Markdown
Collaborator

@haochengxia haochengxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you.

@haochengxia haochengxia merged commit 1157e64 into 1a1a11a:develop Jun 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants