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