Using valgrind to spot error in mpi code

后端 未结 2 1881
栀梦
栀梦 2020-12-14 22:34

I have a code which works perfect in serial but with mpirun -n 2 ./out it gives the following error:

./out\': malloc(): smallbin double linked l         


        
相关标签:
2条回答
  • 2020-12-14 23:22

    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.

    0 讨论(0)
  • 2020-12-14 23:35

    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
    
    0 讨论(0)
提交回复
热议问题