我想通过MPI3-RMA构建一个计数器并编写这个代码,其中变量a除了第一个等级之外增加:
,1,1,1,1,2,555,333,111,222,321,561,121,331,451,672
因此,在fetch_and_op-operation之后,主等级0应为PROGRAM fetchAndOpTest
USE mpi
IMPLICIT NONE
INTEGER, PARAMETER :: masterRank = 0
INTEGER, PARAMETER :: ONE = 1
INTEGER :: myRank = 0
INTEGER :: numProcs = 1
INTEGER :: win, ierror
INTEGER :: a
INTEGER (KIND=MPI_ADDRESS_KIND) &
:: lowerbound, sizeofint
CALL MPI_INIT(ierror)
CALL MPI_COMM_RANK(MPI_COMM_WORLD, myRank,ierror)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD,numProcs, ierror)
CALL MPI_TYPE_GET_EXTENT(MPI_INTEGER, lowerbound,sizeofint, ierror)
CALL MPI_WIN_CREATE(a,sizeofint,sizeofint,MPI_INFO_NULL,MPI_COMM_WORLD,win,ierror)
a = 0
WRITE(*,*) "Rank ",myRank,"meldet a = ",a
CALL MPI_WIN_FENCE(0,win,ierror)
IF(myRank .NE. masterRank) THEN
CALL MPI_Fetch_and_op(ONE,a,MPI_INTEGER,masterRank,0, MPI_SUM,win,ierror)
END IF
CALL MPI_WIN_FENCE(0,win,ierror)
WRITE(*,*) "Rank ",myRank,"meldet a = ",a
CALL MPI_WIN_FREE(win,ierror)
CALL MPI_FINALIZE(ierror)
END PROGRAM fetchAndOpTest
。但是a == numProcs-1
行会导致细分错误:
CALL MPI_Fetch_and_op(ONE,a,MPI_INTEGER, masterRank,0, MPI_SUM,win,ierror)
很难找到Fortran的RMA示例代码,但我试图擅长https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/593485的代码来解决我的问题。和以前一样的问题。
使用的编译器:mpiifort