-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from snoweye/master
0.3-5 on CRAN
- Loading branch information
Showing
48 changed files
with
541 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: pbdMPI | ||
Version: 0.3-4 | ||
Date: 2018-01-03 | ||
Version: 0.3-5 | ||
Date: 2018-02-25 | ||
Title: Programming with Big Data -- Interface to MPI | ||
Authors@R: c(person("Wei-Chen", "Chen", role = c("aut", "cre"), email = | ||
"[email protected]"), | ||
|
@@ -27,7 +27,7 @@ SystemRequirements: OpenMPI (>= 1.5.4) on Solaris, Linux, Mac, and | |
Pack 2012 R2 MS-MPI Redistributable Package) on Windows. | ||
License: Mozilla Public License 2.0 | ||
URL: http://r-pbd.org/ | ||
BugReports: http://group.r-pbd.org/ | ||
BugReports: https://github.com/snoweye/pbdMPI/issues | ||
MailingList: Please send questions and comments regarding pbdR to | ||
[email protected] | ||
NeedsCompilation: yes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
### Utility | ||
|
||
execmpi <- function(spmd.code = NULL, spmd.file = NULL, | ||
mpicmd = NULL, nranks = 2L, verbose = TRUE){ | ||
### Check # of ranks. | ||
nranks <- as.integer(nranks) | ||
if(nranks <= 0){ | ||
stop("argument 'nranks' must be a integer and greater than 0.") | ||
} | ||
|
||
### Input checks | ||
if(! is.null(spmd.code)){ | ||
if(!is.character(spmd.code)){ | ||
stop("argument 'spmd.code' must be a character string") | ||
} else if(length(spmd.code) == 0){ | ||
stop("argument 'spmd.code' must be a non-empty character string") | ||
} else if (length(spmd.code) > 1){ | ||
warning("spmd.code has length > 1; only the first element will be used") | ||
spmd.code <- spmd.code[1L] | ||
} | ||
|
||
### Dump spmd.code to a temp file, execute | ||
spmd.file <- tempfile() | ||
on.exit(unlink(spmd.file)) | ||
conn <- file(spmd.file, open = "wt") | ||
writeLines(spmd.code, conn) | ||
close(conn) | ||
} else{ | ||
if(is.null(spmd.file)){ | ||
stop("Either spmd.code or spmd.file should be provided.") | ||
} | ||
} | ||
if(! file.exists(spmd.file)){ | ||
stop("spmd.file does not exist.") | ||
} | ||
|
||
### Find MPI executable. | ||
if(is.null(mpicmd)){ | ||
if(Sys.info()[['sysname']] == "Windows"){ | ||
mpicmd <- try(system("mpiexec", intern = TRUE), silent = TRUE) | ||
if(class(mpicmd) == "try-error"){ | ||
warning("No MPI executable can be found from PATH.") | ||
return(invisible(NULL)) | ||
} else{ | ||
mpicmd <- "mpiexec" | ||
} | ||
} else{ | ||
mpicmd <- system("which mpiexec", intern = TRUE) | ||
if(! is.null(attr(mpicmd, "status"))){ | ||
mpicmd <- system("which mpirun", intern = TRUE) | ||
if(! is.null(attr(mpicmd, "status"))){ | ||
mpicmd <- system("which orterun", intern = TRUE) | ||
if(! is.null(attr(mpicmd, "status"))){ | ||
mpicmd <- get.conf("MPIEXEC") | ||
if(mpicmd == ""){ | ||
mpicmd <- get.conf("MPIRUN") | ||
if(mpicmd == ""){ | ||
mpicmd <- get.conf("ORTERUN") | ||
if(mpicmd == ""){ | ||
warning("No MPI executable can be found.") | ||
return(invisible(NULL)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
### Find Rscript. | ||
if(Sys.info()[['sysname']] == "Windows"){ | ||
rscmd <- paste(Sys.getenv("R_HOME"), "/bin", Sys.getenv("R_ARCH_BIN"), | ||
"/Rscript", sep = "") | ||
} else{ | ||
rscmd <- paste(Sys.getenv("R_HOME"), "/bin/Rscript", sep = "") | ||
} | ||
|
||
### Make a cmd. | ||
if(Sys.info()[['sysname']] == "Windows"){ | ||
cmd <- paste(mpicmd, "-np", nranks, rscmd, spmd.file, sep = " ") | ||
### Redirect to log.file will get the message below and fail. | ||
### The process cannot access the file because it is being used by | ||
### another process. | ||
} else{ | ||
log.file <- tempfile() | ||
on.exit(unlink(log.file), add = TRUE) | ||
cmd <- paste(mpicmd, "-np", nranks, rscmd, spmd.file, | ||
">", log.file, "2>&1 & echo \"PID=$!\" &", sep = " ") | ||
} | ||
if(verbose){ | ||
cat(">>> MPI command:\n", cmd, "\n", sep = "") | ||
} | ||
|
||
### Run the cmd. | ||
if(Sys.info()[['sysname']] == "Windows"){ | ||
ret <- system(cmd, intern = TRUE, ignore.stdout = FALSE, | ||
ignore.stderr = FALSE, wait = TRUE) | ||
} else{ | ||
tmp <- system(cmd, intern = TRUE, ignore.stdout = FALSE, | ||
ignore.stderr = FALSE, wait = FALSE) | ||
if(verbose){ | ||
cat(">>> MPI PID:\n", paste(tmp, collapse = "\n"), "\n", sep = "") | ||
} | ||
|
||
### Check if the job is finished, otherwise wait for it. | ||
pid <- gsub("^PID=(.*)$", "\\1", tmp) | ||
cmd.pid <- paste("ps -p", pid, sep = " ") | ||
while(TRUE){ | ||
tmp.pid <- suppressWarnings(system(cmd.pid, intern = TRUE)) | ||
if(is.null(attr(tmp.pid, "status"))){ | ||
Sys.sleep(1) | ||
} else{ | ||
break | ||
} | ||
} | ||
} | ||
|
||
### Get the output from the log file. | ||
if(Sys.info()[['sysname']] != "Windows"){ | ||
ret <- readLines(log.file) | ||
} | ||
if(verbose){ | ||
cat(">>> MPI results:\n", paste(ret, collapse = "\n"), "\n", sep = "") | ||
} | ||
|
||
### Return | ||
invisible(ret) | ||
} # End of execmpi(). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# DO NOT CHANGE the "init" and "install" sections below | ||
|
||
# Download script file from GitHub | ||
init: | ||
ps: | | ||
$ErrorActionPreference = "Stop" | ||
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" | ||
Import-Module '..\appveyor-tool.ps1' | ||
install: | ||
- ps: Bootstrap | ||
- cd .. | ||
### Install HPC Pack 2012 R2 Update 3 SDK | ||
# - ps: (New-Object Net.WebClient).DownloadFile("https://download.microsoft.com/download/7/B/5/7B582B17-AF1E-454A-B86B-E6733010EB47/sdk_x64.msi", "sdk_x64.msi") | ||
# - ps: msiexec /i sdk_x64.msi /quiet /qn /norestart /log install.log PROPERTY1=value1 PROPERTY2=value2 | ||
### Install MS-MPI v9.0 | ||
- ps: Start-FileDownload 'https://download.microsoft.com/download/2/E/C/2EC96D7F-687B-4613-80F6-E10F670A2D97/msmpisetup.exe' | ||
- MSMpiSetup.exe -unattend | ||
- dir "C:\Program Files\Microsoft MPI" | ||
- dir "C:\Program Files\Microsoft MPI\Bin" | ||
### Install MS-MPI v9.0 SDK | ||
- ps: Start-FileDownload 'https://download.microsoft.com/download/2/E/C/2EC96D7F-687B-4613-80F6-E10F670A2D97/msmpisdk.msi' | ||
- msmpisdk.msi /passive | ||
- dir "C:\Program Files (x86)\Microsoft SDKs\MPI" | ||
- dir "C:\Program Files (x86)\Microsoft SDKs\MPI\Include" | ||
- dir "C:\Program Files (x86)\Microsoft SDKs\MPI\Lib" | ||
### Set PATH | ||
- set MPI_EXEC=C:\Program Files\Microsoft MPI | ||
- set MPI_ROOT=C:\Program Files (x86)\Microsoft SDKS\MPI | ||
- set PATH=%MPI_EXEC%\Bin;%PATH% | ||
### Check MS-MPI | ||
- mpiexec -help | ||
# - mpiexec -help2 | ||
# - mpiexec -help3 | ||
|
||
environment: | ||
global: | ||
WARNINGS_ARE_ERRORS: | ||
RTOOLS_VERSION: 34 | ||
USE_RTOOLS: true | ||
|
||
matrix: | ||
- R_VERSION: release | ||
R_ARCH: x64 | ||
|
||
build_script: | ||
- cd pbdMPI | ||
- travis-tool.sh install_deps | ||
- cd .. | ||
- R CMD build --no-build-vignettes --no-manual --no-resave-data pbdMPI | ||
- R CMD INSTALL pbdMPI*.tar.gz | ||
- R CMD check pbdMPI*.tar.gz --as-cran --no-manual --no-vignettes --no-clean | ||
- dir pbdMPI.Rcheck | ||
# - type pbdMPI.Rcheck\00check.log | ||
- type pbdMPI.Rcheck\pbdMPI-Ex_x64.Rout | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.