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

Use logical count for everything newer than dozer #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 6 additions & 4 deletions windows/ThreadCount-Win7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
8 changes: 5 additions & 3 deletions windows/ThreadCount-WinXP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, maybe not this..

printf("Processor Module Count: %u\n", logical / 2);
printf("Processor Core Count: %u\n", logical);
}
Expand Down