diff --git a/windows/ThreadCount-Win7.cpp b/windows/ThreadCount-Win7.cpp index 387352e..7198e70 100644 --- a/windows/ThreadCount-Win7.cpp +++ b/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 @@ -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; } @@ -96,4 +106,4 @@ int main(int argc, char* argv[]) { printf("Default Thread Count: %u\n", getDefaultThreadCount()); return 0; -} \ No newline at end of file +} diff --git a/windows/ThreadCount-WinXP.cpp b/windows/ThreadCount-WinXP.cpp index 708c51c..ac5ddac 100644 --- a/windows/ThreadCount-WinXP.cpp +++ b/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 @@ -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; } @@ -93,4 +104,4 @@ int main(int argc, char* argv[]) { printf("Default Thread Count: %u\n", getDefaultThreadCount()); return 0; -} \ No newline at end of file +}