| 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.errorAlogical. 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 inputxis a list output from a bp*apply function such asbplapplyorbpmapply.
-
- logging:
-
When
log = TRUEthefutile.loggerpackage is loaded on the workers. All log messages written in thefutile.loggerformat 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 = TRUEthese are diverted to the log output. Those familiar with theoutfileargument tomakeClustercan think oflog = FALSEas equivalent tooutfile = NULL; providing alogdiris the same as providing a name foroutfileexcept 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.
- 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
logdirandresultdirfields in the constructor or with the accessors,bplogdirandbpresultdir. - 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 = NULLmeans that each evaluation ofbplapplyproceeds 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)