SerialParam-class | R Documentation |
This class is used to parameterize serial evaluation, primarily to facilitate easy transition from parallel to serial code.
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
)
stop.on.error |
|
progressbar |
|
RNGseed |
|
timeout |
|
log |
|
threshold |
|
logdir |
|
resultdir |
|
jobname |
|
force.GC |
|
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
.
By default all computations are attempted and partial results are returned with any error messages.
stop.on.error
A logical
. Stops all jobs as soon
as one job fails or wait for all jobs to terminate. When
FALSE
, the return value is a list of successful results
along with error messages as 'conditions'.
The bpok(x)
function returns a logical()
vector
that is FALSE for any jobs that threw an error. The input
x
is a list output from a bp*apply function such as
bplapply
or bpmapply
.
When log = TRUE
the futile.logger
package is loaded on
the workers. All log messages written in the futile.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 the outfile
argument to makeCluster
can think of log = FALSE
as
equivalent to outfile = NULL
; providing a logdir
is the
same as providing a name for outfile
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.
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
and
resultdir
fields in the constructor or with the accessors,
bplogdir
and bpresultdir
.
For MulticoreParam
, SnowParam
, and
SerialParam
, random number generation is controlled through
the RNGseed =
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 of X
, and used to seed the
random number stream for the application of FUN()
to
X[[i]]
. Thus setting RNGseed =
ensures
reproducibility across MulticoreParam()
,
SnowParam()
, and SerialParam()
, regardless of worker
or task number. The default value RNGseed = NULL
means that
each evaluation of bplapply
proceeds independently.
For details of the L'Ecuyer generator, see ?clusterSetRNGStream
.
SerialParam()
:Return an object to be used for serial evaluation of otherwise
parallel functions such as bplapply
,
bpvec
.
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.
Martin Morgan mailto:mtmorgan@fhcrc.org
getClass("BiocParallelParam")
for additional parameter classes.
register
for registering parameter classes for use in parallel
evaluation.
p <- SerialParam()
simplify2array(bplapply(1:10, sqrt, BPPARAM=p))
bpvec(1:10, sqrt, BPPARAM=p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.