zullil wrote:Having now found a way to toggle hyper-threading off and on, I can confirm that the code below does not work on my dual quad-core Intel 5520 Mac Pro.
The printf statement produces 16 8 8 in both cases.
Hi Louis,
thanks for testing this.
We will probably revert HT detection entirely and fall back on 1.6.3 behaviour that is not perfect but at least gives no surprises and people seems already used to it.
Making HT detection to work in all cases seems very complex: you need to add a lot of obscure code very different from what you are supposed to find in a chess engine, more similar to OS kernel code
I also take the chance to highlight that HT detection has _nothing_ to do with playing strength, crashes or other strange behavior. The only net effect is that your engine will run using less cores of what actually could run, but you can easily workaround this simply setting "threads" UCI parameters to the number of actual cores your machine has. You can do this with any GUI or even from command line.
I haven't looked at this myself, but you should be able to get a physical core count vs logical core count by deconstructing the APIC ID for each logical cpu (or x2APIC for x64).. LOGICAL_ID vs CORE_ID. Was that the route taken in Stockfish?
I agree though, not much benefit in figuring this out, just let the user do the work.
/*
* GetSysProcessorCoreCount
*
* Returns count of processor cores in the system that were enumerated by this app
*
* Arguments: None
*
* Return: Number of physical processors or 0 if number can not be calculated
*/
unsigned GetSysProcessorCoreCount()
{
if (!glbl_ptr->EnumeratedCoreCount)
InitCpuTopology();
if (glbl_ptr->error) return 0;
return glbl_ptr->EnumeratedCoreCount;
}
Only a few thousend lines of utility code behind the scene (InitCpuTopology()) to include ...