Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
snoweye committed Aug 5, 2018
1 parent fb13191 commit e527dbb
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 21 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
^\.travis\.yml$
appveyor.yml
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export(

### "R/util_*.r"
"execmpi",
"runmpi",

### "R/000_pbd_opt.r"
"pbd_opt" #,
Expand Down
9 changes: 7 additions & 2 deletions R/get_conf.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
### "pbd*/src/Makevars.in" and "pbd*/src/Makevar.win"
### to find the default configurations from
### "pbd*/etc${R_ARCH}/Makconf".
get.conf <- function(arg, arch = '', package = "pbdMPI"){
get.conf <- function(arg, arch = '', package = "pbdMPI", return = FALSE){
file.name <- paste("./etc", arch, "/Makeconf", sep = "")
file.path <- tools::file_path_as_absolute(
system.file(file.name, package = package))
ret <- scan(file.path, what = character(), sep = "\n", quiet = TRUE)

id <- grep(paste("^", arg, " = ", sep = ""), ret)
if(length(id) > 0){
cat(gsub(paste("^", arg, " = (.*)", sep = ""), "\\1", ret[id[1]]))
ret <- gsub(paste("^", arg, " = (.*)", sep = ""), "\\1", ret[id[1]])
if(!return){
cat(ret)
} else{
return(invisible(ret))
}
} else{
stop("The arg is not found.")
}
Expand Down
16 changes: 10 additions & 6 deletions R/util_execmpi.r
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,20 @@ execmpi <- function(spmd.code = NULL, spmd.file = NULL,
mpicmd <- "mpiexec"
}
} else{
mpicmd <- system("which mpiexec", intern = TRUE)
mpicmd <- suppressWarnings(system("which mpiexec",
ignore.stderr = TRUE, intern = TRUE))
if(! is.null(attr(mpicmd, "status"))){
mpicmd <- system("which mpirun", intern = TRUE)
mpicmd <- suppressWarnings(system("which mpirun",
ignore.stderr = TRUE, intern = TRUE))
if(! is.null(attr(mpicmd, "status"))){
mpicmd <- system("which orterun", intern = TRUE)
mpicmd <- suppressWarnings(system("which orterun",
ignore.stderr = TRUE, intern = TRUE))
if(! is.null(attr(mpicmd, "status"))){
mpicmd <- get.conf("MPIEXEC")
mpicmd <- get.conf("MPIEXEC", return = TRUE)
if(mpicmd == ""){
mpicmd <- get.conf("MPIRUN")
mpicmd <- get.conf("MPIRUN", return = TRUE)
if(mpicmd == ""){
mpicmd <- get.conf("ORTERUN")
mpicmd <- get.conf("ORTERUN", return = TRUE)
if(mpicmd == ""){
warning("No MPI executable can be found.")
return(invisible(NULL))
Expand Down Expand Up @@ -128,3 +131,4 @@ execmpi <- function(spmd.code = NULL, spmd.file = NULL,
invisible(ret)
} # End of execmpi().

runmpi <- execmpi
51 changes: 38 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -752,7 +751,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
Expand Down Expand Up @@ -1005,15 +1003,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1151,7 +1140,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1304,7 +1293,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -4458,6 +4446,40 @@ MPIRUN=`which mpirun`
MPIEXEC=`which mpiexec`
ORTERUN=`which orterun`
if test "X$MPIRUN" = "X" -o "X$MPIEXEC" = "X" -o "X$ORTERUN" = "X" ; then
if test "$MPITYPE" = "OPENMPI" ; then
TMP_MODULE=`module avail mpi/o | grep "mpi/o" | sed -e "s/^\(mpi\/o\S*\)\(\s*.*\)$/\1/"`
fi
if test "$MPITYPE" = "MPICH" -o "$MPITYPE" = "MPICH2" -o "$MPITYPE" = "MPICH3" -o "$MPITYPE" = "MPICH3" ; then
TMP_MODULE=`module avail mpi/m | grep "mpi/m" | sed -e "s/^\(mpi\/m\S*\)\(\s*.*\)$/\1/"`
fi
if test $"X$TMP_MODULE" != "X" ; then
if test "X$MPIRUN" = "X" ; then
TMP_EXEC=`module load ${TMP_MODULE}; which mpirun`
if test "X$TMP_EXEC" != "X" ; then
MPIRUN="module load ${TMP_MODULE}; ${TMP_EXEC}"
fi
fi
if test "X$MPIEXEC" = "X" ; then
TMP_EXEC=`module load ${TMP_MODULE}; which mpiexec`
if test "X$TMP_EXEC" != "X" ; then
MPIEXEC="module load ${TMP_MODULE}; ${TMP_EXEC}"
fi
fi
if test "X$ORTERUN" = "X" ; then
TMP_EXEC=`module load ${TMP_MODULE}; which orterun`
if test "X$TMP_EXEC" != "X" ; then
ORTERUN="module load ${TMP_MODULE}; ${TMP_EXEC}"
fi
fi
fi
fi
# Check whether --enable-pbdPROF was given.
if test "${enable_pbdPROF+set}" = set; then :
Expand Down Expand Up @@ -4508,6 +4530,9 @@ fi
echo " "
echo "******************* Results of pbdMPI package configure *****************"
echo " "
echo ">> MPIRUN = ${MPIRUN}"
echo ">> MPIEXEC = ${MPIEXEC}"
echo ">> ORTERUN = ${ORTERUN}"
echo ">> TMP_INC = ${TMP_INC}"
echo ">> TMP_LIB = ${TMP_LIB}"
echo ">> TMP_LIBNAME = ${TMP_LIBNAME}"
Expand Down
39 changes: 39 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,42 @@ MPIRUN=`which mpirun`
MPIEXEC=`which mpiexec`
ORTERUN=`which orterun`

dnl Mainly for Fedora which has "mpi/openmpi-x86_64" and "mpi/mpich-x86_64"
dnl Others may have "mpi/gcc/openmpi-*" or so which need more works.
if test "X$MPIRUN" = "X" -o "X$MPIEXEC" = "X" -o "X$ORTERUN" = "X" ; then
if test "$MPITYPE" = "OPENMPI" ; then
TMP_MODULE=`module avail mpi/o | grep "mpi/o" | sed -e "s/^\(mpi\/o\S*\)\(\s*.*\)$/\1/"`
fi

if test "$MPITYPE" = "MPICH" -o "$MPITYPE" = "MPICH2" -o "$MPITYPE" = "MPICH3" -o "$MPITYPE" = "MPICH3" ; then
TMP_MODULE=`module avail mpi/m | grep "mpi/m" | sed -e "s/^\(mpi\/m\S*\)\(\s*.*\)$/\1/"`
fi

if test $"X$TMP_MODULE" != "X" ; then
if test "X$MPIRUN" = "X" ; then
TMP_EXEC=`module load ${TMP_MODULE}; which mpirun`
if test "X$TMP_EXEC" != "X" ; then
MPIRUN="module load ${TMP_MODULE}; ${TMP_EXEC}"
fi
fi

if test "X$MPIEXEC" = "X" ; then
TMP_EXEC=`module load ${TMP_MODULE}; which mpiexec`
if test "X$TMP_EXEC" != "X" ; then
MPIEXEC="module load ${TMP_MODULE}; ${TMP_EXEC}"
fi
fi

if test "X$ORTERUN" = "X" ; then
TMP_EXEC=`module load ${TMP_MODULE}; which orterun`
if test "X$TMP_EXEC" != "X" ; then
ORTERUN="module load ${TMP_MODULE}; ${TMP_EXEC}"
fi
fi

fi
fi


dnl pbdPROF
AC_ARG_ENABLE([pbdPROF],
Expand Down Expand Up @@ -829,6 +865,9 @@ dnl Report
echo " "
echo "******************* Results of pbdMPI package configure *****************"
echo " "
echo ">> MPIRUN = ${MPIRUN}"
echo ">> MPIEXEC = ${MPIEXEC}"
echo ">> ORTERUN = ${ORTERUN}"
echo ">> TMP_INC = ${TMP_INC}"
echo ">> TMP_LIB = ${TMP_LIB}"
echo ">> TMP_LIBNAME = ${TMP_LIBNAME}"
Expand Down
3 changes: 3 additions & 0 deletions man/uu_execmpi.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{Utility execmpi}
\alias{execmpi}
\alias{runmpi}
\title{ Execute MPI code in system }
\description{
This function basically saves code in a spmd.file and executes
Expand All @@ -9,6 +10,8 @@
\usage{
execmpi(spmd.code = NULL, spmd.file = NULL,
mpicmd = NULL, nranks = 2L, verbose = TRUE)
runmpi(spmd.code = NULL, spmd.file = NULL,
mpicmd = NULL, nranks = 2L, verbose = TRUE)
}
\arguments{
\item{spmd.code}{SPMD code to be run via mpicmd and \code{Rscript}.}
Expand Down

0 comments on commit e527dbb

Please sign in to comment.