| 56599 |
ripley |
1 |
% File src/library/parallel/man/makePSOCKcluster.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 61974 |
ripley |
3 |
% Copyright 2003-13 R Core Team
|
| 56599 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 57939 |
hornik |
6 |
\newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
|
|
|
7 |
|
| 56646 |
ripley |
8 |
\name{makeCluster}
|
|
|
9 |
\alias{makeCluster}
|
| 56599 |
ripley |
10 |
\alias{makePSOCKcluster}
|
| 56646 |
ripley |
11 |
\alias{makeForkCluster}
|
| 56643 |
ripley |
12 |
\alias{stopCluster}
|
| 57336 |
ripley |
13 |
\alias{setDefaultCluster}
|
| 56599 |
ripley |
14 |
\title{
|
|
|
15 |
Create a Parallel Socket Cluster
|
|
|
16 |
}
|
|
|
17 |
\description{
|
|
|
18 |
Creates a set of copies of \R running in parallel and communicating
|
|
|
19 |
over sockets.
|
|
|
20 |
}
|
|
|
21 |
\usage{
|
| 56646 |
ripley |
22 |
makeCluster(spec, type, ...)
|
| 56599 |
ripley |
23 |
makePSOCKcluster(names, ...)
|
| 56646 |
ripley |
24 |
makeForkCluster(nnodes = getOption("mc.cores", 2L), ...)
|
| 56643 |
ripley |
25 |
|
| 57335 |
ripley |
26 |
stopCluster(cl = NULL)
|
|
|
27 |
|
| 57336 |
ripley |
28 |
setDefaultCluster(cl = NULL)
|
| 56599 |
ripley |
29 |
}
|
|
|
30 |
\arguments{
|
| 56646 |
ripley |
31 |
\item{spec}{A specification appropriate to the type of cluster.}
|
| 56650 |
hornik |
32 |
\item{names}{Either a character vector of host names on which to run
|
| 57312 |
ripley |
33 |
the worker copies of \R, or a positive integer (in which case
|
| 56599 |
ripley |
34 |
that number of copies is run on \samp{localhost}).}
|
| 57380 |
ripley |
35 |
\item{nnodes}{The number of nodes to be forked.}
|
| 56646 |
ripley |
36 |
\item{type}{One of the supported types: see \sQuote{Details}.}
|
| 56599 |
ripley |
37 |
\item{\dots}{Options to be passed to the function spawning the workers.
|
| 57380 |
ripley |
38 |
See \sQuote{Details}.}
|
| 56644 |
ripley |
39 |
\item{cl}{an object of class \code{"cluster"}.}
|
| 56599 |
ripley |
40 |
}
|
|
|
41 |
\details{
|
| 56646 |
ripley |
42 |
\code{makeCluster} creates a cluster of one of the supported types.
|
|
|
43 |
The default type, \code{"PSOCK"}, calls \code{makePSOCKcluster}. Type
|
| 58219 |
ripley |
44 |
\code{"FORK"} calls \code{makeForkCluster}. Other types are passed to
|
| 57939 |
hornik |
45 |
package \CRANpkg{snow}.
|
| 61433 |
ripley |
46 |
|
| 56646 |
ripley |
47 |
\code{makePSOCKcluster} is very similar to \code{makeSOCKcluster} in
|
| 57939 |
hornik |
48 |
package \CRANpkg{snow}. It runs \command{Rscript} on the specified
|
| 56646 |
ripley |
49 |
host(s) to set up a worker process which listens on a socket for
|
|
|
50 |
expressions to evaluate, and returns the results (as serialized
|
|
|
51 |
objects).
|
| 56599 |
ripley |
52 |
|
| 57378 |
ripley |
53 |
\code{makeForkCluster} is merely a stub on Windows. On Unix-alike
|
|
|
54 |
platforms it creates the worker process by forking.
|
| 61433 |
ripley |
55 |
|
| 56599 |
ripley |
56 |
The workers are most often running on the same host as the master,
|
|
|
57 |
when no options need be set.
|
|
|
58 |
|
| 57378 |
ripley |
59 |
Several options are supported (mainly for \code{makePSOCKcluster}):
|
| 56599 |
ripley |
60 |
\describe{
|
| 57641 |
ripley |
61 |
\item{\code{master}}{The host name of the master, as known to the
|
|
|
62 |
workers. This may not be the same as it is known to the master,
|
|
|
63 |
and on private subnets it may be necessary to specify this as a
|
| 62602 |
ripley |
64 |
numeric IP address. For example, OS X is likely to detect a
|
| 57641 |
ripley |
65 |
machine as \samp{somename.local}, a name known only to itself.}
|
| 56599 |
ripley |
66 |
\item{\code{port}}{The port number for the socket connection,
|
| 56621 |
ripley |
67 |
default taken from the environment variable \env{R_PARALLEL_PORT},
|
| 61974 |
ripley |
68 |
then a randomly chosen port in the range \code{11000:11999}.}
|
| 56599 |
ripley |
69 |
\item{\code{timeout}}{The timeout in seconds for that port. Default
|
| 57376 |
ripley |
70 |
30 days (and the POSIX standard only requires values up to 31 days
|
|
|
71 |
to be supported).}
|
| 57380 |
ripley |
72 |
\item{\code{outfile}}{Where to direct the \code{\link{stdout}} and
|
|
|
73 |
\code{\link{stderr}} connection output from the workers.
|
|
|
74 |
\code{""} indicates no redirection (which may only be useful for
|
| 61433 |
ripley |
75 |
workers on the local machines).
|
| 57380 |
ripley |
76 |
Defaults to \file{/dev/null} (\file{nul:} on Windows). The other
|
|
|
77 |
possibility is a file path on the worker's host.
|
|
|
78 |
Files will be opened in append mode, as all workers log to the
|
| 61433 |
ripley |
79 |
same file.}
|
| 56599 |
ripley |
80 |
\item{\code{homogeneous}}{Logical. Are all the hosts running
|
|
|
81 |
identical setups, so \command{Rscript} can be launched using its
|
|
|
82 |
full path on the master? Otherwise it has to be in the default
|
|
|
83 |
path on the other hosts.}
|
| 56621 |
ripley |
84 |
\item{\code{rscript}}{The path to \command{Rscript} on the workers.
|
| 56599 |
ripley |
85 |
Defaults to the full path on the master.}
|
| 56656 |
ripley |
86 |
\item{\code{renice}}{A numerical \sQuote{niceness} to set for the
|
|
|
87 |
worker processes, e.g.{} \code{15} for a low priority.
|
| 57312 |
ripley |
88 |
OS-dependent: see \code{\link{psnice}} for details.}
|
| 56599 |
ripley |
89 |
\item{\code{rshcmd}}{The command to be run on the master to launch a
|
|
|
90 |
process on another host. Defaults to \command{ssh}.}
|
|
|
91 |
\item{\code{user}}{The user name to be used when communicating with
|
|
|
92 |
another host.}
|
|
|
93 |
\item{\code{manual}}{Logical. If true the workers will need to be
|
| 56646 |
ripley |
94 |
run manually.}
|
| 56649 |
ripley |
95 |
\item{\code{methods}}{Logical. If true (default) the workers will
|
| 57378 |
ripley |
96 |
load the \pkg{methods} package: not loading it saves ca 30\% of the
|
| 56649 |
ripley |
97 |
startup time of the cluster.}
|
| 58219 |
ripley |
98 |
\item{\code{useXDR}}{Logical. If true (default) serialization will
|
| 58220 |
ripley |
99 |
use XDR: where large amounts of data are to be transferred and
|
| 58219 |
ripley |
100 |
all the nodes are little-endian, communication may be
|
|
|
101 |
substantially fast if this is set to false.}
|
| 56599 |
ripley |
102 |
}
|
| 56646 |
ripley |
103 |
|
|
|
104 |
Function \code{makeForkCluster} creates a socket cluster by forking
|
|
|
105 |
(and hence is not available on Windows). It supports options
|
| 58219 |
ripley |
106 |
\code{port}, \code{timeout} and \code{outfile}, and always uses
|
|
|
107 |
\code{useXDR = FALSE}.
|
| 61433 |
ripley |
108 |
|
| 57378 |
ripley |
109 |
It is good practice to shut down the workers by calling
|
| 56630 |
ripley |
110 |
\code{\link{stopCluster}}: however the workers will terminate
|
|
|
111 |
themselves once the socket on which they are listening for commands
|
|
|
112 |
becomes unavailable, which it should if the master \R session is
|
|
|
113 |
completed (or its process dies).
|
| 61433 |
ripley |
114 |
|
| 57336 |
ripley |
115 |
Function \code{setDefaultCluster} registers a cluster as the default one
|
|
|
116 |
for the current session. Using \code{setDefaultCluster(NULL)} removes
|
| 57335 |
ripley |
117 |
the registered cluster, as does stopping that cluster.
|
| 56599 |
ripley |
118 |
}
|
| 57380 |
ripley |
119 |
|
| 56599 |
ripley |
120 |
\value{
|
|
|
121 |
An object of class \code{c("SOCKcluster", "cluster")}.
|
|
|
122 |
}
|
| 57380 |
ripley |
123 |
|
| 56742 |
ripley |
124 |
\author{
|
|
|
125 |
Luke Tierney and R Core.
|
| 56599 |
ripley |
126 |
|
| 57939 |
hornik |
127 |
Derived from the \CRANpkg{snow} package.
|
| 56742 |
ripley |
128 |
}
|