R and dompi Package
This page explains how to configure your job in order to run a R script that relies on the doMPI package.
Job script example
Below is an example of a Slurm job script which will execute a doMPI-R script in parallel :
#!/bin/bash
#SBATCH -n 32
#SBATCH -p std
# load R module
module load R/4.5.0
# launch parallel execution instances of R running script file test-dompi.R
mpirun /bin/bash $(which R) CMD BATCH --no-save test-dompi.R
exit 0
This job script :
- requests Slurm for 32 task slots (i.e. 32 CPUs) in the std partition
- assumes the R script named ‘test-dompi.R’ is in the directory where the job itself was submitted.
- uses R version 4.3.3, but other versions might be available.
- starts 32 R processes by using mpirun command. All R processes will process the script file ‘test-dompi.R’, but they will synchronize in order to execute concurrently the dopar loops.