JAGS_runtime_cluster() starts a PSOCK cluster for
parallel computation whose workers run the package builds of the calling
session, as the workers of parallel JAGS_fit() do. Packages built on
BayesTools use it for their own parallel computation.
JAGS_runtime_cluster_stop() stops such a cluster.
JAGS_runtime_cluster(
cores,
packages = "BayesTools",
runtime_setup = NULL,
options = list(),
operation = "Parallel computation"
)
JAGS_runtime_cluster_stop(cl)number of worker processes.
packages that every worker loads. Each worker must load the
same build (version, R code, and native libraries; see
JAGS_package_builds()) as the calling session.
NULL or a function of one context argument, as
in JAGS_fit(). It runs in the calling process and on every worker when
the cluster starts (context$phase "start"), and in the calling
process after the workers stopped ("finish"). The context counts one
chain per worker (context$chains equals cores).
named list of options set on every worker, in addition to
all current BayesTools.* options of the calling session; an entry
of options takes precedence over a current option of the same name.
description of the computation used in error messages.
cluster returned by JAGS_runtime_cluster().
JAGS_runtime_cluster() returns the cluster (as created by
parallel::makePSOCKcluster()), for use with the functions of the
parallel package. JAGS_runtime_cluster_stop() returns
NULL invisibly.
Workers start with Rscript --vanilla, so no user or site
startup file runs, and with the library paths of the calling session.
Setting the options precedes loading the packages. If the start fails, the
workers are stopped (and a started runtime setup finished) before the error
is signalled. JAGS_runtime_cluster_stop() stops the workers first
and then finishes the runtime setup in the calling process; further calls
have no effect.