Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine MPI rank/process number local to a socket/node

Say, I run a parallel program using MPI. Execution command

mpirun -n 8 -npernode 2 <prg>

launches 8 processes in total. That is 2 processes per node and 4 nodes in total. (OpenMPI 1.5). Where a node comprises 1 CPU (dual core) and network interconnect between nodes is InfiniBand.

Now, the rank number (or process number) can be determined with

int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

This returns a number between 0 and 7.

But, How can I determine the node number (in this case a number between 0 and 3) and the process number within a node (number between 0 and 1)?

like image 281
ritter Avatar asked Jan 26 '12 17:01

ritter


People also ask

What is process rank in MPI?

MPI process rank Each process has a unique rank, i.e. an integer identifier, within a. communicator. The rank value is between 0 and #procs-1. The rank value is used to distinguish one process from another. Commands MPI Comm size & MPI Comm rank are very useful.

What does mpirun do?

"mpirun" is a shell script that attempts to hide the differences in starting jobs for various devices from the user. Mpirun attempts to determine what kind of machine it is running on and start the required number of jobs on that machine.


2 Answers

I believe you can achieve that with MPI-3 in this manner:

MPI_Comm shmcomm;
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0,
                    MPI_INFO_NULL, &shmcomm);
int shmrank;
MPI_Comm_rank(shmcomm, &shmrank);
like image 133
Dave O. Avatar answered Sep 30 '22 06:09

Dave O.


It depends on the MPI implementation - and there is no standard for this particular problem.

Open MPI has some environment variables that can help. OMPI_COMM_WORLD_LOCAL_RANK will give you the local rank within a node - ie. this is the process number which you are looking for. A call to getenv will therefore answer your problem - but this is not portable to other MPI implementations.

See this for the (short) list of variables in OpenMPI.

I don't know of a corresponding "node number".

like image 45
David Avatar answered Sep 30 '22 05:09

David