How to debug MPI with CLion?
Asked Answered
S

2

7

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

Slag answered 18/6, 2016 at 20:14 Comment(2)
Are you running all MPI processes locally?Visor
yes, i run it locally on processor with 4 coresSlag
V
3

As Zulan already mentioned,

  1. Add these lines before your breakpoint and rebuild your application (from OpenMPI)

     int i = 0;
     while(0==i)
        sleep(5);
    
  2. Launch your program from the terminal with mpirun

$mpirun -np 4 ./Application

  1. Attach LLDB or GDB to a local process

Run-> Attach to Process

  1. Pause Program (the program will pause on sleep(5))

  2. Set i!=0 and Resume Program

  3. Happy debugging

You may need to connect to your other processes to set i!=0 and continue debugging.

Venous answered 30/10, 2018 at 22:11 Comment(1)
If your program fails due to ptrace: Operation not permitted, see: https://mcmap.net/q/25093/-how-to-solve-quot-ptrace-operation-not-permitted-quot-when-trying-to-attach-gdb-to-a-process/9723204Barranca
V
1

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.

Visor answered 19/6, 2016 at 15:45 Comment(1)
thanks, but when i tried to attach process, program failed with message ptrace: Operation not permitted. Debugger detachedSlag

© 2022 - 2024 — McMap. All rights reserved.