diff --git a/.Rbuildignore b/.Rbuildignore index 169fde0..f6dd5db 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1 +1,2 @@ ^\.travis\.yml$ +appveyor.yml diff --git a/NAMESPACE b/NAMESPACE index ae64793..49766e7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -79,6 +79,7 @@ export( ### "R/util_*.r" "execmpi", + "runmpi", ### "R/000_pbd_opt.r" "pbd_opt" #, diff --git a/R/get_conf.r b/R/get_conf.r index 437ff0e..60d82df 100644 --- a/R/get_conf.r +++ b/R/get_conf.r @@ -2,7 +2,7 @@ ### "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)) @@ -10,7 +10,12 @@ get.conf <- function(arg, arch = '', package = "pbdMPI"){ 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.") } diff --git a/R/util_execmpi.r b/R/util_execmpi.r index 5217c70..cd599da 100644 --- a/R/util_execmpi.r +++ b/R/util_execmpi.r @@ -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)) @@ -128,3 +131,4 @@ execmpi <- function(spmd.code = NULL, spmd.file = NULL, invisible(ret) } # End of execmpi(). +runmpi <- execmpi diff --git a/configure b/configure index 49a17cf..763d027 100755 --- a/configure +++ b/configure @@ -674,7 +674,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -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}' @@ -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=* \ @@ -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. @@ -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] @@ -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 : @@ -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}" diff --git a/configure.ac b/configure.ac index 2246add..f8c6b70 100644 --- a/configure.ac +++ b/configure.ac @@ -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], @@ -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}" diff --git a/man/uu_execmpi.Rd b/man/uu_execmpi.Rd index 76399c7..85eb4b5 100644 --- a/man/uu_execmpi.Rd +++ b/man/uu_execmpi.Rd @@ -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 @@ -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}.}