Valgrind与mpi

时间:2018-03-19 13:41:58

标签: fortran mpi valgrind

我搜索了很多,但我没有找到任何明确的答案。我试图使用valgrind在mpi代码中找到内存泄漏问题。我正在将代码缩减到最小状态以便隔离问题,然后我意识到即使是如下的简单代码:

program foo
  include "mpi.h"
  implicit none
  integer :: ierr

  call MPI_init(ierr)
  call MPI_finalize(ierr)
end program

发生内存泄漏。使用

进行编译
mpif90 foo.f90

并正在运行

mpirun -n 1 valgrind ./a.out 

给出:

==523== Memcheck, a memory error detector
==523== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==523== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==523== Command: ./a.out
==523==
==523== Conditional jump or move depends on uninitialised value(s)
==523==    at 0x5AA4236: opal_value_unload (in /home/francesco/openmpi/lib/libopen-pal.so.20.10.1)
==523==    by 0x57C8C0A: ompi_proc_complete_init (in /home/francesco/openmpi/lib/libmpi.so.20.10.1)
==523==    by 0x57CC5FE: ompi_mpi_init (in /home/francesco/openmpi/lib/libmpi.so.20.10.1)
==523==    by 0x57EBD52: PMPI_Init (in /home/francesco/openmpi/lib/libmpi.so.20.10.1)
==523==    by 0x4E7E5A7: MPI_INIT (in /home/francesco/openmpi/lib/libmpi_mpifh.so.20.11.0)
==523==    by 0x4009FE: MAIN__ (in /mnt/c/Users/Utente/Lavoro/prove/MPI/a.out)
==523==    by 0x400A46: main (in /mnt/c/Users/Utente/Lavoro/prove/MPI/a.out)
==523==
==523==
==523== HEAP SUMMARY:
==523==     in use at exit: 83,013 bytes in 609 blocks
==523==   total heap usage: 16,641 allocs, 16,032 frees, 3,629,830 bytes allocated
==523==
==523== LEAK SUMMARY:
==523==    definitely lost: 11,711 bytes in 13 blocks
==523==    indirectly lost: 1,094 bytes in 28 blocks
==523==      possibly lost: 0 bytes in 0 blocks
==523==    still reachable: 70,208 bytes in 568 blocks
==523==         suppressed: 0 bytes in 0 blocks
==523== Rerun with --leak-check=full to see details of leaked memory
==523==
==523== For counts of detected and suppressed errors, rerun with: -v
==523== Use --track-origins=yes to see where uninitialised values come from
==523== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

我的问题是:

1)为什么这个简单的代码会导致内存泄漏?我做错了什么或遗失了什么?

2)我读到valgrind可以用mpi给出误报,如果是这样的话,我怎么能理解哪些错误与valgrind-mpi不兼容有关,哪些与我在代码中的错误有关?

0 个答案:

没有答案