55\description {
66 This function basically saves code in a spmd.file and executes
77 MPI via R ' s system call e.g.
8- \c ode{system("mpiexec -np 2 Rscript spmd.file")}.
8+ \c ode{system("mpiexec -np 1 Rscript spmd.file")}.
99}
1010\u sage{
1111execmpi(spmd.code = NULL, spmd.file = NULL,
12- mpicmd = NULL, nranks = 2L, verbose = TRUE)
12+ mpicmd = NULL, nranks = 1L, rscmd = NULL, verbose = TRUE,
13+ disable.current.mpi = TRUE)
1314runmpi(spmd.code = NULL, spmd.file = NULL,
14- mpicmd = NULL, nranks = 2L, verbose = TRUE)
15+ mpicmd = NULL, nranks = 1L, rscmd = NULL, verbose = TRUE,
16+ disable.current.mpi = TRUE)
1517}
1618\a rguments{
1719 \i tem{spmd.code}{SPMD code to be run via mpicmd and \c ode{Rscript}.}
1820 \i tem{spmd.file}{a file contains SPMD code to be run via mpicmd and \c ode{Rscript}.}
1921 \i tem{mpicmd}{MPI executable command. If \c ode{NULL}, system default will be searched.}
2022 \i tem{nranks}{number of processes to run the SPMD code envoked by mpicmd.}
23+ \i tem{rscmd}{\c ode{Rscript} executable command. If \c ode{NULL}, system default will be searched.}
2124 \i tem{verbose}{print SPMD code outputs and MPI messages.}
25+ \i tem{disable.current.mpi}{force to finalize the current MPI comm if any, for unix-alike system only.}
2226}
2327\d etails{
2428 When the \c ode{spmd.code} is \c ode{NULL}: The code should be already
@@ -36,14 +40,14 @@ runmpi(spmd.code = NULL, spmd.file = NULL,
3640 used to dump \c ode{spmd.code}.
3741
3842 For Unix-alike systems, the command
39- \c ode{cmd <- paste(mpicmd, "-np", nranks, "Rscript" , spmd.file, ">", log.file, " 2>&1 & echo \" PID=$!\" &")}
43+ \c ode{cmd <- paste(mpicmd, "-np", nranks, rscmd , spmd.file, ">", log.file, " 2>&1 & echo \" PID=$!\" &")}
4044 is executed via \c ode{system(cmd, intern = TRUE, wait = FALSE, ignore.stdout = TRUE, ignore.stderr = TRUE)}. The \c ode{log.file} is a temporary file to
4145 save the outputs from the \c ode{spmd.code}. The results saved to the
4246 \c ode{log.file} will be read back in and \c ode{cat} and \c ode{return}
4347 to R.
4448
4549 For Windows, the \c ode{cmd} will be
46- \c ode{paste(mpicmd, "-np", nranks, "Rscript" , spmd.file)}
50+ \c ode{paste(mpicmd, "-np", nranks, rscmd , spmd.file)}
4751 and is executed via
4852 \c ode{system(cmd, intern = TRUE, wait = FALSE, ignore.stdout = TRUE, ignore.stderr = TRUE)}.
4953}
@@ -52,6 +56,23 @@ runmpi(spmd.code = NULL, spmd.file = NULL,
5256 in Linux-alike systems. For Windows, the MPI job is always wait until
5357 it is complete.
5458}
59+ \n ote{
60+ For Unix-alike systems,
61+ in new R and MPI, the \c ode{pbdMPI::execmpi(...)} may
62+ carry the current MPI \c ode{comm} into \c ode{system(cmd, ...)} calls.
63+ Because the \c ode{comm} has been established/loaded by the
64+ \c ode{init()} call because of \c ode{::},
65+ the \c ode{mpiexec} inside the \c ode{system(cmd, ...)} calls
66+ will be confused with the exist \c ode{comm}.
67+
68+ Consider that \c ode{pbdMPI::execmpi(...)} is typically called in
69+ interactive mode (or actually only done for CRAN check in most case),
70+ an argument \c ode{disable.current.mpi = TRUE} is added/needed to finalize
71+ the existing \c ode{comm} first before \c ode{system(cmd, ...)} be executed.
72+
73+ This function is NOT recommended for running SPMD programs.
74+ The recommended way is to run under shell command.
75+ }
5576\r eferences{
5677 Programming with Big Data in R Website:
5778 \u rl{http://r-pbd.org/}
0 commit comments