snowfall-init {snowfall} | R Documentation |
Initialisation and organisation code to use snowfall.
sfInit( parallel=NULL, cpus=NULL, nostart=FALSE ) sfStop( nostop=FALSE ) sfParallel() sfCpus() sfNodes() sfGetCluster() sfSession() sfSetMaxCPUs( number=32 )
parallel |
Logical determinating parallel or sequential execution. If not set values from commandline are taken. |
cpus |
Numerical amount of CPUs requested for the cluster. If not set, values from the commandline are taken. |
nostart |
Logical determinating if the basic cluster setup should be skipped. Needed for nested use of snowfall and usage in packages. |
nostop |
Same as noStart for ending. |
number |
Amount of maximum CPUs useable. |
sfInit
initialisise the usage of the snowfall functions
and - if running in parallel mode - setup the cluster and
snow. If using
sfCluster
management tool, call this without arguments. If
sfInit
is called with arguments, these overwrite
sfCluster
settings. If running parallel, sfInit
set up the
cluster by calling makeCluster
from snow. If using with
sfCluster
, the initialisation also contains management of
lockfiles. If this function is called more than once and current
cluster is yet running, sfStop
is called automatically.
Note that you MUST call sfInit
before using any other function
from snowfall, with the only exception sfSetMaxCPUs
.
If you use snowfall in a package argument nostart
is very
handy if mainprogram uses snowfall as well. If set, cluster
setup will be skipped and both parts (package and main program) use
the same cluster.
If you call sfInit
more than one time in a program without
explicit calling sfStop
, stopping of the cluster will be
executed automatically. If your R-environment does not cover required
libraries, sfInit
automatically switches to sequential mode
(with a warning). Required libraries for parallel usage are snow
and Rmpi.
Note there is limit on CPUs used in one program (which can be
configured on package installation). The current limit are 32 CPUs. If
you need a higher amount of CPUs, call sfSetMaxCPUs
before the first call to sfInit
. The limit is set to
prevent inadvertently request by single users affecting the cluster as
a whole.
sfStop
stop cluster. If running in parallel mode, the LAM/MPI
cluster is shut down.
sfParallel
, sfCpus
and sfSession
grant access to
the internal state of the currently used cluster.
All three can be configured via commandline and especially with
sfCluster
as well, but given
arguments in sfInit
always overwrite values on commandline.
The commandline options are --parallel (empty option. If missing,
sequential mode is forced), --cpus=X (for nodes, where X is a
numerical value) and --session=X (with X a string).
sfParallel
returns a
logical if program is running in parallel/cluster-mode or sequential
on a single processor.
sfCpus
returns the size of the cluster in CPUs
(equals the CPUs which are useable). In sequential mode sfCpus
returns one. sfNodes
is a deprecated similar to sfCpus
.
sfSession
returns a string with the
session-identification. It is mainly important if used with the
sfCluster
tool.
sfGetCluster
gets the snow-cluster handler. Use for
direct calling of snow functions.
sfSetMaxCPUs
enables to set a higher maximum CPU-count for this
program. If you need higher limits, call sfSetMaxCPUs
before
sfInit
with the new maximum amount.
See snow documentation for details on commands:
snow
## Not run: # Run program in plain sequential mode. sfInit( parallel=FALSE ) stopifnot( sfParallel() == FALSE ) sfStop() # Run in parallel mode overwriting probably given values on # commandline. Hooks in running LAM cluster, if none is running, # snow is spawning one on localhost. sfInit( parallel=TRUE, nodes=10 ) stopifnot( sfCpus() == 10 ) stopifnot( sfParallel() == TRUE ) sfStop() # Run in sfCluster-mode: settings are taken from commandline. sfInit() # Session-ID from sfCluster (or XXXXXXXX as default) session <- sfSession() # Calling a snow function: cluster handler needed. parLapply( sfGetCluster(), 1:10, exp ) # Same using snowfall wrapper, no handler needed. sfLapply( 1:10, exp ) sfStop() ## End(Not run)