我正在运行一个屏障程序,其中我使用-np
选项提供了多个进程。我的程序在1个进程中正常运行但在数量增加时SEGFAULTS。我想知道哪条线导致了内存故障。
我最初尝试valgrind mpirun -np 2 tournament 2
,但它只是提供以下输出:
[ubuntu:14556] *** Process received signal ***
[ubuntu:14556] Signal: Segmentation fault (11)
[ubuntu:14556] Signal code: Address not mapped (1)
[ubuntu:14556] Failing at address: 0x7fff0000005a
[ubuntu:14556] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0xfbb0) [0x7fe3f5c4dbb0]
[ubuntu:14556] [ 1] tournament() [0x40115a]
[ubuntu:14556] [ 2] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fe3f5897de5]
[ubuntu:14556] [ 3] tournament() [0x4009d9]
[ubuntu:14556] *** End of error message ***
[ubuntu:14557] *** Process received signal ***
[ubuntu:14557] Signal: Segmentation fault (11)
[ubuntu:14557] Signal code: (128)
[ubuntu:14557] Failing at address: (nil)
[ubuntu:14557] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0xfbb0) [0x7f23c81e4bb0]
[ubuntu:14557] [ 1] tournament() [0x400f61]
[ubuntu:14557] [ 2] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f23c7e2ede5]
[ubuntu:14557] [ 3] tournament() [0x4009d9]
[ubuntu:14557] *** End of error message ***
然后我认为我需要为此生成符号表,所以我给了mpicc tournament.c -o tournament -fopenmp -lm -g
。我仍然为valgrind获得相同的输出。
如何使用Valgrind和OpenMPI知道哪一行给我SEGFAULT
?