parallelly (version 1.21.0)

availableWorkers: Get Set of Available Workers

Description

Get Set of Available Workers

Usage

availableWorkers(
  methods = getOption2("future.availableWorkers.methods", c("mc.cores",
    "_R_CHECK_LIMIT_CORES_", "PBS", "SGE", "Slurm", "LSF", "custom", "system",
    "fallback")),
  na.rm = TRUE,
  default = "localhost",
  which = c("auto", "min", "max", "all")
)

Arguments

methods

A character vector specifying how to infer the number of available cores.

na.rm

If TRUE, only non-missing settings are considered/returned.

default

The default set of workers.

which

A character specifying which set / sets to return. If "auto", the first non-empty set found. If "min", the minimum value is returned. If "max", the maximum value is returned (be careful!) If "all", all values are returned.

Value

Return a character vector of workers, which typically consists of names of machines / compute nodes, but may also be IP numbers.

Details

The default set of workers for each method is rep("localhost", times = availableCores(method)), which means that each will at least use as many parallel workers on the current machine that availableCores() allows for that method.

In addition, the following settings ("methods") are also acknowledged:

  • "PBS" - Query TORQUE/PBS environment variable PBS_NODEFILE. If this is set and specifies an existing file, then the set of workers is read from that file, where one worker (node) is given per line. An example of a job submission that results in this is qsub -l nodes = 4:ppn = 2, which requests four nodes each with two cores.

  • "SGE" - Query Sun/Oracle Grid Engine (SGE) environment variable PE_HOSTFILE. An example of a job submission that results in this is qsub -pe mpi 8 (or qsub -pe ompi 8), which requests eight cores on a any number of machines.

  • "LSF" - Query LSF/OpenLava environment variable LSB_HOSTS.

  • "custom" - If option future.availableWorkers.custom is set and a function, then this function will be called (without arguments) and it's value will be coerced to a character vector, which will be interpreted as hostnames of available workers.

See Also

To get the number of available workers on the current machine, see availableCores().

Examples

Run this code
# NOT RUN {
message(paste("Available workers:",
        paste(sQuote(availableWorkers()), collapse = ", ")))

# }
# NOT RUN {
options(mc.cores = 2L)
message(paste("Available workers:",
        paste(sQuote(availableWorkers()), collapse = ", ")))
# }
# NOT RUN {
# }
# NOT RUN {
## Always use two workers on host 'n1' and one on host 'n2'
options(parallelly.availableWorkers.custom = function() {
  c("n1", "n1", "n2")
})
message(paste("Available workers:",
        paste(sQuote(availableWorkers()), collapse = ", ")))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab