[R-SIG-Mac] detecting cores

Mikko Korpela mikko.korpela at aalto.fi
Fri Feb 5 15:44:36 CET 2016


On 05.02.2016 14:07, Prof Brian Ripley wrote:
> sysctl on 10.11 has options which would enable us to differentiate
> between logical and physical codes on parallel::detectCores --- however
> these are not documented in Apple's online man pages, which are for
> 10.9.  Could someone running 10.9 and someone for 10.10 report if
> 
> /usr/sbin/sysctl -n hw.physicalcpu
> /usr/sbin/sysctl -n hw.logicalcpu
> 
> run in a terminal work and gives the correct result?  (Normally the
> second will be twice the first taking account of hyperthreading.)
Here is the output for an older OS X version, 10.7.5. The computer has a
dual core processor without hyperthreading. Also included is the listing
of all sysctl variable names that begin with "hw." and are followed by
something with "cpu".

The man page about the command line tool, sysctl(8), does not mention
hw.physicalcpu or hw.logicalcpu. However, the variables are listed on
the man page sysctl(3), which is about the underlying C functions. The
latter man page was apparently installed with the XCode Command Line
Tools package. Therefore I have also printed its version number.

$ /usr/sbin/sysctl -n hw.physicalcpu
2
$ /usr/sbin/sysctl -n hw.logicalcpu
2
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.7.5
BuildVersion:	11G63
$ /usr/sbin/sysctl -a | grep "hw\\..*cpu" | sed 's/[: ].*//'
hw.ncpu
hw.cpufrequency
hw.availcpu
hw.ncpu
hw.activecpu
hw.physicalcpu
hw.physicalcpu_max
hw.logicalcpu
hw.logicalcpu_max
hw.cputype
hw.cpusubtype
hw.cpu64bit_capable
hw.cpufamily
hw.cpufrequency
hw.cpufrequency_min
hw.cpufrequency_max
$ pkgutil --pkg-info=com.apple.pkg.DeveloperToolsCLI | grep version
version: 4.6.0.0.1.1365549073

-- 
Mikko Korpela
Aalto University School of Science
Department of Computer Science



More information about the R-SIG-Mac mailing list