How to debug mpi program with Clion?
Executable is set mpirun, that's why I can not debug as usual, I think, so how to do it? Thanks

- 61
- 1
- 3
-
Are you running all MPI processes locally? – Zulan Jun 18 '16 at 20:19
-
yes, i run it locally on processor with 4 cores – Vadim Romansky Jun 19 '16 at 14:24
2 Answers
As Zulan already mentioned,
Add these lines before your breakpoint and rebuild your application (from OpenMPI)
int i = 0; while(0==i) sleep(5);
Launch your program from the terminal with
mpirun
$mpirun -np 4 ./Application
- Attach LLDB or GDB to a local process
Run-> Attach to Process
Pause Program (the program will pause on
sleep(5)
)Set
i!=0
and Resume ProgramHappy debugging
You may need to connect to your other processes to set i!=0
and continue debugging.

- 3,069
- 7
- 26
- 40
-
If your program fails due to ptrace: Operation not permitted, see: https://stackoverflow.com/q/19215177/9723204 – Hawklike Apr 14 '21 at 14:34
The current version of CLion does not directly support debugging MPI programs. The best you can do is to attach to an individual process, after it is launched with mpirun
. You may have to delay the processes to give yourself enough time to attach to them. OpenMPI describes a few tricks how to do so.
It can be very tedious to debug a parallel application with serial deuggers. Searching for the one process out of many that has an abnormal value is alot of manual work. Generally you are better off using a parallel debugger such as DDT or totalview.

- 21,896
- 6
- 49
- 109
-
1thanks, but when i tried to attach process, program failed with message ptrace: Operation not permitted. Debugger detached – Vadim Romansky Jun 19 '16 at 18:20