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

Add support for detecting AVX2. Confirmed to detect on Haswell i3.

This commit is contained in:
Veselin Georgiev 2014-09-24 00:03:11 +03:00
parent ce02f0bc96
commit fa2083a992
4 changed files with 9 additions and 1 deletions

View file

@ -558,6 +558,7 @@ const char* cpu_feature_str(cpu_feature_t feature)
{ CPU_FEATURE_APERFMPERF, "aperfmperf" }, { CPU_FEATURE_APERFMPERF, "aperfmperf" },
{ CPU_FEATURE_PFI, "pfi" }, { CPU_FEATURE_PFI, "pfi" },
{ CPU_FEATURE_PA, "pa" }, { CPU_FEATURE_PA, "pa" },
{ CPU_FEATURE_AVX2, "avx2" },
}; };
unsigned i, n = COUNT_OF(matchtable); unsigned i, n = COUNT_OF(matchtable);
if (n != NUM_CPU_FEATURES) { if (n != NUM_CPU_FEATURES) {

View file

@ -354,6 +354,7 @@ typedef enum {
CPU_FEATURE_APERFMPERF, /*!< MPERF/APERF MSRs support */ CPU_FEATURE_APERFMPERF, /*!< MPERF/APERF MSRs support */
CPU_FEATURE_PFI, /*!< Processor Feedback Interface support */ CPU_FEATURE_PFI, /*!< Processor Feedback Interface support */
CPU_FEATURE_PA, /*!< Processor accumulator */ CPU_FEATURE_PA, /*!< Processor accumulator */
CPU_FEATURE_AVX2, /*!< AVX2 instructions */
/* termination: */ /* termination: */
NUM_CPU_FEATURES, NUM_CPU_FEATURES,
} cpu_feature_t; } cpu_feature_t;

View file

@ -362,6 +362,9 @@ static void load_intel_features(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
{ 28, CPU_FEATURE_AVX }, { 28, CPU_FEATURE_AVX },
{ 30, CPU_FEATURE_RDRAND }, { 30, CPU_FEATURE_RDRAND },
}; };
const struct feature_map_t matchtable_ebx7[] = {
{ 5, CPU_FEATURE_AVX2 },
};
const struct feature_map_t matchtable_edx81[] = { const struct feature_map_t matchtable_edx81[] = {
{ 20, CPU_FEATURE_XD }, { 20, CPU_FEATURE_XD },
}; };
@ -369,6 +372,9 @@ static void load_intel_features(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
match_features(matchtable_edx1, COUNT_OF(matchtable_edx1), raw->basic_cpuid[1][3], data); match_features(matchtable_edx1, COUNT_OF(matchtable_edx1), raw->basic_cpuid[1][3], data);
match_features(matchtable_ecx1, COUNT_OF(matchtable_ecx1), raw->basic_cpuid[1][2], data); match_features(matchtable_ecx1, COUNT_OF(matchtable_ecx1), raw->basic_cpuid[1][2], data);
} }
if (raw->basic_cpuid[0][0] >= 7) {
match_features(matchtable_ebx7, COUNT_OF(matchtable_ebx7), raw->basic_cpuid[7][1], data);
}
if (raw->ext_cpuid[0][0] >= 1) { if (raw->ext_cpuid[0][0] >= 1) {
match_features(matchtable_edx81, COUNT_OF(matchtable_edx81), raw->ext_cpuid[1][3], data); match_features(matchtable_edx81, COUNT_OF(matchtable_edx81), raw->ext_cpuid[1][3], data);
} }

View file

@ -90,4 +90,4 @@ intel_fn11[3]=00000000 00000000 00000003 00000001
64 64
128 (non-authoritative) 128 (non-authoritative)
Haswell (Core i3) Haswell (Core i3)
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 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 avx2