Skip to content

Instantly share code, notes, and snippets.

@sachsmc
Last active August 29, 2015 14:21
Show Gist options
  • Save sachsmc/83598f4f6269d5f952f5 to your computer and use it in GitHub Desktop.
Save sachsmc/83598f4f6269d5f952f5 to your computer and use it in GitHub Desktop.
MPI Apply on Biowulf
#!/bin/bash
# navigate to directory
cd Simulation
# Get OpenMPI in our PATH. openmpi_ipath and openmpi_ib
module load R
# module load openmpi/1.4.4/gnu/eth loaded above so not needed anymore
`which mpirun` -n 1 -machinefile $PBS_NODEFILE R --vanilla >Run1.out<<EOF
# begin R code
library(Rmpi)
# load stuff if necessary
# source("mysims.R")
mpi.spawn.Rslaves(nslaves=$np)
onerun<-function(number){
set.seed(number+14)
# do something
boots <- rnorm(100)
# return something
return(boots)
}
results <- Rmpi::mpi.applyLB(1:1000, onerun)
finishedout <- do.call(rbind, results)
write.csv(finishedout, "Run.csv", row.names=FALSE)
mpi.close.Rslaves()
mpi.quit()
EOF
qsub -v np=52 -l walltime=424:00:00, nodes=26 simRun.bat
@sachsmc
Copy link
Author

sachsmc commented May 12, 2015

np should be 2 times the number of nodes, because the default nodes each have 2 processors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment