Hello all,
As of right now GCC with MinGW-w64 doesn't support more than 64 logical CPUs on
Windows.
I've looked into the source. In mingw-w64-libraries\winpthreads\src\thread.c
three is a function:
/* Compatibility routine for pthread-win32. It returns the
amount of available CPUs on system. */
int
pthread_num_processors_np(void)
{
int r = 0;
DWORD_PTR ProcessAffinityMask, SystemAffinityMask;
if (GetProcessAffinityMask(GetCurrentProcess(), &ProcessAffinityMask,
&SystemAffinityMask))
{
for(; ProcessAffinityMask != 0; ProcessAffinityMask >>= 1)
r += (ProcessAffinityMask & 1) != 0;
}
/* assume at least 1 */
return r ? r : 1;
}
This is incorrect way of counting CPUs on Windows (starting from Windows 7) as
GetProcessAffinityMask returns a mask for current CPU group for the process and
not for all CPUs on the system. This means that a process can only work within
64CPUs limit. If a system has more than 64 logical CPUs for example a dualbox
Xeon system 2x24 it means CPUs are spread into 2 groups of 48 each (because of
hyperthreading). This means that on such a system the program will only be able
to use 48 logical CPUs (24cores with hyperthreading, leaving 2nd CPU completely
idle)
Some resources from microsoft:
https://blogs.technet.microsoft.com/hardtofind/2018/01/29/windows-server-with-more-than-64-logical-processors/
https://msdn.microsoft.com/en-us/library/dd405527(VS.85).aspx
I've also filled a bug on GCC bugzilla, here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86146
Clang (up to 5.0.2 anyway as in 6.0 OpenMP is no longer included on Windows
distribution) counts CPUs correctly. The code is in:
void __kmp_affinity_entire_machine_mask(kmp_affin_mask_t *mask)
function.
I realize there aren't many people who develop applications which meet all the
criteria:
1)developed and mainly run on Windows
2)in C but not under Visual Studio
3)performance critical and being able to use more than 32 physical cores
so that is unlikely to be a priority. I am willing to pay for the development
if there is some mechanism supporting it.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public