Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my program detect, whether it was launch via mpirun

Tags:

mpi

How can my MPI program detect, if it was launched as a standalone application or via mpirun?

like image 269
fhucho Avatar asked Oct 01 '12 17:10

fhucho


2 Answers

Considering the answer and comments by semiuseless and Hristo Iliev, there is no general and portable way to do this. As a workaround, you can check for environment variables that are set by mpirun. See e.g.:
http://www.open-mpi.org/faq/?category=running#mpi-environmental-variables

like image 177
Douglas B. Staple Avatar answered Oct 14 '22 14:10

Douglas B. Staple


There is no MPI standard way to tell the difference between an MPI application that is launched directly, or as a single rank with mpirun. See "Singleton MPI_Init" for more on this kind of MPI job.

The environment variable checking answer from Douglas is a reasonable hack...but is not portable to any other MPI implementation.

like image 40
Stan Graves Avatar answered Oct 14 '22 14:10

Stan Graves