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
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.
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.
© 2022 - 2024 — McMap. All rights reserved.