include 'mpif.h
‟
integer ierr, rank, size, MAXPROC, NTIMES, i, it
parameter (MAXPROC = 128, NTIMES = 10000)
integer ibuf(MAXPROC)
double precision time_start, time_finish
integer req(2*MAXPROC), statuses(MPI_STATUS_SIZE,
MAXPROC)
call MPI_INIT(ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size,
ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank,
ierr) if(rank .eq. 0) then
do i = 1, size-1
call MPI_RECV_INIT(ibuf(i), 0, MPI_INTEGER, i, 5,
&
MPI_COMM_WORLD, req(i), ierr)
call MPI_SEND_INIT(rank, 0, MPI_INTEGER, i, 6,
&
MPI_COMM_WORLD, req(size+i),
&
ierr)
end do
time_start = MPI_WTIME(ierr)
do it = 1, NTIMES
call MPI_STARTALL(size-1, req, ierr)
call MPI_WAITALL(size-1, req, statuses, ierr)
184
call MPI_STARTALL(size-1, req(size+l), ierr)
call MPI_WAITALL(size-1, req(size+l), statuses, ierr)
end do else
call MPI_RECV_INIT(ibuf(1), 0, MPI_INTEGER, 0, 6,
&
MPI_COMM_WORLD, req(l), ierr)
call MPI_SEND_INIT(rank, 0, MPI_INTEGER, 0, 5,
&
MPI_COMM_WORLD, req(2), ierr)
time_start = MPI_WTIME(ierr)
do it = 1, NTIMES
call MPI_START(req(2), ierr)
call MPI_WAIT(req(2), statuses, ierr)
call MPI_START(req(l), ierr)
call MPI_WAIT(req(l), statuses, ierr)
end do
end if
time_finish = MPI_WTIME(ierr)-
time_start
print *, 'rank = ', rank, „ all time = ',
&
(time_finish)/NTIMES
Достарыңызбен бөлісу: |