From 2d542945ea504e69652df161f9c48a5c07024a17 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Sun, 13 Dec 2020 19:23:45 +0800 Subject: [PATCH 1/2] Use logical count for everything newer than dozer --- windows/ThreadCount-Win7.cpp | 10 ++++++---- windows/ThreadCount-WinXP.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/windows/ThreadCount-Win7.cpp b/windows/ThreadCount-Win7.cpp index 7198e70..3df314a 100644 --- a/windows/ThreadCount-Win7.cpp +++ b/windows/ThreadCount-Win7.cpp @@ -73,8 +73,10 @@ DWORD getDefaultThreadCount() { char vendor[13]; getCpuidVendor(vendor); if (0 == strcmp(vendor, "AuthenticAMD")) { - if (0x15 == getCpuidFamily()) { - // AMD "Bulldozer" family microarchitecture + if (0x15 <= getCpuidFamily()) { + // AMD "Bulldozer" family microarchitecture or newer + // Jaguar does not have SMT, and Zen SMT is no worse than Bulldozer + // MAINTAINER: remember to update if SMT ever gets bad! count = logical; } else { @@ -92,8 +94,8 @@ int main(int argc, char* argv[]) { DWORD cores, logical; getProcessorCount(cores, logical); - if ((0 == strcmp(vendor, "AuthenticAMD")) && (0x15 == getCpuidFamily())) { - // AMD "Bulldozer" family microarchitecture + if ((0 == strcmp(vendor, "AuthenticAMD")) && (0x15 <= getCpuidFamily())) { + // AMD "Bulldozer" family microarchitecture or newer printf("Processor Module Count: %u\n", logical / 2); printf("Processor Core Count: %u\n", logical); } diff --git a/windows/ThreadCount-WinXP.cpp b/windows/ThreadCount-WinXP.cpp index ac5ddac..933099b 100644 --- a/windows/ThreadCount-WinXP.cpp +++ b/windows/ThreadCount-WinXP.cpp @@ -72,7 +72,9 @@ DWORD getDefaultThreadCount() { getCpuidVendor(vendor); if (0 == strcmp(vendor, "AuthenticAMD")) { if (0x15 == getCpuidFamily()) { - // AMD "Bulldozer" family microarchitecture + // AMD "Bulldozer" family microarchitecture or newer + // Jaguar does not have SMT, and Zen SMT is no worse than Bulldozer + // MAINTAINER: remember to update if SMT ever gets bad! count = logical; } else { @@ -90,8 +92,8 @@ int main(int argc, char* argv[]) { DWORD cores, logical; getProcessorCount(cores, logical); - if ((0 == strcmp(vendor, "AuthenticAMD")) && (0x15 == getCpuidFamily())) { - // AMD "Bulldozer" family microarchitecture + if ((0 == strcmp(vendor, "AuthenticAMD")) && (0x15 <= getCpuidFamily())) { + // AMD "Bulldozer" family microarchitecture or newer printf("Processor Module Count: %u\n", logical / 2); printf("Processor Core Count: %u\n", logical); } From c23d83dd2c3bab8d09b51bf121cf441ace59fcf6 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Sun, 13 Dec 2020 19:30:34 +0800 Subject: [PATCH 2/2] README: Add useful links we should tell people why this matters at all --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7901095..cf64712 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,8 @@ These self-contained code samples show you how to correctly detect physical and ## Support and suggestions If you spot a bug, or would like to see the samples evolve in a particular way, file an issue and we'll take a look! + +## Further reading + +- Ken Mitchell (2017). [CPU Core Count Detection on Windows®](https://gpuopen.com/learn/cpu-core-count-detection-windows/). *GPUOpen*. +- Ken Mitchell, Elliot Kim (2018). [AMD Ryzen™ CPU Optimization](https://gpuopen.com/wp-content/uploads/2018/05/gdc_2018_sponsored_optimizing_for_ryzen.pdf). Presented on GDC 2018.