From 94fc6ae36a16daa68e6c71b94d791db25400ca32 Mon Sep 17 00:00:00 2001 From: Veselin Georgiev Date: Fri, 17 Apr 2015 01:21:30 +0300 Subject: [PATCH] Modify the table matcher a bit. Put some weights on the different fields. Priously all fields in the matchtable were treated equal in importance. With this change, the cache size a taken with half the weight in the decision. Also add detection entries for some more recent Haswells, and the respective tests. These are an i5 Haswell from a Mac Book Pro, and a i7 Haswel from Thinkpad T540. --- libcpuid/libcpuid_util.c | 20 +++---- libcpuid/recog_intel.c | 4 ++ tests/intel/haswell/haswell-i5.test | 93 +++++++++++++++++++++++++++++ tests/intel/haswell/haswell-i7.test | 93 +++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+), 10 deletions(-) create mode 100644 tests/intel/haswell/haswell-i5.test create mode 100644 tests/intel/haswell/haswell-i7.test diff --git a/libcpuid/libcpuid_util.c b/libcpuid/libcpuid_util.c index c08f63a..46e813c 100644 --- a/libcpuid/libcpuid_util.c +++ b/libcpuid/libcpuid_util.c @@ -78,16 +78,16 @@ static int score(const struct match_entry_t* entry, const struct cpu_id_t* data, int brand_code, int model_code) { int res = 0; - if (entry->family == data->family ) res++; - if (entry->model == data->model ) res++; - if (entry->stepping == data->stepping ) res++; - if (entry->ext_family == data->ext_family) res++; - if (entry->ext_model == data->ext_model ) res++; - if (entry->ncores == data->num_cores ) res++; - if (entry->l2cache == data->l2_cache ) res++; - if (entry->l3cache == data->l3_cache ) res++; - if (entry->brand_code == brand_code ) res++; - if (entry->model_code == model_code ) res++; + 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; return res; } diff --git a/libcpuid/recog_intel.c b/libcpuid/recog_intel.c index 0cbfead..7469f6a 100644 --- a/libcpuid/recog_intel.c +++ b/libcpuid/recog_intel.c @@ -309,6 +309,10 @@ const struct match_entry_t cpudb_intel[] = { { 6, 12, -1, -1, 60, 4, -1, -1, CORE_HASWELL7 , 0, "Haswell (Core i7)" }, { 6, 12, -1, -1, 60, 4, -1, -1, CORE_HASWELL5 , 0, "Haswell (Core i5)" }, { 6, 12, -1, -1, 60, 2, -1, -1, CORE_HASWELL3 , 0, "Haswell (Core i3)" }, + /* These ones also exist as well: */ + { 6, 5, -1, -1, 69, 4, -1, -1, CORE_HASWELL7 , 0, "Haswell (Core i7)" }, + { 6, 5, -1, -1, 69, 4, -1, -1, CORE_HASWELL5 , 0, "Haswell (Core i5)" }, + { 6, 5, -1, -1, 69, 2, -1, -1, CORE_HASWELL3 , 0, "Haswell (Core i3)" }, /* Core microarchitecture-based Xeons: */ diff --git a/tests/intel/haswell/haswell-i5.test b/tests/intel/haswell/haswell-i5.test new file mode 100644 index 0000000..4b3fde2 --- /dev/null +++ b/tests/intel/haswell/haswell-i5.test @@ -0,0 +1,93 @@ +basic_cpuid[0]=0000000d 756e6547 6c65746e 49656e69 +basic_cpuid[1]=00040651 00100800 7ffafbbf bfebfbff +basic_cpuid[2]=76036301 00f0b5ff 00000000 00c10000 +basic_cpuid[3]=00000000 00000000 00000000 00000000 +basic_cpuid[4]=1c004121 01c0003f 0000003f 00000000 +basic_cpuid[5]=00000040 00000040 00000003 11142120 +basic_cpuid[6]=00000077 00000002 00000009 00000000 +basic_cpuid[7]=00000000 000027ab 00000000 00000000 +basic_cpuid[8]=00000000 00000000 00000000 00000000 +basic_cpuid[9]=00000000 00000000 00000000 00000000 +basic_cpuid[10]=07300403 00000000 00000000 00000603 +basic_cpuid[11]=00000001 00000002 00000100 00000000 +basic_cpuid[12]=00000000 00000000 00000000 00000000 +basic_cpuid[13]=00000007 00000340 00000340 00000000 +basic_cpuid[14]=00000007 00000340 00000340 00000000 +basic_cpuid[15]=00000007 00000340 00000340 00000000 +basic_cpuid[16]=00000007 00000340 00000340 00000000 +basic_cpuid[17]=00000007 00000340 00000340 00000000 +basic_cpuid[18]=00000007 00000340 00000340 00000000 +basic_cpuid[19]=00000007 00000340 00000340 00000000 +basic_cpuid[20]=00000007 00000340 00000340 00000000 +basic_cpuid[21]=00000007 00000340 00000340 00000000 +basic_cpuid[22]=00000007 00000340 00000340 00000000 +basic_cpuid[23]=00000007 00000340 00000340 00000000 +basic_cpuid[24]=00000007 00000340 00000340 00000000 +basic_cpuid[25]=00000007 00000340 00000340 00000000 +basic_cpuid[26]=00000007 00000340 00000340 00000000 +basic_cpuid[27]=00000007 00000340 00000340 00000000 +basic_cpuid[28]=00000007 00000340 00000340 00000000 +basic_cpuid[29]=00000007 00000340 00000340 00000000 +basic_cpuid[30]=00000007 00000340 00000340 00000000 +basic_cpuid[31]=00000007 00000340 00000340 00000000 +ext_cpuid[0]=80000008 00000000 00000000 00000000 +ext_cpuid[1]=00000000 00000000 00000021 2c100800 +ext_cpuid[2]=65746e49 2952286c 726f4320 4d542865 +ext_cpuid[3]=35692029 3532342d 43205538 40205550 +ext_cpuid[4]=342e3220 7a484730 00000000 00000000 +ext_cpuid[5]=00000000 00000000 00000000 00000000 +ext_cpuid[6]=00000000 00000000 01006040 00000000 +ext_cpuid[7]=00000000 00000000 00000000 00000100 +ext_cpuid[8]=00003027 00000000 00000000 00000000 +ext_cpuid[9]=00000007 00000340 00000340 00000000 +ext_cpuid[10]=00000007 00000340 00000340 00000000 +ext_cpuid[11]=00000007 00000340 00000340 00000000 +ext_cpuid[12]=00000007 00000340 00000340 00000000 +ext_cpuid[13]=00000007 00000340 00000340 00000000 +ext_cpuid[14]=00000007 00000340 00000340 00000000 +ext_cpuid[15]=00000007 00000340 00000340 00000000 +ext_cpuid[16]=00000007 00000340 00000340 00000000 +ext_cpuid[17]=00000007 00000340 00000340 00000000 +ext_cpuid[18]=00000007 00000340 00000340 00000000 +ext_cpuid[19]=00000007 00000340 00000340 00000000 +ext_cpuid[20]=00000007 00000340 00000340 00000000 +ext_cpuid[21]=00000007 00000340 00000340 00000000 +ext_cpuid[22]=00000007 00000340 00000340 00000000 +ext_cpuid[23]=00000007 00000340 00000340 00000000 +ext_cpuid[24]=00000007 00000340 00000340 00000000 +ext_cpuid[25]=00000007 00000340 00000340 00000000 +ext_cpuid[26]=00000007 00000340 00000340 00000000 +ext_cpuid[27]=00000007 00000340 00000340 00000000 +ext_cpuid[28]=00000007 00000340 00000340 00000000 +ext_cpuid[29]=00000007 00000340 00000340 00000000 +ext_cpuid[30]=00000007 00000340 00000340 00000000 +ext_cpuid[31]=00000007 00000340 00000340 00000000 +intel_fn4[0]=1c004121 01c0003f 0000003f 00000000 +intel_fn4[1]=1c004122 01c0003f 0000003f 00000000 +intel_fn4[2]=1c004143 01c0003f 000001ff 00000000 +intel_fn4[3]=1c03c163 02c0003f 00000fff 00000006 +intel_fn11[0]=00000001 00000002 00000100 00000000 +intel_fn11[1]=00000004 00000004 00000201 00000000 +intel_fn11[2]=00000000 00000000 00000002 00000000 +intel_fn11[3]=00000000 00000000 00000003 00000000 +-------------------------------------------------------------------------------- +6 +5 +1 +6 +69 +2 +4 +32 +32 +256 +3072 +8 +8 +12 +64 +64 +64 +128 (non-authoritative) +Haswell (Core i5) +fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni pclmul dts64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 syscall xd movbe popcnt aes xsave osxsave avx rdtscp lm lahf_lm constant_tsc fma3 f16c rdrand x2apic avx2 bmi1 bmi2 diff --git a/tests/intel/haswell/haswell-i7.test b/tests/intel/haswell/haswell-i7.test new file mode 100644 index 0000000..8e2434b --- /dev/null +++ b/tests/intel/haswell/haswell-i7.test @@ -0,0 +1,93 @@ +basic_cpuid[0]=0000000d 756e6547 6c65746e 49656e69 +basic_cpuid[1]=000306c3 03100800 7fdafbbf bfebfbff +basic_cpuid[2]=76036301 00f0b5ff 00000000 00c10000 +basic_cpuid[3]=00000000 00000000 00000000 00000000 +basic_cpuid[4]=1c004121 01c0003f 0000003f 00000000 +basic_cpuid[5]=00000040 00000040 00000003 00042120 +basic_cpuid[6]=00000077 00000002 00000009 00000000 +basic_cpuid[7]=00000000 000027ab 00000000 00000000 +basic_cpuid[8]=00000000 00000000 00000000 00000000 +basic_cpuid[9]=00000000 00000000 00000000 00000000 +basic_cpuid[10]=07300403 00000000 00000000 00000603 +basic_cpuid[11]=00000001 00000002 00000100 00000003 +basic_cpuid[12]=00000000 00000000 00000000 00000000 +basic_cpuid[13]=00000007 00000340 00000340 00000000 +basic_cpuid[14]=00000007 00000340 00000340 00000000 +basic_cpuid[15]=00000007 00000340 00000340 00000000 +basic_cpuid[16]=00000007 00000340 00000340 00000000 +basic_cpuid[17]=00000007 00000340 00000340 00000000 +basic_cpuid[18]=00000007 00000340 00000340 00000000 +basic_cpuid[19]=00000007 00000340 00000340 00000000 +basic_cpuid[20]=00000007 00000340 00000340 00000000 +basic_cpuid[21]=00000007 00000340 00000340 00000000 +basic_cpuid[22]=00000007 00000340 00000340 00000000 +basic_cpuid[23]=00000007 00000340 00000340 00000000 +basic_cpuid[24]=00000007 00000340 00000340 00000000 +basic_cpuid[25]=00000007 00000340 00000340 00000000 +basic_cpuid[26]=00000007 00000340 00000340 00000000 +basic_cpuid[27]=00000007 00000340 00000340 00000000 +basic_cpuid[28]=00000007 00000340 00000340 00000000 +basic_cpuid[29]=00000007 00000340 00000340 00000000 +basic_cpuid[30]=00000007 00000340 00000340 00000000 +basic_cpuid[31]=00000007 00000340 00000340 00000000 +ext_cpuid[0]=80000008 00000000 00000000 00000000 +ext_cpuid[1]=00000000 00000000 00000021 2c100000 +ext_cpuid[2]=65746e49 2952286c 726f4320 4d542865 +ext_cpuid[3]=37692029 3137342d 20514d30 20555043 +ext_cpuid[4]=2e322040 48473035 0000007a 00000000 +ext_cpuid[5]=00000000 00000000 00000000 00000000 +ext_cpuid[6]=00000000 00000000 01006040 00000000 +ext_cpuid[7]=00000000 00000000 00000000 00000100 +ext_cpuid[8]=00003027 00000000 00000000 00000000 +ext_cpuid[9]=00000007 00000340 00000340 00000000 +ext_cpuid[10]=00000007 00000340 00000340 00000000 +ext_cpuid[11]=00000007 00000340 00000340 00000000 +ext_cpuid[12]=00000007 00000340 00000340 00000000 +ext_cpuid[13]=00000007 00000340 00000340 00000000 +ext_cpuid[14]=00000007 00000340 00000340 00000000 +ext_cpuid[15]=00000007 00000340 00000340 00000000 +ext_cpuid[16]=00000007 00000340 00000340 00000000 +ext_cpuid[17]=00000007 00000340 00000340 00000000 +ext_cpuid[18]=00000007 00000340 00000340 00000000 +ext_cpuid[19]=00000007 00000340 00000340 00000000 +ext_cpuid[20]=00000007 00000340 00000340 00000000 +ext_cpuid[21]=00000007 00000340 00000340 00000000 +ext_cpuid[22]=00000007 00000340 00000340 00000000 +ext_cpuid[23]=00000007 00000340 00000340 00000000 +ext_cpuid[24]=00000007 00000340 00000340 00000000 +ext_cpuid[25]=00000007 00000340 00000340 00000000 +ext_cpuid[26]=00000007 00000340 00000340 00000000 +ext_cpuid[27]=00000007 00000340 00000340 00000000 +ext_cpuid[28]=00000007 00000340 00000340 00000000 +ext_cpuid[29]=00000007 00000340 00000340 00000000 +ext_cpuid[30]=00000007 00000340 00000340 00000000 +ext_cpuid[31]=00000007 00000340 00000340 00000000 +intel_fn4[0]=1c004121 01c0003f 0000003f 00000000 +intel_fn4[1]=1c004122 01c0003f 0000003f 00000000 +intel_fn4[2]=1c004143 01c0003f 000001ff 00000000 +intel_fn4[3]=1c03c163 02c0003f 00001fff 00000006 +intel_fn11[0]=00000001 00000002 00000100 00000003 +intel_fn11[1]=00000004 00000008 00000201 00000003 +intel_fn11[2]=00000000 00000000 00000002 00000003 +intel_fn11[3]=00000000 00000000 00000003 00000003 +-------------------------------------------------------------------------------- +6 +12 +3 +6 +60 +4 +8 +32 +32 +256 +6144 +8 +8 +12 +64 +64 +64 +128 (non-authoritative) +Haswell (Core i7) +fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni pclmul dts64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 xd movbe popcnt aes xsave osxsave avx rdtscp lm lahf_lm constant_tsc fma3 f16c rdrand avx2 bmi1 bmi2