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

Function Mithril_parse_init_params

libCacheSim/cache/prefetch/Mithril.c:76–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76static void Mithril_parse_init_params(const char *cache_specific_params,
77 Mithril_init_params_t *init_params) {
78 char *params_str = strdup(cache_specific_params);
79
80 while (params_str != NULL && params_str[0] != '\0') {
81 char *key = strsep((char **)&params_str, "=");
82 char *value = strsep((char **)&params_str, ",");
83 while (params_str != NULL && *params_str == ' ') {
84 params_str++;
85 }
86 if (strcasecmp(key, "lookahead-range") == 0) {
87 init_params->lookahead_range = atoi(value);
88 } else if (strcasecmp(key, "max-support") == 0) {
89 init_params->max_support = atoi(value);
90 } else if (strcasecmp(key, "min-support") == 0) {
91 init_params->min_support = atoi(value);
92 } else if (strcasecmp(key, "confidence") == 0) {
93 init_params->confidence = atoi(value);
94 } else if (strcasecmp(key, "pf-list-size") == 0) {
95 init_params->pf_list_size = atoi(value);
96 } else if (strcasecmp(key, "rec-trigger") == 0) {
97 if (strcasecmp(value, "miss") == 0) {
98 init_params->rec_trigger = miss;
99 } else if (strcasecmp(value, "evict") == 0) {
100 init_params->rec_trigger = evict;
101 } else if (strcasecmp(value, "miss_evict") == 0) {
102 init_params->rec_trigger = miss_evict;
103 } else if (strcasecmp(value, "each_req") == 0) {
104 init_params->rec_trigger = each_req;
105 } else {
106 ERROR("Mithril's rec-trigger does not support %s \n", value);
107 }
108 } else if (strcasecmp(key, "block-size") == 0) {
109 init_params->block_size = (unsigned long)atoi(value);
110 } else if (strcasecmp(key, "max-metadata-size") == 0) {
111 init_params->max_metadata_size = atof(value);
112 } else if (strcasecmp(key, "cycle-time") == 0) {
113 init_params->cycle_time = atoi(value);
114 } else if (strcasecmp(key, "mining-threshold") == 0) {
115 init_params->mining_threshold = atoi(value);
116 } else if (strcasecmp(key, "sequential-type") == 0) {
117 init_params->sequential_type = atoi(value);
118 } else if (strcasecmp(key, "sequential-K") == 0) {
119 init_params->sequential_K = atoi(value);
120 } else if (strcasecmp(key, "AMP-pthreshold") == 0) {
121 init_params->AMP_pthreshold = atoi(value);
122 } else if (strcasecmp(key, "print") == 0 ||
123 strcasecmp(key, "default") == 0) {
124 printf("default params: %s\n", Mithril_default_params());
125 exit(0);
126 } else {
127 ERROR("Mithril does not have parameter %s\n", key);
128 printf("default params: %s\n", Mithril_default_params());
129 exit(1);
130 }
131 }
132}
133

Callers 1

Calls 3

atoiFunction · 0.85
atofFunction · 0.85
Mithril_default_paramsFunction · 0.85

Tested by

no test coverage detected