SerialParam-class {BiocParallel} | R Documentation |
Enable serial evaluation
Description
This class is used to parameterize serial evaluation, primarily to facilitate easy transition from parallel to serial code.
Usage
SerialParam(
stop.on.error = TRUE,
progressbar = FALSE,
RNGseed = NULL,
timeout = WORKER_TIMEOUT,
log = FALSE,
threshold = "INFO",
logdir = NA_character_,
resultdir = NA_character_,
jobname = "BPJOB",
force.GC = FALSE
)
Arguments
stop.on.error |
|
progressbar |
|
RNGseed |
|
timeout |
|
log |
|
threshold |
|
logdir |
|
resultdir |
|
jobname |
|
force.GC |
|
Details
SerialParam
is used for serial computation on a single
node. Using SerialParam
in conjunction with bplapply
differs from use of lapply
because it provides features such as
error handling, logging, and random number use consistent with
SnowParam
and MulticoreParam
.
- error handling:
-
By default all computations are attempted and partial results are returned with any error messages.
-
stop.on.error
Alogical
. Stops all jobs as soon as one job fails or wait for all jobs to terminate. WhenFALSE
, the return value is a list of successful results along with error messages as 'conditions'. The
bpok(x)
function returns alogical()
vector that is FALSE for any jobs that threw an error. The inputx
is a list output from a bp*apply function such asbplapply
orbpmapply
.
-
- logging:
-
When
log = TRUE
thefutile.logger
package is loaded on the workers. All log messages written in thefutile.logger
format are captured by the logging mechanism and returned real-time (i.e., as each task completes) instead of after all jobs have finished.Messages sent to stdout and stderr are returned to the workspace by default. When
log = TRUE
these are diverted to the log output. Those familiar with theoutfile
argument tomakeCluster
can think oflog = FALSE
as equivalent tooutfile = NULL
; providing alogdir
is the same as providing a name foroutfile
except that BiocParallel writes a log file for each task.The log output includes additional statistics such as memory use and task runtime. Memory use is computed by calling gc(reset=TRUE) before code evaluation and gc() (no reseet) after. The output of the second gc() call is sent to the log file. There are many ways to track memory use - this particular approach was taken because it is consistent with how the BatchJobs package reports memory on the workers.
- log and result files:
-
Results and logs can be written to a file instead of returned to the workspace. Writing to files is done from the master as each task completes. Options can be set with the
logdir
andresultdir
fields in the constructor or with the accessors,bplogdir
andbpresultdir
. - random number generation:
-
For
MulticoreParam
,SnowParam
, andSerialParam
, random number generation is controlled through theRNGseed =
argument. BiocParallel uses the L'Ecuyer-CMRG random number generator described in the parallel package to generate independent random number streams. One stream is associated with each element ofX
, and used to seed the random number stream for the application ofFUN()
toX[[i]]
. Thus settingRNGseed =
ensures reproducibility acrossMulticoreParam()
,SnowParam()
, andSerialParam()
, regardless of worker or task number. The default valueRNGseed = NULL
means that each evaluation ofbplapply
proceeds independently.For details of the L'Ecuyer generator, see ?
clusterSetRNGStream
.
Constructor
-
SerialParam()
:Return an object to be used for serial evaluation of otherwise parallel functions such as
bplapply
,bpvec
.
Methods
The following generics are implemented and perform as documented on
the corresponding help page (e.g., ?bpworkers
):
bpworkers
. bpisup
, bpstart
,
bpstop
, are implemented, but do not have any
side-effects.
Author(s)
Martin Morgan mailto:mtmorgan@fhcrc.org
See Also
getClass("BiocParallelParam")
for additional parameter classes.
register
for registering parameter classes for use in parallel
evaluation.
Examples
p <- SerialParam()
simplify2array(bplapply(1:10, sqrt, BPPARAM=p))
bpvec(1:10, sqrt, BPPARAM=p)
## Not run:
register(SerialParam(), default=TRUE)
## End(Not run)