Get the number of physical cores PULL REQ


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?

Thanks Harry! Will push something shortly.

Thanks for getting that in Jules. It would be interesting to see results on the weirder platforms. If anyone has one of these JuceDemo from develop branch should give the results:

  • Android with HyperThreaded intel
  • Linux with AMD Ryzen
  • Linux with ARM (or weirder - as long as JUCE supports)