1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

Allow to debug score

AMD Raphael is detected as Warhol. I found they have the same score because Raphael is stepping 2, despite having a matching ext_model
This commit is contained in:
Xorg 2022-10-01 17:21:33 +02:00
parent 3bf569faf5
commit 7a176ff1e4
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A

View file

@ -95,19 +95,29 @@ static unsigned int popcount64(uint64_t mask)
static int score(const struct match_entry_t* entry, const struct cpu_id_t* data,
int brand_code, uint64_t bits, int model_code)
{
int res = 0;
if (entry->family == data->family ) res += 2;
if (entry->model == data->model ) res += 2;
if (entry->stepping == data->stepping ) res += 2;
if (entry->ext_family == data->ext_family) res += 2;
if (entry->ext_model == data->ext_model ) res += 2;
if (entry->ncores == data->num_cores ) res += 2;
if (entry->l2cache == data->l2_cache ) res += 1;
if (entry->l3cache == data->l3_cache ) res += 1;
if (entry->brand_code == brand_code ) res += 2;
if (entry->model_code == model_code ) res += 2;
int i, tmp, res = 0;
const struct { const char *field; int entry; int data; int score; } array[] = {
{ "family", entry->family, data->family, 2 },
{ "model", entry->model, data->model, 2 },
{ "stepping", entry->stepping, data->stepping, 2 },
{ "ext_family", entry->ext_family, data->ext_family, 2 },
{ "ext_model", entry->ext_model, data->ext_model, 2 },
{ "ncores", entry->ncores, data->num_cores, 2 },
{ "l2cache", entry->l2cache, data->l2_cache, 1 },
{ "l3cache", entry->l3cache, data->l3_cache, 1 },
{ "brand_code", entry->brand_code, brand_code, 2 },
{ "model_code", entry->model_code, model_code, 2 },
};
for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) {
if(array[i].entry == array[i].data) {
res += array[i].score;
debugf(4, "Score: %-12s matches, adding %2i (current score for this entry: %2i)\n", array[i].field, array[i].score, res);
}
}
res += popcount64(entry->model_bits & bits) * 2;
tmp = popcount64(entry->model_bits & bits) * 2;
res += tmp;
debugf(4, "Score: %-12s matches, adding %2i (current score for this entry: %2i)\n", "model_bits", tmp, res);
return res;
}