以下简短的Fortran90程序只要包含MPI_GET调用就会崩溃。 等级1尝试从等级0读取值并在MPI_WIN_UNLOCK中挂起。等级0在MPI_BARRIER中尝试崩溃并出现分段错误。
我反复检查命令的语法,但它们似乎是正确的。 C / C ++中的类似代码在同一系统上运行。
我正在使用OpenMPI 1.4.3和gfortran 4.4.5。
PROGRAM mpitest
USE mpi
IMPLICIT NONE
INTEGER :: ierr, npe, rnk, win
INTEGER (KIND=MPI_ADDRESS_KIND) lowerbound, sizeofreal
REAL :: val = 1.0, oval = 2.0
CALL MPI_INIT( ierr )
CALL MPI_COMM_RANK( MPI_COMM_WORLD, rnk, ierr )
CALL MPI_COMM_SIZE( MPI_COMM_WORLD, npe, ierr )
CALL MPI_TYPE_GET_EXTENT(MPI_REAL, lowerbound, sizeofreal, ierr)
CALL MPI_WIN_CREATE(val, sizeofreal, sizeofreal, MPI_INFO_NULL, MPI_COMM_WORLD, win, ierr)
IF( rnk .EQ. 1 ) THEN
CALL MPI_WIN_LOCK( MPI_LOCK_SHARED, 0, 0, win, ierr )
CALL MPI_GET( oval, 1, MPI_REAL, 0, 0, 1, MPI_REAL, win, ierr )
CALL MPI_WIN_UNLOCK( 0, win, ierr )
END IF
CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
CALL MPI_WIN_FREE(win, ierr)
CALL MPI_FINALIZE(ierr)
END PROGRAM mpitest
mpif90 mpitest.f90
mpirun -n 2 ./a.out
*** Process received signal ***
Signal: Segmentation fault (11)
Signal code: Address not mapped (1)
Failing at address: 0x34006020a0
[ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x36420) [0x7f2d1c8c1420]
[ 1] /lib/x86_64-linux-gnu/libc.so.6(+0x13ae70) [0x7f2d1c9c5e70]
[ 2] /usr/lib/libmpi.so.0(ompi_convertor_pack+0x199) [0x7f2d1c61d629]
[ 3] /usr/lib/openmpi/lib/openmpi/mca_osc_pt2pt.so(+0x56b0) [0x7f2d166876b0]
[ 4] /usr/lib/openmpi/lib/openmpi/mca_osc_pt2pt.so(+0x3a81) [0x7f2d16685a81]
[ 5] /usr/lib/openmpi/lib/openmpi/mca_osc_pt2pt.so(+0x23ac) [0x7f2d166843ac]
[ 6] /usr/lib/libopen-pal.so.0(opal_progress+0x5b) [0x7f2d1ba700db]
[ 7] /usr/lib/libmpi.so.0(+0x35635) [0x7f2d1c60f635]
[ 8] /usr/lib/openmpi/lib/openmpi/mca_coll_tuned.so(+0x1afa) [0x7f2d1688eafa]
[ 9] /usr/lib/openmpi/lib/openmpi/mca_coll_tuned.so(+0x958f) [0x7f2d1689658f]
[10] /usr/lib/libmpi.so.0(MPI_Barrier+0x8d) [0x7f2d1c6250cd]
[11] /usr/lib/libmpi_f77.so.0(PMPI_BARRIER+0x13) [0x7f2d1cf661d3]
[12] ./a.out() [0x401003]
[13] ./a.out(main+0x34) [0x401058]
[14] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f2d1c8ac30d]
[15] ./a.out() [0x400da9]
*** End of error message ***
答案 0 :(得分:6)
这是一个棘手的问题,但有一个线索来自于这里的段错误发生在一个无关且完全安全的例行程序MPI_Barrier()
中。问题是存在堆栈损坏。
潜在的问题只是一个参数类型不匹配(我希望MPI Fortran绑定会捕获,但没有)。 MPI_Get的目标置换参数是类MPI_ADDRESS_KIND
的整数,但您只是将整数传递给它。
如果您使用lowerbound
作为目标偏移量,或者将您传入的0提升为明确的MPI_ADDRESS_KIND,那么您的程序就可以正常工作。