Does anyone know how to query the number of physical cores from MATLAB? I would like to get the number of physical, not logical, cores (which may vary when the hyper-thread is turned on).
I need a method for cross-platform (Windows and Linux, not caring about Mac), but I would be happy to use two separate methods with an operator switchbased on output computer.
So far I have tried:
java.lang.Runtime.getRuntime().availableProcessorsSystem.Environment.ProcessorCount!wmic cpu get NumberOfCoresand !wmic cpu get NumberOfLogicalProcessors.
1 is cross-platform, but returns the number of logical rather than physical processors.
2 - Windows only, and also returns logical, not physical processors.
3 gives both physical and logical processors, but it is also only Windows, and although I can successfully use it from the DOS command prompt window, for some reason it seems to hang forever when it starts with MATLAB.
source
share