klauspost / cpuid

CPU feature identification for Go
MIT License
1.01k stars 125 forks source link

Can this package support detecting CPU microarchitecture information? #135

Closed jiere closed 8 months ago

jiere commented 8 months ago

$ cpuid --version cpuid version 20230505 $ cpuid -1 |grep synth (family synth) = 0x6 (6) (model synth) = 0x8f (143) (simple synth) = Intel Xeon (unknown type) (Sapphire Rapids E5/B3) {Golden Cove}, Intel 7 (size synth) = 49152 (48 KB) (size synth) = 32768 (32 KB) (size synth) = 2097152 (2 MB) (size synth) = 110100480 (105 MB) (QoS monitoring counter size synth) = 32 (vuln to branch type confusion synth) = true (multi-processing synth) = multi-core (c=56), hyper-threaded (t=2) (APIC widths synth): CORE_width=6 SMT_width=1 (APIC synth): PKG_ID=1 CORE_ID=53 SMT_ID=1 (uarch synth) = Intel Sapphire Rapids {Golden Cove}, Intel 7 (synth) = Intel Scalable (4th Gen) Bronze/Silver/Gold/Platinum (Sapphire Rapids E5/B3) {Golden Cove}, Intel 7 $ cpuid -1 |grep uarch (uarch synth) = Intel Sapphire Rapids {Golden Cove}, Intel 7

mythi commented 8 months ago

The sample output gives a good overview. Would CPU Family, Model, and microarchitectue level be enough or are you looking for something else?

jiere commented 8 months ago

Yeah, we just need to find a cpuid alternative golang pkg/lib to achieve similar target, since cpuid itself is a binary dependency which is not included in all Linux Distros. Another reason is that the command call in Golang is also not so elegant.

We found project here, but the current CPU mapping list looks not complete. Not sure if there is any project where the CPU mapping list is well maintained and up-to-date, at lease for Intel CPUs:)

klauspost commented 8 months ago

There is none here. I cannot commit to maintaining such a list, but I would accept a reasonably worked through PR that can map family+model to a microarch.

The cpuid_data.zip can be used for testing.