Update home authored by van Vliet's avatar van Vliet
......@@ -1701,6 +1701,54 @@ To make your R program to run parallel and more efficient, we have installed for
Loading one of these libraires does **not** make your program to run parallel.
For that, you have to adapt your R program.
**Example**
hello.R
```
library(Rmpi)
id <- mpi.comm.rank(comm = 0)
np <- mpi.comm.size(comm = 0)
hostname <- mpi.get.processor.name()
msg <- sprintf("Hello world from process %03d of %03d, on host %s\n", id, np, hostname)
cat(msg)
mpi.barrier(comm = 0)
mpi.finalize()
```
run-rpmi.slurm
```
#!/bin/bash
#SBATCH --job-name=hello_parallel # Job name
#SBATCH --output=slurm-rmpi.out # Output file name
#SBATCH --error=slurm-rmpi.err # Error file name
#SBATCH --partition=short # Partition
#SBATCH --time=00:05:00 # Time limit
#SBATCH --nodes=2 # Number of nodes
#SBATCH --ntasks-per-node=4 # MPI processes per node
module purge
module add statistical/R/4.0.0/gcc.8.3.1
module add library/mpi/openmpi/4.0.3/gcc-8.3.1
mpirun Rscript hello.R
```
```
[username@res-hpc-lo01 R]$ cat slurm-rmpi.out
Hello world from process 000 of 008, on host res-hpc-gpu01
Hello world from process 001 of 008, on host res-hpc-gpu01
Hello world from process 002 of 008, on host res-hpc-gpu01
Hello world from process 003 of 008, on host res-hpc-gpu01
Hello world from process 004 of 008, on host res-hpc-gpu02
Hello world from process 005 of 008, on host res-hpc-gpu02
Hello world from process 006 of 008, on host res-hpc-gpu02
Hello world from process 007 of 008, on host res-hpc-gpu02
```
We recommend to have a look at the following web pages:
[High-Performance and Parallel Computing with R](https://cran.r-project.org/web/views/HighPerformanceComputing.html)
......
......