Create a rbmi ready cluster
Arguments
- ncores
Number of parallel processes to use or an existing cluster to make use of
- objects
a named list of objects to export into the sub-processes
- packages
-
a character vector of libraries to load in the sub-processes
This function is a wrapper around
parallel::makePSOCKcluster()but takes care of configuringrbmito be used in the sub-processes as well as loading user defined objects and libraries and setting the seed for reproducibility.If
ncoresis1this function will returnNULL.If
ncoresis a cluster created viaparallel::makeCluster()then this function just takes care of inserting the relevantrbmiobjects into the existing cluster.
Value
A parallel socket cluster object (as created by
parallel::makePSOCKcluster()) configured for use with rbmi, or NULL if
ncores = 1. When ncores is an existing cluster it is returned with the
required rbmi objects and libraries loaded into it.
Examples
if (FALSE) { # \dontrun{
# Basic usage
make_rbmi_cluster(5)
# User objects + libraries
VALUE <- 5
myfun <- function(x) {
x + day(VALUE) # From lubridate::day()
}
make_rbmi_cluster(5, list(VALUE = VALUE, myfun = myfun), c("lubridate"))
# Using a already created cluster
cl <- parallel::makeCluster(5)
make_rbmi_cluster(cl)
} # }
