View source: R/batchtools_multicore.R
| batchtools_multicore | R Documentation |
A batchtools backend that resolves futures in parallel via forked background R processes
batchtools_multicore(
...,
workers = availableCores(constraints = "multicore"),
fs.latency = 0,
delete = getOption("future.batchtools.delete", "on-success"),
registry = list(),
finalize = getOption("future.finalize", TRUE)
)
workers |
The number of multicore processes to be
available for concurrent batchtools multicore futures.
If a single worker is requested, which is the default when only one
CPU core is available, the batchtools local backend is used instead.
It is synchronous, that is, the main R process blocks while a job is
running. To use an asynchronous batchtools multicore backend also
with a single worker, protect the number of workers using |
fs.latency |
[ |
delete |
Controls if and when the batchtools job registry folder is
deleted.
If |
registry |
(optional) A named list of settings applied to each
future's batchtools Registry.
This is a more convenient alternative to using argument |
finalize |
If TRUE, a future's batchtools Registry is automatically deleted when the future is garbage collected, otherwise not. |
... |
Not used. |
Batchtools multicore futures use batchtools cluster functions
created by batchtools::makeClusterFunctionsMulticore() with
ncpus = workers.
Since batchtools multicore futures are asynchronous, conditions, such as
progress updates signaled by the progressr package, are relayed
while the jobs are running. Note, however, that a single worker, unless
protected using base::I(), falls back to the synchronous batchtools local
backend, in which case they are relayed first when a job has finished.
An alternative to the batchtools multicore backend is to use
plan(future::multicore).
Nothing.
library(future)
plan(future.batchtools::batchtools_multicore, workers = 2)
message("Main process ID: ", Sys.getpid())
f <- future({
data.frame(
hostname = Sys.info()[["nodename"]],
os = Sys.info()[["sysname"]],
cores = unname(parallelly::availableCores()),
pid = Sys.getpid(),
modules = Sys.getenv("LOADEDMODULES")
)
})
info <- value(f)
print(info)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.