This is a useful function to get the number of cores ignoring hyperthreading. So I can remove all the unportable getNumCpus()/2 in our code. I thought it might be useful upstream.
Tested on OSX 10.12, Windows 10 (should work in XP and up) & CentOS 7 (should work on all Intel linux). If it goes wrong it returns the same as getNumCpus().
** Returns numPhysicalCpus = numCpus on Android (I have no hyperthreading Android device to test)
If anyone knows how to make it work on Android (apparently some Intel chips have Hyperthreading on Android?) then that would be great.
** Untested on AMD/ARM linux
Also if anyone with Linux on AMD (not sure if any AMD processors pre-Ryzen have >1 thread per core?) then checking the implementation there would be useful too. Are there any ARM chips with >1 thread per core?