|
|
|
@ -1,5 +1,5 @@
|
|
|
|
! debug out-of-bound
|
|
|
|
! debug out-of-bound
|
|
|
|
#define DBG_OOB
|
|
|
|
! #define DBG_OOB
|
|
|
|
! debug personal
|
|
|
|
! debug personal
|
|
|
|
! #define DBG_PER
|
|
|
|
! #define DBG_PER
|
|
|
|
|
|
|
|
|
|
|
|
@ -113,19 +113,19 @@ subroutine psi_dswapdata_vect(flag,beta,y,desc_a,work,info,data)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#include "scorep/SCOREP_User.inc"
|
|
|
|
#include "scorep/SCOREP_User.inc"
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), intent(in) :: flag
|
|
|
|
integer(psb_ipk_), intent(in) :: flag
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
class(psb_d_base_vect_type) :: y
|
|
|
|
class(psb_d_base_vect_type) :: y
|
|
|
|
real(psb_dpk_) :: beta
|
|
|
|
real(psb_dpk_) :: beta
|
|
|
|
real(psb_dpk_), target :: work(:)
|
|
|
|
real(psb_dpk_), target :: work(:)
|
|
|
|
type(psb_desc_type), target :: desc_a
|
|
|
|
type(psb_desc_type), target :: desc_a
|
|
|
|
integer(psb_ipk_), optional :: data
|
|
|
|
integer(psb_ipk_), optional :: data
|
|
|
|
|
|
|
|
|
|
|
|
! locals
|
|
|
|
! locals
|
|
|
|
integer(psb_ipk_) :: ictxt, np, me, icomm, idxs, idxr, totxch, data_, err_act
|
|
|
|
integer(psb_ipk_) :: ictxt, np, me, icomm, idxs, idxr, totxch, data_, err_act
|
|
|
|
class(psb_i_base_vect_type), pointer :: d_vidx
|
|
|
|
class(psb_i_base_vect_type), pointer :: d_vidx
|
|
|
|
character(len=20) :: name
|
|
|
|
character(len=20) :: name
|
|
|
|
logical :: swap_persistent
|
|
|
|
logical :: swap_persistent, swap_nonpersistent, do_alltoallv
|
|
|
|
|
|
|
|
|
|
|
|
info=psb_success_
|
|
|
|
info=psb_success_
|
|
|
|
name='psi_swap_datav'
|
|
|
|
name='psi_swap_datav'
|
|
|
|
@ -136,7 +136,9 @@ subroutine psi_dswapdata_vect(flag,beta,y,desc_a,work,info,data)
|
|
|
|
icomm = desc_a%get_mpic()
|
|
|
|
icomm = desc_a%get_mpic()
|
|
|
|
! TODO: get_mpic should be used to get dist_graph_comm, but for now this works
|
|
|
|
! TODO: get_mpic should be used to get dist_graph_comm, but for now this works
|
|
|
|
swap_persistent = iand(flag,psb_swap_persistent_) /= 0
|
|
|
|
swap_persistent = iand(flag,psb_swap_persistent_) /= 0
|
|
|
|
if (swap_persistent) then
|
|
|
|
swap_nonpersistent = iand(flag,psb_swap_nonpersistent_) /= 0
|
|
|
|
|
|
|
|
do_alltoallv = swap_persistent .or. swap_nonpersistent
|
|
|
|
|
|
|
|
if (do_alltoallv) then
|
|
|
|
if (allocated(desc_a%dist_graph_comm)) then
|
|
|
|
if (allocated(desc_a%dist_graph_comm)) then
|
|
|
|
! print *, "desc_a%dist_graph_comm", desc_a%dist_graph_comm
|
|
|
|
! print *, "desc_a%dist_graph_comm", desc_a%dist_graph_comm
|
|
|
|
icomm = desc_a%dist_graph_comm
|
|
|
|
icomm = desc_a%dist_graph_comm
|
|
|
|
@ -231,13 +233,14 @@ subroutine psi_dswap_vidx_vect(iictxt,iicomm,flag,beta,y,idx, &
|
|
|
|
& err_act, i, j, ii, ri, si, idx_pt, totsnd_, totrcv_,&
|
|
|
|
& err_act, i, j, ii, ri, si, idx_pt, totsnd_, totrcv_,&
|
|
|
|
& snd_pt, rcv_pt, pnti, n, ierr
|
|
|
|
& snd_pt, rcv_pt, pnti, n, ierr
|
|
|
|
logical :: swap_mpi, swap_sync, swap_send, swap_recv,&
|
|
|
|
logical :: swap_mpi, swap_sync, swap_send, swap_recv,&
|
|
|
|
& albf,do_send,do_recv, swap_persistent, do_persistent
|
|
|
|
& albf,do_send,do_recv, &
|
|
|
|
|
|
|
|
do_alltoallv, swap_persistent, swap_nonpersistent
|
|
|
|
logical, parameter :: usersend=.false., debug=.false.
|
|
|
|
logical, parameter :: usersend=.false., debug=.false.
|
|
|
|
character(len=20) :: name
|
|
|
|
character(len=20) :: name
|
|
|
|
|
|
|
|
|
|
|
|
!remove
|
|
|
|
!remove
|
|
|
|
integer :: status(MPI_STATUS_SIZE)
|
|
|
|
integer :: status(MPI_STATUS_SIZE)
|
|
|
|
real :: start_t, finish_t
|
|
|
|
real(psb_dpk_) :: start_t, finish_t, start_comm_t, end_comm_t
|
|
|
|
logical :: weight
|
|
|
|
logical :: weight
|
|
|
|
real(psb_dpk_) :: tmp
|
|
|
|
real(psb_dpk_) :: tmp
|
|
|
|
! score-p declaration
|
|
|
|
! score-p declaration
|
|
|
|
@ -260,14 +263,15 @@ subroutine psi_dswap_vidx_vect(iictxt,iicomm,flag,beta,y,idx, &
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
n=1
|
|
|
|
n=1
|
|
|
|
swap_mpi = iand(flag,psb_swap_mpi_) /= 0
|
|
|
|
swap_mpi = iand(flag,psb_swap_mpi_) /= 0
|
|
|
|
swap_sync = iand(flag,psb_swap_sync_) /= 0
|
|
|
|
swap_sync = iand(flag,psb_swap_sync_) /= 0
|
|
|
|
swap_send = iand(flag,psb_swap_send_) /= 0
|
|
|
|
swap_send = iand(flag,psb_swap_send_) /= 0
|
|
|
|
swap_recv = iand(flag,psb_swap_recv_) /= 0
|
|
|
|
swap_recv = iand(flag,psb_swap_recv_) /= 0
|
|
|
|
swap_persistent = iand(flag,psb_swap_persistent_) /= 0
|
|
|
|
swap_persistent = iand(flag,psb_swap_persistent_) /= 0
|
|
|
|
|
|
|
|
swap_nonpersistent = iand(flag,psb_swap_nonpersistent_) /= 0
|
|
|
|
do_send = swap_mpi .or. swap_sync .or. swap_send
|
|
|
|
do_send = swap_mpi .or. swap_sync .or. swap_send
|
|
|
|
do_recv = swap_mpi .or. swap_sync .or. swap_recv
|
|
|
|
do_recv = swap_mpi .or. swap_sync .or. swap_recv
|
|
|
|
do_persistent = swap_persistent
|
|
|
|
do_alltoallv = swap_persistent .or. swap_nonpersistent
|
|
|
|
|
|
|
|
|
|
|
|
totrcv_ = totrcv * n
|
|
|
|
totrcv_ = totrcv * n
|
|
|
|
totsnd_ = totsnd * n
|
|
|
|
totsnd_ = totsnd * n
|
|
|
|
@ -276,19 +280,17 @@ subroutine psi_dswap_vidx_vect(iictxt,iicomm,flag,beta,y,idx, &
|
|
|
|
|
|
|
|
|
|
|
|
! TODO check do_persistent twice, here and calling psi_dswapdata_vect,
|
|
|
|
! TODO check do_persistent twice, here and calling psi_dswapdata_vect,
|
|
|
|
! redudent but needed for now
|
|
|
|
! redudent but needed for now
|
|
|
|
if (do_persistent) then
|
|
|
|
if (do_alltoallv) then
|
|
|
|
! if not allocated, allocate buffers and create request
|
|
|
|
|
|
|
|
if (.not. allocated(y%p)) then
|
|
|
|
if (.not. allocated(y%p)) then
|
|
|
|
allocate(y%p)
|
|
|
|
allocate(y%p)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
if (.not. allocated(y%p%sndbuf)) then
|
|
|
|
if (.not. allocated(y%p%sndbuf)) then
|
|
|
|
|
|
|
|
! allocate time counters
|
|
|
|
|
|
|
|
allocate(y%p%alltoall_comm_time, y%p%total_time)
|
|
|
|
|
|
|
|
y%p%alltoall_comm_time = 0
|
|
|
|
|
|
|
|
! allocate buffers
|
|
|
|
allocate(y%p%sndbuf(totsnd), y%p%rcvbuf(totrcv))
|
|
|
|
allocate(y%p%sndbuf(totsnd), y%p%rcvbuf(totrcv))
|
|
|
|
allocate(y%p%rcv_count, y%p%snd_count)
|
|
|
|
allocate(y%p%rcv_count, y%p%snd_count)
|
|
|
|
#ifdef DBG_OOB ! debug out-of-bound
|
|
|
|
|
|
|
|
y%p%sndbuf = 0
|
|
|
|
|
|
|
|
y%p%rcvbuf = me + 10
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! get number of neighbors and graph so we know who to communicate with
|
|
|
|
! get number of neighbors and graph so we know who to communicate with
|
|
|
|
call MPI_Dist_graph_neighbors_count(icomm, y%p%rcv_count, &
|
|
|
|
call MPI_Dist_graph_neighbors_count(icomm, y%p%rcv_count, &
|
|
|
|
y%p%snd_count, weight, ierr) ! should weight go into psb_d_persis_vect_type??
|
|
|
|
y%p%snd_count, weight, ierr) ! should weight go into psb_d_persis_vect_type??
|
|
|
|
@ -339,49 +341,41 @@ subroutine psi_dswap_vidx_vect(iictxt,iicomm,flag,beta,y,idx, &
|
|
|
|
pnti = pnti + nerv + nesd + 3
|
|
|
|
pnti = pnti + nerv + nesd + 3
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DBG_PER
|
|
|
|
! #ifdef DBG_PER
|
|
|
|
print *, me, ":totxch=", totxch,"totsnd", totsnd, "totrcv", totrcv
|
|
|
|
! print *, me, ": totxch", totxch,"total to send", totsnd, "total to recv", totrcv
|
|
|
|
print *, me, ": rcv_count = ", y%p%rcv_count, "snd_count = ", y%p%snd_count
|
|
|
|
! print *, me, ": rcv_count = ", y%p%rcv_count, "snd_count = ", y%p%snd_count
|
|
|
|
print *, me, ": y%p%rcv_from =", y%p%rcv_from, "y%p%snd_to =", y%p%snd_to
|
|
|
|
! print *, me, ":y%p%snd_displs = ",y%p%snd_displs, &
|
|
|
|
print *, me, ":y%p%snd_counts", y%p%snd_counts, "y%p%snd_displs = ",y%p%snd_displs, &
|
|
|
|
! "y%p%rcv_displs",y%p%rcv_displs
|
|
|
|
"y%p%rcv_counts", y%p%rcv_counts, "y%p%rcv_displs",y%p%rcv_displs
|
|
|
|
! #endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
! ----------------------------
|
|
|
|
allocate(y%p%init_request)
|
|
|
|
! print *, me, ": totsnd=",totsnd ,"y%p%snd_to =", y%p%snd_to, &
|
|
|
|
y%p%init_request = -1
|
|
|
|
! "y%p%snd_counts = ", y%p%snd_counts
|
|
|
|
|
|
|
|
! print *, me, ": totrcv=",totrcv,"y%p%rcv_from =", y%p%rcv_from, &
|
|
|
|
! SCOREP_USER_REGION_BEGIN(MPIX_Neighbor_alltoallv_init_region, &
|
|
|
|
! "y%p%rcv_counts = ", y%p%rcv_counts
|
|
|
|
! "MPIX_Neighbor_alltoallv_init", SCOREP_USER_REGION_TYPE_FUNCTION)
|
|
|
|
! ----------------------------
|
|
|
|
! SCOREP_USER_REGION_BEGIN(artless_test, &
|
|
|
|
|
|
|
|
! "foo", SCOREP_USER_REGION_TYPE_COMMON)
|
|
|
|
|
|
|
|
call MPI_Barrier(MPI_COMM_WORLD,ierr)
|
|
|
|
! ----------------------------
|
|
|
|
call cpu_time(start_t)
|
|
|
|
! Persistant Request Creation
|
|
|
|
call MPIX_Neighbor_alltoallv_init(y%p%sndbuf, y%p%snd_counts, y%p%snd_displs, &
|
|
|
|
! ----------------------------
|
|
|
|
MPI_DOUBLE_PRECISION, y%p%rcvbuf, y%p%rcv_counts, y%p%rcv_displs, &
|
|
|
|
if (swap_persistent) then
|
|
|
|
MPI_DOUBLE_PRECISION, icomm, MPI_INFO_NULL, &
|
|
|
|
allocate(y%p%init_request)
|
|
|
|
y%p%init_request, ierr)
|
|
|
|
y%p%init_request = -1
|
|
|
|
! SCOREP_USER_REGION_END(artless_test)
|
|
|
|
start_t = MPI_Wtime()
|
|
|
|
! SCOREP_USER_REGION_END(MPIX_Neighbor_alltoallv_init_region)
|
|
|
|
call MPIX_Neighbor_alltoallv_init(y%p%sndbuf, y%p%snd_counts, y%p%snd_displs, &
|
|
|
|
call cpu_time(finish_t)
|
|
|
|
MPI_DOUBLE_PRECISION, y%p%rcvbuf, y%p%rcv_counts, y%p%rcv_displs, &
|
|
|
|
allocate(y%p%comm_create_time)
|
|
|
|
MPI_DOUBLE_PRECISION, icomm, MPI_INFO_NULL, &
|
|
|
|
y%p%comm_create_time = finish_t - start_t
|
|
|
|
y%p%init_request, ierr)
|
|
|
|
! print *,"cpu time of MPIX_Neighbor_alltoallv_init is", finish_t - start_t
|
|
|
|
finish_t = MPI_Wtime()
|
|
|
|
|
|
|
|
allocate(y%p%request_create_time)
|
|
|
|
if (ierr .ne. 0) then
|
|
|
|
y%p%request_create_time = finish_t - start_t
|
|
|
|
print *, "ERROR: MPIX_Neighbor_alltoallvinit ierr = ", ierr
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
! ----------------------------
|
|
|
|
! ARTLESS: SENDBUF LOOKS OK HERE!
|
|
|
|
! if (ierr .ne. 0) then
|
|
|
|
! call MPI_Barrier(MPI_COMM_WORLD, ierr)
|
|
|
|
! print *, "ERROR: MPIX_Neighbor_alltoallvinit ierr = ", ierr
|
|
|
|
! write(*,'(I2 A)', advance='no') me, ": sndbuf = "
|
|
|
|
! goto 9999
|
|
|
|
! print '(104 F4.0)', y%p%sndbuf
|
|
|
|
! end if
|
|
|
|
! call MPI_Barrier(MPI_COMM_WORLD, ierr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DBG_PER
|
|
|
|
|
|
|
|
print* ,me, ": end MPIX_Neighbor_alltoallv_init"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else ! send and recv buffers exist, need to pack send buffer
|
|
|
|
else ! send and recv buffers exist, need to pack send buffer
|
|
|
|
si = 1 ! sndbuf index
|
|
|
|
si = 1 ! sndbuf index
|
|
|
|
pnti = 1
|
|
|
|
pnti = 1
|
|
|
|
@ -405,38 +399,24 @@ subroutine psi_dswap_vidx_vect(iictxt,iicomm,flag,beta,y,idx, &
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end if ! end packing phase
|
|
|
|
end if ! end packing phase
|
|
|
|
|
|
|
|
|
|
|
|
! --- start communication
|
|
|
|
! ---- start communication ----
|
|
|
|
#ifdef DBG_PER
|
|
|
|
start_comm_t = MPI_Wtime()
|
|
|
|
if (.not. allocated(y%p%init_request)) then
|
|
|
|
! ---- if persistant ----
|
|
|
|
print *, "error: y%p%init_request should be allocated"
|
|
|
|
if (swap_persistent) then
|
|
|
|
goto 9999
|
|
|
|
call MPI_Start(y%p%init_request, ierr)
|
|
|
|
|
|
|
|
call MPI_Wait(y%p%init_request, status, ierr)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call MPI_Start(y%p%init_request, ierr)
|
|
|
|
! ---- if non-persistent ----
|
|
|
|
#ifdef DBG_PER
|
|
|
|
if (swap_nonpersistent) then
|
|
|
|
if (ierr .ne. 0) then
|
|
|
|
call MPI_Neighbor_alltoallv(y%p%sndbuf, y%p%snd_counts, y%p%snd_displs, &
|
|
|
|
print *, "ERROR: rank ",me,"has MPI_Start status(MPI_ERROR) = ", &
|
|
|
|
MPI_DOUBLE_PRECISION, y%p%rcvbuf, y%p%rcv_counts, y%p%rcv_displs, &
|
|
|
|
status(MPI_ERROR), "and ierr = ", ierr
|
|
|
|
MPI_DOUBLE_PRECISION, icomm, ierr)
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call MPI_Wait(y%p%init_request, status, ierr)
|
|
|
|
|
|
|
|
#ifdef DBG_PER
|
|
|
|
|
|
|
|
if (ierr .ne. 0) then
|
|
|
|
|
|
|
|
print *, "ERROR: rank ",me,"has MPI_Wait status(MPI_ERROR) = ", &
|
|
|
|
|
|
|
|
status(MPI_ERROR), "and ierr = ", ierr
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
#endif
|
|
|
|
end_comm_t = MPI_Wtime() - start_comm_t
|
|
|
|
|
|
|
|
y%p%alltoall_comm_time = y%p%alltoall_comm_time + end_comm_t
|
|
|
|
|
|
|
|
|
|
|
|
! write(*,'(I2 A)', advance='no') me, "::::: rcvbuf ="
|
|
|
|
|
|
|
|
! print '(104 F4.0)', y%p%rcvbuf
|
|
|
|
|
|
|
|
! ----scatter/unpack buffer----
|
|
|
|
! ----scatter/unpack buffer----
|
|
|
|
#ifdef DBG_PER
|
|
|
|
|
|
|
|
print*, me, ": begin scatter/unpack buffer"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pnti = 1
|
|
|
|
pnti = 1
|
|
|
|
rcv_pt = 1
|
|
|
|
rcv_pt = 1
|
|
|
|
do i=1, totxch
|
|
|
|
do i=1, totxch
|
|
|
|
|