I am not sure if active processors might differ from available ones and which 
OpenMP should show. According to that old document I've linked to one can first 
call:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd405486(v=vs.85).aspx

and this for every group:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd405485(v=vs.85).aspx

It seems Clang does that in z_Windows_NT_util.cpp

Counting CPUs is only one problems. You also need to take into account CPU 
groups when creating threads. The linked docs suggest using 
CreateRemoteThreadEx instead _beginthreadex. Handling affinity settings becomes 
more difficult as well (there is scatter, bind etc.). I've seen some code for 
it in Clang OpenMP source, for example:
 __kmp_affinity_bind_thread(int proc) 

It seems Clang also uses system_affinity (_kmp_get_system_affinity) which 
contains affinities for all CPU groups.
Unfortunately I am not competent enough to understand how to do it correctly 
nor suggest a patch. I have nearly 0 experience in Windows specific programming.


On Sat, Jun 16, 2018, at 8:40 AM, Liu Hao wrote:
> 在 2018/6/16 4:48, [email protected] 写道:
> > 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:
> > 
> 
> > 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.
> > 
> 
> 
> Isn't the number of logical CPU cores the `dwNumberOfProcessors` member 
> of `SYSTEM_INFO` returned by `GetNativeSystemInfo()` function? That will 
> be more reliable than popcounting the affinity mask.
> 
> [1] 
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms724381(v=vs.85).aspx
> [2] 
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
> 
> -- 
> Best regards,
> LH_Mouse

------------------------------------------------------------------------------
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

Reply via email to