File: makeClusterMPI.Rd

package info (click to toggle)
r-cran-parallelly 1.42.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,216 kB
  • sloc: ansic: 111; sh: 13; makefile: 2
file content (73 lines) | stat: -rw-r--r-- 2,366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/makeClusterMPI.R
\name{makeClusterMPI}
\alias{makeClusterMPI}
\alias{MPI}
\title{Create a Message Passing Interface (MPI) Cluster of R Workers for Parallel Processing}
\usage{
makeClusterMPI(
  workers,
  ...,
  autoStop = FALSE,
  verbose = getOption2("parallelly.debug", FALSE)
)
}
\arguments{
\item{workers}{The number workers (as a positive integer).}

\item{\dots}{Optional arguments passed to
\code{\link[parallel:makeCluster]{makeCluster}(workers, type = "MPI", ...)}.}

\item{autoStop}{If TRUE, the cluster will be automatically stopped
using \code{\link[parallel:makeCluster]{stopCluster}()} when it is
garbage collected, unless already stopped.  See also \code{\link[=autoStopCluster]{autoStopCluster()}}.}

\item{verbose}{If TRUE, informative messages are outputted.}
}
\value{
An object of class \code{c("RichMPIcluster", "MPIcluster", "cluster")} consisting
of a list of \code{"MPInode"} workers.
}
\description{
The \code{makeClusterMPI()} function creates an MPI cluster of \R workers
for parallel processing.  This function utilizes
\code{makeCluster(..., type = "MPI")} of the \pkg{parallel} package and
tweaks the cluster in an attempt to avoid
\code{\link[parallel:makeCluster]{stopCluster()}} from hanging (1).
\emph{WARNING: This function is very much in a beta version and should
only be used if \code{parallel::makeCluster(..., type = "MPI")} fails.}
}
\details{
\emph{Creating MPI clusters requires that the \pkg{Rmpi} and \pkg{snow}
packages are installed.}
}
\section{Alternative usage}{


In R (>= 4.4.0), an alternatively to using
\code{cl <- parallelly::makeClusterMPI(workers)} is:

\if{html}{\out{<div class="sourceCode">}}\preformatted{cl <- parallel::makeCluster(workers, type = parallelly::MPI)
}\if{html}{\out{</div>}}
}

\examples{
\donttest{\dontrun{
if (requireNamespace("Rmpi") && requireNamespace("snow")) {
  cl <- makeClusterMPI(2, autoStop = TRUE)
  print(cl)
  y <- parLapply(cl, X = 1:3, fun = sqrt)
  print(y)
  rm(list = "cl")
}
}}

}
\references{
\enumerate{
\item R-sig-hpc thread \href{https://stat.ethz.ch/pipermail/r-sig-hpc/2017-September/002065.html}{Rmpi: mpi.close.Rslaves() 'hangs'} on 2017-09-28.
}
}
\seealso{
\code{\link[=makeClusterPSOCK]{makeClusterPSOCK()}} and \code{\link[parallel:makeCluster]{parallel::makeCluster()}}.
}