Using valgrind to spot error in mpi code

风格不统一 提交于 2019-11-29 02:36:24

Note that with the invocation above,

valgrind --leak-check=yes mpirun -n 2 ./out

you are running valgrind on the program mpirun, which presumably has been extensively tested and works correctly, and not the program ./out, which you know to have a problem.

To run valgrind on your test program you will want to do:

mpirun -n 2 valgrind --leak-check=yes ./out

Which uses mpirun to launch 2 processes, each running valgrind --leak-check=yes ./out.

You can never go wrong with a Jonathan Dursi answer but let me just add that with more than one processor it can be a pain to read valgrind output.

Instead of outputting to the console, dump it to a log file. Of course you can't dump both processes to the same log file. valgrind interprets '%p' as the process id so you get two (or more) log files:

mpiexec -np 2 valgrind --leak-check=full \
    --show-reachable=yes --log-file=nc.vg.%p ./noncontig_coll2 -fname blah
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!