klauspost / cpuid

CPU feature identification for Go
MIT License
1.04k stars 128 forks source link

Processor cores not displayed correctly #141

Open SomniSom opened 10 months ago

SomniSom commented 10 months ago

Processor Information (dmidecode):

cpuid:

klauspost commented 10 months ago

Threads Per Core is not going to be accurate.

But it does seem like there is something fishy with the latest Intels:

=== RUN   TestMocks/GenuineIntel00B06A2_RaptorLakeP_04_CPUID.txt
    mockcpu_test.go:180: Opening GenuineIntel00B06A2_RaptorLakeP_04_CPUID.txt
    mockcpu_test.go:183: Name: 13th Gen Intel(R) Core(TM) i9-13900H
    mockcpu_test.go:185: Max Function:0x20
    mockcpu_test.go:187: Max Extended Function:0x80000008
    mockcpu_test.go:188: VendorString: GenuineIntel
    mockcpu_test.go:189: VendorID: Intel
    mockcpu_test.go:190: PhysicalCores: 10
    mockcpu_test.go:191: ThreadsPerCore: 2
    mockcpu_test.go:192: LogicalCores: 20
    mockcpu_test.go:193: Family 6 Model: 186 Stepping: 2
    mockcpu_test.go:194: Features: ADX,AESNI,AVX,AVX2,AVXVNNI,BHI_CTRL,BMI1,BMI2,CETIBT,CETSS,CLMUL,CMOV,CMPXCHG8,CX16,ERMS,F16C,FLUSH_L1D,FMA3,FSRM,FXSR,FXSROPT,GFNI,HRESET,HTT,HYBRID_CPU,IA32_ARCH_CAP,IA32_CORE_CAP,IBPB,IDPRED_CTRL,KEYLOCKER,LAHF,LZCNT,MD_CLEAR,MMX,MOVBE,MOVDIR64B,MOVDIRI,NX,OSXSAVE,PCONFIG,POPCNT,PSFD,RDRAND,RDSEED,RDTSCP,RRSBA_CTRL,SERIALIZE,SHA,SPEC_CTRL_SSBD,SSE,SSE2,SSE3,SSE4,SSE42,SSSE3,STIBP,STOSB_SHORT,SYSEE,TME,VAES,VMX,VPCLMULQDQ,WAITPKG,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT,XSAVES
    mockcpu_test.go:195: Microarchitecture level: 3
    mockcpu_test.go:196: Cacheline bytes: 64
    mockcpu_test.go:197: L1 Instruction Cache: 32768 bytes
    mockcpu_test.go:198: L1 Data Cache: 49152 bytes
    mockcpu_test.go:199: L2 Cache: 1310720 bytes
    mockcpu_test.go:200: L3 Cache: 25165824 bytes
    mockcpu_test.go:201: Hz: 3000000000 Hz
    mockcpu_test.go:202: Boost: 5400000000 Hz

https://www.intel.com/content/www/us/en/products/sku/232135/intel-core-i913900h-processor-24m-cache-up-to-5-40-ghz/specifications.html

Problem seem to be:

func physicalCores() int {
    v, _ := vendorID()
    switch v {
    case Intel:
        return logicalCores() / threadsPerCore()

So some work will have to be put into changing the detection of this, and maybe some additional information on slow/fast cores.