Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2159 Discussions

Determine MPI launch environment

PSE
Beginner
1,310 Views

I am updating Intel MPI to 2021.6.0 from Intel MPI 5.0.3. I was using the environment variable "I_MPI_CMD" (created by the Intel MPI runtime started via mpiexec/mpirun) to determine the launch context of my application (parallel vs serial). This environment variable was not explicitly documented in the Intel MPI documentation but recommended by the Intel technical support team in the past.

 

With the upgrade to 2021.6, this environment variable is no longer set when executing mpiexec/mpirun. Hence, is there an equivalent variable to the old I_MPI_CMD that could be used – note that the fact that I_MPI_CMD was not documented gave me some reassurance that a user would not have it set in the environment without running mpiexec.

 

As an alternative to this (rather) error-prone approach, is there an established method to determine if a process is a child of mpiexec/mpirun? This would be used as a replacement to determine the launch context of the application.

 

Thank you!

Labels (1)
0 Kudos
8 Replies
VarshaS_Intel
Moderator
1,273 Views

Hi,


Thanks for posting in Intel Communities.


>>(created by the Intel MPI runtime started via mpiexec/mpirun) to determine the launch context of the application (parallel vs serial)”

Could you please elaborate more on this statement? And also, could you please let us know what serial means? (is it an application launched with one rank?)


Could you please provide us with the use case of I_MPI_CMD?


Thanks & Regards,

Varsha


0 Kudos
PSE
Beginner
1,262 Views

Dear Varsha,

 

Thank you for the reply!

 

>> Could you please elaborate more on this statement? And also, could you please let us know what serial means? (is it an application launched with one rank?)

The setup is such that the application can run both as a stand-alone executable as well as part of a mpiexec/mpirun call. What I am trying to establish is if my application is running by simply calling

application.exe

or, for example, by calling

mpiexec.exe <...> -n 1 application.exe : -n 2 workerProcess.exe

 

i.e. is it a child process of mpirun/mpiexec.

 

>> Could you please provide us with the use case of I_MPI_CMD?

With MPI 5.0.3 we were checking the environment if the variable  I_MPI_CMD was present. If it was then I would continue with the necessary steps of calling MPI_Init() etc. Otherwise, there would be no MPI involved.

 

This check no longer works with Intel MPI 2021.6. 

 

I hope this helps and thank you for your time!

 

 

0 Kudos
VarshaS_Intel
Moderator
1,244 Views

Hi,


Could you please let us know for which application you have tried and please provide the steps you have followed to use this I_MPI_CMD environment variable and how I_MPI_CMD helped you to achieve your goal?


Could you please share any output logs in which we can see the I_MPI_CMD results?


It would help us if you provide us with all the above requested details.


Thanks & Regards,

Varsha


0 Kudos
PSE
Beginner
1,216 Views

Dear Varsha,

 

The application I am running is a private development. In the running of the application, I make a check similar to:

 

bool isParallel = false;

auto env = std::getenv("I_MPI_CMD");

if (env != nullptr && env[0] != '\0') {
  isParallel = true;
}

 

If I have determined that my application has been launched by mpiexec then I proceed in the code to initialise the MPI environment

   if (isParallel){
    MPI_Init(nullptr, nullptr);
}

 otherwise, my application does not make use of any MPI functionality.

The environment variable "I_MPI_CMD" is created by the Intel MPI runtime (for v 5.0.3) started via mpiexec/mpirun. This no longer is present after the upgrade to 2021.6, so now every time my application returns isParallel as false.

 

Example run from Intel MPI 5.0.3, where I_MPI_CMD is being set by mpirun to the actual command line that was executed:

 

> mpirun --version
Intel(R) MPI Library for Linux* OS, Version 5.0 Update 3 Build 20150128 (build id: 11250)
Copyright (C) 2003-2015, Intel Corporation. All rights reserved.
> mpirun -n 1 MainApplication.exe : -n 1 MainApplication.exe
I_MPI_CMD is set!
I_MPI_CMD = mpirun -n 1 MainApplication.exe : -n 1 MainApplication.exe
MainApplication.exe 2022.2.0 Jun 29 2022 11:42:33
...

 

Running the equivalent with Intel MPU 2021.6.0 (some debug info present due to I_MPI_DEBUG being set):

 

> mpirun -n 1 MainApplication.exe : -n 1 WorkerApplication.exe
I_MPI_CMD is not set!
[0] MPI startup(): Intel(R) MPI Library, Version 2021.6  Build 20220227 (id: 28877f3f32)
[0] MPI startup(): Copyright (C) 2003-2022 Intel Corporation.  All rights reserved.
[0] MPI startup(): library kind: release
[0] MPI startup(): libfabric version: 1.13.2rc1-impi
[0] MPI startup(): max number of MPI_Request per vci: 67108864 (pools: 1)
[0] MPI startup(): libfabric provider: tcp;ofi_rxm
[0] MPI startup(): threading: mode: direct
[0] MPI startup(): threading: vcis: 1
[0] MPI startup(): threading: app_threads: -1
[0] MPI startup(): threading: runtime: generic
[0] MPI startup(): threading: progress_threads: 1
[0] MPI startup(): threading: async_progress: 0
[0] MPI startup(): threading: lock_level: global
[0] MPI startup(): tag bits available: 19 (TAG_UB value: 524287)
[0] MPI startup(): source bits available: 20 (Maximal number of rank: 1048575)

[0] MPI startup(): I_MPI_ROOT=/mpi/intel/2021.6.0
[0] MPI startup(): I_MPI_MPIRUN=mpirun
[0] MPI startup(): I_MPI_HYDRA_TOPOLIB=hwloc
[0] MPI startup(): I_MPI_INTERNAL_MEM_POLICY=default
[0] MPI startup(): I_MPI_DEBUG=6
MainApplication.exe 2022.2.0 Jun 29 2022 11:29:50

 

As you can see from my printing to the console, I_MPI_CMD is no longer set.

 

Essentially, I would like to know if there is a way of making sure that my application has been launched via mpirun and I can safely call the MPI_Init().

 

Thank you!

0 Kudos
VarshaS_Intel
Moderator
1,158 Views

Hi,

 

Thanks for providing the details.

 

Could you please let us know is there any other difference in the results apart from the I_MPI_CMD(I_MPI_CMD = mpirun -n 1 MainApplication.exe : -n 1 MainApplication.exe) in the latest Intel MPI 2021.6 and MPI 5.0.3?

 

Thanks & Regards,

Varsha

 

0 Kudos
VarshaS_Intel
Moderator
1,129 Views

Hi,


You can find the I_MPI_MPIRUN=mpirun from the debug information where it is using the Intel MPI.


And also, could you please let us know is there any other difference in the results apart from the I_MPI_CMD(I_MPI_CMD = mpirun -n 1 MainApplication.exe : -n 1 MainApplication.exe) in the latest Intel MPI 2021.6 and MPI 5.0.3?


Thanks & Regards,

Varsha


0 Kudos
VarshaS_Intel
Moderator
1,099 Views

Hi,


We have not heard back from you. Could you please provide an update on your issue?


Thanks & Regards,

Varsha


0 Kudos
VarshaS_Intel
Moderator
1,070 Views

Hi,


We have not heard back from you. This thread will no longer be monitored by Intel. If you need any additional information, please post a new question.


Thanks & Regards,

Varsha


0 Kudos
Reply