registerDoParallel function is used to register the
parallel backend with the
registerDoParallel(cl, cores=NULL, ...) stopImplicitCluster()
A cluster object as returned by
The number of cores to use for parallel execution. If not
specified, the number of cores is set to the value of
Package options. Currently, only the
parallel package from R 2.14.0 and later provides functions for
parallel execution of R code on machines with multiple cores or processors
or multiple computers. It is essentially a blend of the
multicore packages. By default, the
doParallel package uses
snow-like functionality. The
should work fine on Unix-like systems, but the
functionality is limited to a single sequential worker on Windows systems.
On workstations with multiple cores running Unix-like operating systems,
fork call is used to spawn copies of the current process.
doParallel backend supports both multicore and snow options passed
The supported multicore options are
cores, which are analogous to the similarly named
mclapply, and are passed using the
.options.multicore argument to
foreach. The supported snow options are
preschedule, which like its multicore analog can be used to chunk the
tasks so that each worker gets a prescheduled chunk of tasks, and
attachExportEnv, which can be used to attach the export environment
in certain cases where R's lexical scoping is unable to find a needed
export. The snow options are passed to
foreach using the
stopImplicitCluster can be used in vignettes and other places
where it is important to explicitly close the implicitly created cluster.
cl <- makePSOCKcluster(2) registerDoParallel(cl) m <- matrix(rnorm(9), 3, 3) foreach(i=1:nrow(m), .combine=rbind) stopCluster(cl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.