JoshAdel's answer is correct: Base.CPU_CORES stores the number of available cores, including virtual ones.
I am adding this answer to mark an alternative: using the Hwloc package. From the project description
This Julia package wraps the hwloc library.
The Portable Locality (hwloc) software package provides portable abstractions (via the OS, versions, architectures, ...) of the hierarchical topology of modern architectures, including NUMA memory nodes, sockets, shared caches, cores, and simultaneous multithreading. It also collects various system attributes, such as information cache and memory, as well as the location of I / O devices, such as network interfaces, InfiniBand HCA, or GPUs. First of all, these are applications with the collection of information about modern computing in order to use it accordingly and effectively.
Also on the project page, a method for obtaining the number of physical cores and {physical, virtual} cores (that is, processing units) is as follows:
import Hwloc topology = Hwloc.topology_load() counts = Hwloc.histmap(topology) ncores = counts[:Core] npus = counts[:PU] println("This machine has $ncores cores and $npus PUs (processing units)")
The advantage of using this package is its portable ability to distinguish between physical and virtual kernels, which is currently not available in Julia. There is, however, a petition to include this ability in the language base.
Pablo
source share