anrieff / libcpuid

a small C library for x86 CPU detection and feature extraction
Other
451 stars 106 forks source link

Missing detection of ABM on Intel #144

Closed XZiar closed 4 years ago

XZiar commented 4 years ago

ABM flag checking exists on AMD

https://github.com/anrieff/libcpuid/blob/8db3b8d2d32d22437f063ce692a1b9bb15e42d18/libcpuid/recog_amd.c#L317-L320

Not exists on Intel (no matchtable_ecx81) Not exists on Common:

https://github.com/anrieff/libcpuid/blob/8db3b8d2d32d22437f063ce692a1b9bb15e42d18/libcpuid/cpuid_main.c#L230-L232

But according to wiki:

ABM is only implemented as a single instruction set by AMD; all AMD processors support both instructions or neither. Intel considers POPCNT as part of SSE4.2, and LZCNT as part of BMI1. POPCNT has a separate CPUID flag; however, Intel uses AMD's ABM flag to indicate LZCNT support (since LZCNT completes the ABM).[2]

Follow the reference link's pdf, in chapter 2.2.4, it does mentions: image In chaptet 2.9, it says: image (I thinks the second one is a typo, it should be ECX rather than EDX.)

I do find abm exists when using lscpu:

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 Thread(s) per core: 2 Core(s) per socket: 6 Socket(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 158 Model name: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Stepping: 10 CPU MHz: 2208.000 CPU max MHz: 2208.0000 BogoMIPS: 4416.00 Virtualization: VT-x Hypervisor vendor: Windows Subsystem for Linux Virtualization type: container Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave osxsave avx f16c rdrand lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt ibrs ibpb stibp ssbd

From my test, abm at least exists on both 8750H and 4700hq.