Skip to content

Commit

Permalink
Updated getDefaultThreadCount() to better represent other vendor posi…
Browse files Browse the repository at this point in the history
…tions on SMT for gaming
  • Loading branch information
Rys Sommefeldt committed Sep 27, 2017
1 parent 48177af commit 49a6e73
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
22 changes: 16 additions & 6 deletions windows/ThreadCount-Win7.cpp
@@ -1,4 +1,6 @@
// GetLogicalProcessorInformationEx requires Win7
// This advice is specific to AMD processors and is not general guidance for all processor manufacturers.
//
// GetLogicalProcessorInformationEx requires Win7 or later
// based on https://msdn.microsoft.com/en-us/library/windows/desktop/dd405488(v=vs.85).aspx

#include <stdio.h>
Expand Down Expand Up @@ -61,15 +63,23 @@ int getCpuidFamily() {
return displayFamily;
}

// This advice is specific to AMD processors and is
// not general guidance for all processor
// manufacturers. Remember to profile!
DWORD getDefaultThreadCount() {
DWORD cores, logical;
getProcessorCount(cores, logical);
DWORD count = cores;
DWORD count = logical;
char vendor[13];
getCpuidVendor(vendor);
if ((0 == strcmp(vendor, "AuthenticAMD")) && (0x15 == getCpuidFamily())) {
// AMD "Bulldozer" family microarchitecture
count = logical;
if (0 == strcmp(vendor, "AuthenticAMD")) {
if (0x15 == getCpuidFamily()) {
// AMD "Bulldozer" family microarchitecture
count = logical;
}
else {
count = cores;
}
}
return count;
}
Expand All @@ -96,4 +106,4 @@ int main(int argc, char* argv[]) {
printf("Default Thread Count: %u\n", getDefaultThreadCount());

return 0;
}
}
21 changes: 16 additions & 5 deletions windows/ThreadCount-WinXP.cpp
@@ -1,3 +1,6 @@
// This advice is specific to AMD processors and is not general guidance for all processor manufacturers.
//
// GetLogicalProcessorInformation requires WinXP or later
// based on https://msdn.microsoft.com/en-us/library/windows/desktop/ms683194(v=vs.85).aspx

#include <intrin.h>
Expand Down Expand Up @@ -58,15 +61,23 @@ int getCpuidFamily() {
return displayFamily;
}

// This advice is specific to AMD processors and is
// not general guidance for all processor
// manufacturers. Remember to profile!
DWORD getDefaultThreadCount() {
DWORD cores, logical;
getProcessorCount(cores, logical);
DWORD count = cores;
DWORD count = logical;
char vendor[13];
getCpuidVendor(vendor);
if ((0 == strcmp(vendor, "AuthenticAMD")) && (0x15 == getCpuidFamily())) {
// AMD "Bulldozer" family microarchitecture
count = logical;
if (0 == strcmp(vendor, "AuthenticAMD")) {
if (0x15 == getCpuidFamily()) {
// AMD "Bulldozer" family microarchitecture
count = logical;
}
else {
count = cores;
}
}
return count;
}
Expand All @@ -93,4 +104,4 @@ int main(int argc, char* argv[]) {
printf("Default Thread Count: %u\n", getDefaultThreadCount());

return 0;
}
}

0 comments on commit 49a6e73

Please sign in to comment.