Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix threadsPerCore check for Zen 2 (AMD) #149

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cpuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,16 @@ func threadsPerCore() int {
_, b, _, _ := cpuidex(0xb, 0)
if b&0xffff == 0 {
if vend == AMD {
// Workaround for AMD returning 0, assume 2 if >= Zen 2
// It will be more correct than not.
// if >= Zen 2 0x8000001e EBX 15-8 bits means threads per core.
// The number of threads per core is ThreadsPerCore+1
// See PPR for AMD Family 17h Models 00h-0Fh (page 82)
fam, _, _ := familyModel()
_, _, _, d := cpuid(1)
if (d&(1<<28)) != 0 && fam >= 23 {
if maxExtendedFunction() >= 0x8000001e {
_, b, _, _ := cpuid(0x8000001e)
return int((b>>8)&0xff) + 1
}
return 2
}
}
Expand Down
Loading