MPI in CLion
It is possible to run MPI programs directly in CLION. The easiest way is with in the built-in terminal in Clion. In the terminal navigate to the correct build directory (usually cmake-build-debug or cmake-build-release). Run the mpirun command as standard and specify the built executable.
mpirun -n 2 ./day15
CLion can also be used to attached and debug limited number mpi runs. It is recommended to put a sleep statement at the beginning of the program because attachment is done after each mpi process starts. Without the sleep the program may finish before debugging starts.
- Add sleep statement to program.
- Place debug breakpoint in program.
- Build and launch (debug version) of program using the mpirun command outlined.
- Follow the CLion attach to process to attach to each of the mpi ranks. This must be done for each mpi rank.