Search code examples
processmpicpuopenmpiaffinity

How to replace --cpus-per-proc with --map-by in OpenMPI


I need to update some old codes to work with the most recent version of OpenMPI, but I'm very confused by the new --map-by system. In particular, I'm not sure how to replace --cpus-per-proc N.

Several websites have suggested using --map-by node:pe=N, but when I tried this it gives me a different result.

The original command is:

mpirun -np 3 --report-bindings --bind-to-core --cpus-per-proc 3 ./test.sh

Which gives:

[B/B/B/././././.] [./././././././.] [./././././././.] [./././././././.] 
[./././././././.] [B/B/B/././././.] [./././././././.] [./././././././.] 
[./././././././.] [./././././././.] [B/B/B/././././.] [./././././././.] 

However, when I use the command:

mpirun -np 3 --report-bindings --bind-to core --map-by node:pe=3 ./test.sh

The output is:

[B/B/B/././././.] [./././././././.] [./././././././.] [./././././././.] 
[./././B/B/B/./.] [./././././././.] [./././././././.] [./././././././.] 
[././././././B/B] [B/././././././.] [./././././././.] [./././././././.] 

Could someone please explain how to use the --map-by option?


Solution

  • To spread four MPI processes over four CPU sockets and have each process bound to three cores of the corresponding socket use:

    -n 4 --map-by socket:pe=3 --bind-to core