The current functions are little helpers to make cluster programming
easier.
All of these functions also work in sequential mode without any
further code changes.
sfLibrary
loads an R-package on all nodes, including
master. Use this function if slaves need this library,
too. Parameters are identically to the R-build in funtion
library
. If a relative path is given in lib.loc
,
it is converted to an absolute path.\
As default sfLibrary
stops on any error, but this can be
prevented by setting stopOnError=FALSE
, the function is returning
FALSE
then. On success TRUE
is returned.
sfSource
loads a sourcefile on all nodes, including master. Use
this function if the slaves need the code as well. Make sure the file
is accessible on all nodes under the same path. The loading is done
on slaves using source
with fixes parameters:
local=FALSE, chdir=FALSE, echo=FALSE
, so the files is loaded
global without changing of directory.\
As default sfSource
stops on any error, but this can be
prevented by setting stopOnError=FALSE
, the function is returning
FALSE
then. On success TRUE
is returned.
sfExport
exports variables from the master to all
slaves. Use this function if slaves need acccess to these variables as
well. sfExport
features two execution modes: local and global.
If using local mode (default), variables for export are searched
backwards from current environment to globalenv()
. Use this mode
if you want to export local variables from functions or other
scopes to the slaves. In global mode only global variables from master
are exported.\
Note: all exported variables are global on the slaves!\
If you have many identical named variables in different scopes, use
argument debug=TRUE
to view the context the exported variable
is coming from.\
Variables are given as their names or as a
character vector with their names using argument list
.
sfExportAll
exports all global variables from the master to all
slaves with exception of the
given list. Use this functions if you want to export mostly all
variables to all slaves.\Argument list
is a character vector
with names of the variables not to export.
sfRemove
removes a list of global (previous exported or
generated) variables from slaves and (optional) master.
Use this function if there are large further unused variables
left on slave. Basically this is only interesting if you have more than
one explicit parallel task in your program - where the danger is slaves
memory usage exceed.\
If argument master
is given, the variables are removed from
master as well (default is FALSE).\
Give names of variables as arguments, or use argument list
as a character vector with the names. For deep cleaning of slave
memory use sfRemoveAll
.
sfRemoveAll
removes all global variables from the slaves. Use
this functions if you want to remove mostly all
variables on the slaves. Argument list
is a character vector
with names of the variables not to remove.
sfCat
is a debugging function printing a message on all slaves
(which appear in the logfiles).
sfClusterSplit
splits a vector into one consecutive piece for
each cluster and returns as a list with length equal to the number of
cluster nodes. Wrapper for snow function clusterSplit
.
sfClusterCall
calls a function on each node and returns list of
results. Wrapper for snow function clusterCall
.
sfClusterEvalQ
evaluates a literal expression on all
nodes. Wrapper for snow function clusterEvalQ
.
sfTest
is a simple unit-test for most of the build in functions.
It runs tests and compares the results for the correct behavior. Note
there are some warnings if using, this is intended (as behavior for
some errors is tested, too). use this if you are not sure all nodes are
running your R-code correctly (but mainly it is implemented for
development).