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

Function PG_parse_init_params

libCacheSim/cache/prefetch/PG.c:56–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static void PG_parse_init_params(const char *cache_specific_params, PG_init_params_t *init_params) {
57 char *params_str = strdup(cache_specific_params);
58
59 while (params_str != NULL && params_str[0] != '\0') {
60 char *key = strsep((char **)&params_str, "=");
61 char *value = strsep((char **)&params_str, ",");
62 while (params_str != NULL && *params_str == ' ') {
63 params_str++;
64 }
65 if (strcasecmp(key, "lookahead-range") == 0) {
66 init_params->lookahead_range = atoi(value);
67 } else if (strcasecmp(key, "block-size") == 0) {
68 init_params->block_size = (unsigned long)atoi(value);
69 } else if (strcasecmp(key, "max-metadata-size") == 0) {
70 init_params->max_metadata_size = atof(value);
71 } else if (strcasecmp(key, "prefetch-threshold") == 0) {
72 init_params->prefetch_threshold = atof(value);
73 } else if (strcasecmp(key, "print") == 0 || strcasecmp(key, "default") == 0) {
74 printf("default params: %s\n", PG_default_params());
75 exit(0);
76 } else {
77 ERROR("pg does not have parameter %s\n", key);
78 printf("default params: %s\n", PG_default_params());
79 exit(1);
80 }
81 }
82}
83
84static void set_PG_params(PG_params_t *PG_params, PG_init_params_t *init_params, uint64_t cache_size) {
85 PG_params->lookahead_range = init_params->lookahead_range;

Callers 1

create_PG_prefetcherFunction · 0.85

Calls 3

atoiFunction · 0.85
atofFunction · 0.85
PG_default_paramsFunction · 0.85

Tested by

no test coverage detected