I installed MPI using the Intel OneAPI HPC Toolkit and want to use GDB to debug simple MPI programs. My program is:
#include<iostream>
#include<mpi.h>
int main(){
MPI_Init(NULL,NULL);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
std::cout << "This is rank" << rank << std::endl;
double my_count = 100;
MPI_Sendrecv(&my_count, 1, MPI_DOUBLE, 0, 0, &my_count, 1, MPI_DOUBLE, 2, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Finalize();
return 0;
}
I am running the debug command as mentioned in the Intel website: mpiexec -gdb -n 4 ./test_gdb
. However I get the following problem:
mpigdb: attaching to Cannot access memory
mpigdb: hangup detected: while read from [0]
mpigdb: attaching to Cannot access memory
mpigdb: hangup detected: while read from [1]
mpigdb: attaching to Cannot access memory
mpigdb: hangup detected: while read from [2]
mpigdb: attaching to Cannot access memory
mpigdb: hangup detected: while read from [3]
[0-3] (mpigdb)
and it hangs/freezes. I can't run any gdb commands like break, start, run, quit etc. I know there are a few solutions using xterm etc, but I want to use gdb without xterm etc. Any help how to make it work is appreciated.
I have also tried mpiexec -n 1 gdb ./test_gdb : -n 3 ./test_gdb
,
Reading symbols from ./test_gdb...
(gdb) r
Starting program: /home/user/Documents/Development/C++/GDB_Test/test_gdb
This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.ubuntu.com
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
This is rank2
This is rank3
This is rank0
This is rank1
but it hangs too (as shown)