This is a very simple program downloaded from web,
But there's runtime error in MPI_BUFFER_DETACH,
I've tried other fortran programs using MPI_BUFFER_DETACH, still a similar
error occurs.
But the error ONLY occur in Fortran, C has no problem.
Also, I've tried comment the line with MPI_BUFFER_DETACH, then it runs
smoothly
Below is the code:
program page11
CCCCCCCCCCCCC
C
C MPI_BSEND
C MPI_RECV
C MPI_BUFFER_ATTACH
C MPI_BUFFER_DETACH
C 2 nodes
C
CCCCCCCCCCCC
include 'mpif.h'
integer i,j,k
integer myid, numprocs, ierr
integer status(MPI_STATUS_SIZE)
real square(100)
real buffer(132)
real squaretot
do i=1,100
square(i)=0.0
enddo
squaretot=0.0
C
call MPI_INIT( ierr )
call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
print *,'I am node ',myid,' out of ',numprocs,' nodes.'
if(myid.eq.1) then
do j=1,100
square(j)=j**2
squaretot=squaretot+square(j)
enddo
print *,'After loop squaretot is ',squaretot
C
C MPI_BSEND_OVERHEAD = 32 words, MPI_REAL here = 4 bytes, therefore
C buffer_attach value = number of entries (here 100) X 4 + 128 = 528
C
call MPI_BUFFER_ATTACH(buffer,528,ierr)
call MPI_BSEND(square,100,MPI_REAL,0,99,MPI_COMM_WORLD,ierr)
call MPI_BUFFER_DETACH(buffer,528,ierr)
endif
if(myid.eq.0) then
call MPI_RECV(square,100,MPI_REAL,1,99,
1 MPI_COMM_WORLD,status,ierr)
do k=1,100
squaretot=squaretot+square(k)
enddo
print *,'After receive squaretot is ',squaretot
endif
C
call MPI_FINALIZE(ierr)
end
Below is the output:
I am node 0 out of 2 nodes.
I am node 1 out of 2 nodes.
After loop squaretot is 338350.
MPI process rank 1 (n0, p27065) caught a SIGSEGV in MPI_Buffer_detach.
Rank (1, MPI_COMM_WORLD): Call stack within LAM:
Rank (1, MPI_COMM_WORLD): - MPI_Buffer_detach()
Rank (1, MPI_COMM_WORLD): - main()
After receive squaretot is 338350.
Thanks in advance,
P.N. Lai
|