snow.cluster {StabPerf} | R Documentation |
Identifies whether a SNOW cluster (See package snow) is currently running
snow.cluster(auto=FALSE, stop=FALSE, nodes=NULL, ...)
auto |
logical. Whether cluster should be started if not currently running. |
stop |
logical. Whether a running cluster should be stopped. |
nodes |
integer. Number of nodes to start. Implies auto . |
... |
Options to pass to makeCluster |
The number of nodes actually started can be later detected by accessing the cluster object (See getCluster
).
Attempting to re-start an already-running cluster will simply return TRUE
, indicating that the cluster is already running. If you want to change the number of nodes in the cluster, you need to stop and restart it, specifying a value for nodes
upon restart.
Note: There is an error in the snow package (See makeCluster
) in exporting functions out of packages (See clusterCall
) to be run on other cluster nodes. The named function is exported, but will no longer be recognized as a package function on other cluster nodes. This means, that the function will not have access to internal package functions that are not exported, if the package uses a NAMESPACE
. A simple work-around is to only use simple wrapper functions when making cluster calls (See clusterApply
). The simple wrapper should then directly call the correct package function. This package function must, however, be exported in the NAMESPACE
of the package.
Note: other cluster nodes are run as slaves and are not aware that they are running within the cluster. This means they will not (and should not) start any parallel jobs of their own. In most cases this would lead to deadlock anyway, due to the way the SNOW library interacts with MPI.
The SNOW cluster can also be stopped by shutting down the LAM/MPI cluster upon which the SNOW cluster is running, but this is not necessarily a clean shutdown procedure and should also be used as a last recourse.
success |
logical. |
makeCluster
, lamhosts
, getCluster
, clusterApply
# Start cluster with as many nodes as possible snow.cluster(auto=TRUE) # Start cluster with 10 processors/nodes snow.cluster(nodes=TRUE) # Stop cluster snow.cluster(stop=TRUE) # Query cluster status and do something if cluster running if (snow.cluster()) { clusterApply(getCluster(), 1:10, fun, ...) }