Search code examples
rparallel-processingmpiopenmpidompi

doMPI and Clusters


I'm having my first experience using R and clusters. Searching on Google, I discovered the package "doMPI". This package allow me to automatizate the creation of processes. However, I'm little confuse on the functions.

1 - What is the difference between startMPIcluster and registerDOMPI?

2 - What is the argue passed on the startMPIcluster?

3 - When I use the command mpirun -H n1,n2,n3 -n 1 R --slave -f sincMPI.R, what does it means the -n 1?

4 - For the last, suppose that I have 4 clusters, each one with 60 CPUS. How would it be my code?


Solution

  • Have you read the doMPI vignette? I tried to answer all of these questions in it. I also suggest that you download the doMPI source distribution and look over the example scripts that are included in it.

    As for your questions:

    1. startMPIcluster is used to create a cluster object that represents a set of processes used for parallel computations; registerDoMPI is used to register a cluster object with foreach so it will be used for executing parallel foreach loops. Both functions must be used.

    2. If you execute your R script via mpirun with the -n 1 option, mpirun will only start one process to execute your R script (which I call the master process), and the first argument to startMPIcluster specifies the number of workers that the master should start in order to execute the tasks generated by foreach loops. If you use mpirun to start multiple processes, you don't need to specify a count value at all. I recommend using mpirun to start all of the workers (using -n 3, in your example), and not specifying a value for the count value.

    3. The mpirun -n option specifies the number of workers/processes that it should start. If you want to spawn the workers, you should use -n 1 so that mpirun only starts the master, and use the startMPIcluster count argument to control the number of workers to spawn.

    I really don't understand your last question, but I think the vignette and examples should help you understand all of these concepts better.