fix sample means example

This commit is contained in:
Garrett Mills 2019-05-01 16:05:34 -05:00
parent 9a406e001e
commit adc762ec13
4 changed files with 9 additions and 4 deletions

View File

@ -7,6 +7,7 @@ nodes = mpi.universe.size()
mpi.spawn.Rslaves(nslaves=nodes) mpi.spawn.Rslaves(nslaves=nodes)
generate_plot <- function(filename){ generate_plot <- function(filename){
print(mpi.comm.rank())
samples = rep(NA, 100000) samples = rep(NA, 100000)
for ( i in 1:100000 ){ samples[i] = mean(rexp(40, 0.2)) } for ( i in 1:100000 ){ samples[i] = mean(rexp(40, 0.2)) }
@ -20,7 +21,7 @@ generate_plot <- function(filename){
samples = 1:number_of_plots samples = 1:number_of_plots
mpi.apply(samples, generate_plot) mpi.applyLB(samples, generate_plot)
mpi.close.Rslaves() mpi.close.Rslaves()
mpi.quit() mpi.quit()

View File

@ -0,0 +1,5 @@
#!/bin/bash
mkdir plots/
mpiexec --allow-run-as-root -n 1 --hostfile /kube-openmpi/generated/hostfile R --vanilla -f generate_plots.R > mpi.out

View File

View File

@ -1,9 +1,8 @@
#!/bin/bash #!/bin/bash
#SBATCH --nodes=1 #SLURM --ntasks=5
#SBATCH --ntasks-per-node=1
cd $SLURM_SUBMIT_DIR cd $SLURM_SUBMIT_DIR
mkdir plots/ mkdir plots/
R --vanilla -f generate_plots.R --args "plot$SLURM_ARRAY_TASK_ID" mpiexec -n 1 R --vanilla -f generate_plots.R