|
15F 币
我在使用mpi3中的共享内存,需要在各个进程中共享的是很多个小矩阵块(大约2300个),当我第2045次调用MPI_Win_allocate_shared函数后,会报错access violation,一开始我以为是分配了太多导致内存不够了,于是我将每个矩阵块的大小设置为2*2,结果当我第2045次调用MPI_Win_allocate_shared时仍然会报错access violation。不知道有没有做过相关问题的朋友能帮忙分析一下问题,下面是我的代码
- program sharedmemtest
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_F_POINTER
use mpi
!use global_parameter
implicit none
integer, parameter :: dp = selected_real_kind(14,200)
integer ::hostcomm,hostrank
INTEGER(KIND=MPI_ADDRESS_KIND) :: windowsize
INTEGER :: disp_unit,my_rank,ierr,total
integer i,size
TYPE(C_PTR) ,allocatable:: baseptr(:)
type matrix !新定义一个复数矩阵类型
complex(8),pointer :: mat(:,:)
end type !=========================
TYPE(matrix),pointer :: NF_group_pair(:)
integer ,allocatable::win(:)
call MPI_INIT( ierr )
call MPI_COMM_RANK(MPI_COMM_WORLD,MY_RANK,IERR)
call MPI_COMM_SIZE(MPI_COMM_WORLD,Total,IERR)
CALL MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, hostcomm,ierr)
CALL MPI_Comm_rank(hostcomm, hostrank,ierr)
allocate(NF_group_pair(2300))
allocate(win(2300),baseptr(2300))
if (hostrank == 0) then
windowsize = int(2**2,MPI_ADDRESS_KIND)*16_MPI_ADDRESS_KIND
else
windowsize = 0_MPI_ADDRESS_KIND
end if
disp_unit = 1
!此处是循环分配共享内存,但是在第2045次的时候就会报错
do i = 1,2300
CALL MPI_Win_allocate_shared(windowsize, disp_unit, MPI_INFO_NULL, hostcomm, baseptr(i), win(i), ierr)
if (hostrank /= 0) then
CALL MPI_Win_shared_query(win(i), 0, windowsize, disp_unit, baseptr(i), ierr)
end if
CALL C_F_POINTER(baseptr(i), NF_group_pair(i)%mat,[2,2])
end do
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
call MPI_FINALIZE(IERR)
end program
|
|