availableCores(constraints = NULL, methods = getOption("future.availableCores.methods", c("system", "mc.cores+1", "_R_CHECK_LIMIT_CORES_", "PBS", "SGE", "Slurm")), na.rm = TRUE, default = c(current = 1L), which = c("min", "max", "all"))constrains="multicore" will force a
single core to be reported."min", the minimum value is returned.
If "max", the maximum value is returned (be careful!)
If "all", all values are returned.which="all", then more than one value may be returned.
Together with na.rm=FALSE missing values may also be returned.
availableCores(methods="system"). This can be
done by first specifying
options(future.availableCores.methods="mc.cores+1") and
then the number of cores to use (in addition to the main R process),
e.g. options(mc.cores=8) will cause the value of
availableCores() to be 9 (=8+1).
Having said this, it is almost always better to do this by explicitly
setting the number of workers when specifying the future strategy,
e.g. plan(multiprocess, workers=9)."system" -
Query detectCores().
"mc.cores+1" -
If available, returns the value of option
mc.cores + 1.
Note that mc.cores is defined as the number of
additional R processes that can be used in addition to the
main R process. This means that with mc.cores=0 all
calculations should be done in the main R process, i.e. we have
exactly one core available for our calculations.
The mc.cores option defaults to environment variable
MC_CORES (and is set accordingly when the parallel
package is loaded). The mc.cores option is used by for
instance mclapply().
"PBS" -
Query Torque/PBS environment variable PBS_NUM_PPN.
Depending on PBS system configuration, this resource parameter
may or may not default to one. It can be specified when submitting
a job as in, for instance, qsub -l nodes=4:ppn=2, which
requests four nodes each with two cores.
"SGE" -
Query Sun/Oracle Grid Engine (SGE) environment variable
NSLOTS.
It can be specified when submitting a job as in, for instance,
qsub -pe by_node 2, which two cores on a single machine.
"Slurm" -
Query Simple Linux Utility for Resource Management (Slurm)
environment variable SLURM_CPUS_PER_TASK.
This may or may not be set. It can be set when submitting a job,
e.g. sbatch --cpus-per-task=2 hello.sh or by adding
#SBATCH --cpus-per-task=2 to the `hello.sh` script.
For any other value of a methods element, the R option with the
same name is queried. If that is not set, the system environment
variable is queried. If neither is set, a missing value is returned.