guessCores: Guesses a number of CPU to use for parallel calls

Description Usage Arguments Details Value Examples

View source: R/guessCores.R

Description

First checks the environment variable NCPUS. This will typically be set in PBS jobs to the number of cores assigned to the job. Otherwise, it will use the number of CPUs with detectCores. If that fails or returns more than 12 cores, it will go back to 1 (as this is indicative that the job is being run on a supercomputer but without the NCPUS properly set).

Usage

1
guessCores(verbose = TRUE, max = NULL)

Arguments

verbose

show the number of cores that was guessed.

max

limit the number of cores. Ignored if NCPUS was set.

Details

This function is especially useful for use with makeCluster.

Value

a number of cores to use

Examples

1
2
3
4
5
6
ncpus <- guessCores(max = 2)
# With the parallel package
library(parallel)
cl = makeCluster(ncpus)
parLapply(cl = cl, 1:ncpus, log)
stopCluster(cl)

xrobin/xavamess documentation built on June 15, 2021, 3:46 a.m.