|
|
|
@ -31,6 +31,7 @@
|
|
|
|
|
!
|
|
|
|
|
module psi_i2_collective_mod
|
|
|
|
|
use psi_penv_mod
|
|
|
|
|
use psb_desc_const_mod
|
|
|
|
|
|
|
|
|
|
interface psb_max
|
|
|
|
|
module procedure psb_i2maxs, psb_i2maxv, psb_i2maxm
|
|
|
|
@ -349,7 +350,7 @@ contains
|
|
|
|
|
! SUM
|
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
subroutine psb_i2sums(ctxt,dat,root)
|
|
|
|
|
subroutine psb_i2sums(ctxt,dat,root,mode,request)
|
|
|
|
|
#ifdef MPI_MOD
|
|
|
|
|
use mpi
|
|
|
|
|
#endif
|
|
|
|
@ -360,10 +361,15 @@ contains
|
|
|
|
|
type(psb_ctxt_type), intent(in) :: ctxt
|
|
|
|
|
integer(psb_i2pk_), intent(inout) :: dat
|
|
|
|
|
integer(psb_mpk_), intent(in), optional :: root
|
|
|
|
|
integer(psb_ipk_), intent(in), optional :: mode
|
|
|
|
|
integer(psb_mpk_), intent(inout), optional :: request
|
|
|
|
|
integer(psb_mpk_) :: root_
|
|
|
|
|
integer(psb_i2pk_) :: dat_
|
|
|
|
|
integer(psb_mpk_) :: iam, np, info, icomm
|
|
|
|
|
integer(psb_mpk_) :: iam, np, info
|
|
|
|
|
integer(psb_mpk_) :: icomm
|
|
|
|
|
integer(psb_mpk_) :: status(mpi_status_size)
|
|
|
|
|
integer(psb_ipk_) :: iinfo
|
|
|
|
|
logical :: collective_start, collective_end, collective_sync
|
|
|
|
|
|
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
|
|
|
call psb_info(ctxt,iam,np)
|
|
|
|
@ -374,17 +380,41 @@ contains
|
|
|
|
|
root_ = -1
|
|
|
|
|
endif
|
|
|
|
|
icomm = psb_get_mpi_comm(ctxt)
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
call mpi_allreduce(dat,dat_,1,psb_mpi_i2pk_,mpi_sum,icomm,info)
|
|
|
|
|
dat = dat_
|
|
|
|
|
if (present(mode)) then
|
|
|
|
|
collective_sync = .false.
|
|
|
|
|
collective_start = iand(mode,psb_collective_start_) /= 0
|
|
|
|
|
collective_end = iand(mode,psb_collective_end_) /= 0
|
|
|
|
|
if (.not.present(request)) then
|
|
|
|
|
collective_sync = .true.
|
|
|
|
|
collective_start = .false.
|
|
|
|
|
collective_end = .false.
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
call mpi_reduce(dat,dat_,1,psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
if (iam == root_) dat = dat_
|
|
|
|
|
endif
|
|
|
|
|
collective_sync = .true.
|
|
|
|
|
collective_start = .false.
|
|
|
|
|
collective_end = .false.
|
|
|
|
|
end if
|
|
|
|
|
if (collective_sync) then
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
call mpi_allreduce(MPI_IN_PLACE,dat,1,psb_mpi_i2pk_,mpi_sum,icomm,info)
|
|
|
|
|
else
|
|
|
|
|
call mpi_reduce(MPI_IN_PLACE,dat,1,psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
if (collective_start) then
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
call mpi_iallreduce(MPI_IN_PLACE,dat,1,psb_mpi_i2pk_,mpi_sum,icomm,request,info)
|
|
|
|
|
else
|
|
|
|
|
call mpi_ireduce(MPI_IN_PLACE,dat,1,psb_mpi_i2pk_,mpi_sum,root_,icomm,request,info)
|
|
|
|
|
end if
|
|
|
|
|
else if (collective_end) then
|
|
|
|
|
call mpi_wait(request,status,info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
#endif
|
|
|
|
|
end subroutine psb_i2sums
|
|
|
|
|
|
|
|
|
|
subroutine psb_i2sumv(ctxt,dat,root)
|
|
|
|
|
subroutine psb_i2sumv(ctxt,dat,root,mode,request)
|
|
|
|
|
use psb_realloc_mod
|
|
|
|
|
#ifdef MPI_MOD
|
|
|
|
|
use mpi
|
|
|
|
@ -396,10 +426,14 @@ contains
|
|
|
|
|
type(psb_ctxt_type), intent(in) :: ctxt
|
|
|
|
|
integer(psb_i2pk_), intent(inout) :: dat(:)
|
|
|
|
|
integer(psb_mpk_), intent(in), optional :: root
|
|
|
|
|
integer(psb_ipk_), intent(in), optional :: mode
|
|
|
|
|
integer(psb_mpk_), intent(inout), optional :: request
|
|
|
|
|
integer(psb_mpk_) :: root_
|
|
|
|
|
integer(psb_i2pk_), allocatable :: dat_(:)
|
|
|
|
|
integer(psb_mpk_) :: iam, np, info, icomm
|
|
|
|
|
integer(psb_mpk_) :: iam, np, info
|
|
|
|
|
integer(psb_mpk_) :: icomm
|
|
|
|
|
integer(psb_mpk_) :: status(mpi_status_size)
|
|
|
|
|
integer(psb_ipk_) :: iinfo
|
|
|
|
|
logical :: collective_start, collective_end, collective_sync
|
|
|
|
|
|
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
|
|
|
call psb_info(ctxt,iam,np)
|
|
|
|
@ -410,25 +444,55 @@ contains
|
|
|
|
|
root_ = -1
|
|
|
|
|
endif
|
|
|
|
|
icomm = psb_get_mpi_comm(ctxt)
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
call psb_realloc(size(dat),dat_,iinfo)
|
|
|
|
|
dat_ = dat
|
|
|
|
|
if (iinfo == psb_success_) &
|
|
|
|
|
& call mpi_allreduce(dat_,dat,size(dat),psb_mpi_i2pk_,mpi_sum,icomm,info)
|
|
|
|
|
if (present(mode)) then
|
|
|
|
|
collective_sync = .false.
|
|
|
|
|
collective_start = iand(mode,psb_collective_start_) /= 0
|
|
|
|
|
collective_end = iand(mode,psb_collective_end_) /= 0
|
|
|
|
|
if (.not.present(request)) then
|
|
|
|
|
collective_sync = .true.
|
|
|
|
|
collective_start = .false.
|
|
|
|
|
collective_end = .false.
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
if (iam == root_) then
|
|
|
|
|
call psb_realloc(size(dat),dat_,iinfo)
|
|
|
|
|
dat_ = dat
|
|
|
|
|
call mpi_reduce(dat_,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
collective_sync = .true.
|
|
|
|
|
collective_start = .false.
|
|
|
|
|
collective_end = .false.
|
|
|
|
|
end if
|
|
|
|
|
if (collective_sync) then
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
if (iinfo == psb_success_) &
|
|
|
|
|
& call mpi_allreduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,icomm,info)
|
|
|
|
|
else
|
|
|
|
|
call psb_realloc(1,dat_,iinfo)
|
|
|
|
|
call mpi_reduce(dat,dat_,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
if (iam == root_) then
|
|
|
|
|
call mpi_reduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
else
|
|
|
|
|
call mpi_reduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
if (collective_start) then
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
if (iinfo == psb_success_) &
|
|
|
|
|
& call mpi_iallreduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,&
|
|
|
|
|
& icomm,request,info)
|
|
|
|
|
else
|
|
|
|
|
if (iam == root_) then
|
|
|
|
|
call mpi_ireduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,&
|
|
|
|
|
& icomm,request,info)
|
|
|
|
|
else
|
|
|
|
|
call mpi_ireduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,&
|
|
|
|
|
& icomm,request,info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
else if (collective_end) then
|
|
|
|
|
call mpi_wait(request,status,info)
|
|
|
|
|
endif
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
end subroutine psb_i2sumv
|
|
|
|
|
|
|
|
|
|
subroutine psb_i2summ(ctxt,dat,root)
|
|
|
|
|
subroutine psb_i2summ(ctxt,dat,root,mode,request)
|
|
|
|
|
use psb_realloc_mod
|
|
|
|
|
#ifdef MPI_MOD
|
|
|
|
|
use mpi
|
|
|
|
@ -440,10 +504,14 @@ contains
|
|
|
|
|
type(psb_ctxt_type), intent(in) :: ctxt
|
|
|
|
|
integer(psb_i2pk_), intent(inout) :: dat(:,:)
|
|
|
|
|
integer(psb_mpk_), intent(in), optional :: root
|
|
|
|
|
integer(psb_ipk_), intent(in), optional :: mode
|
|
|
|
|
integer(psb_mpk_), intent(inout), optional :: request
|
|
|
|
|
integer(psb_mpk_) :: root_
|
|
|
|
|
integer(psb_i2pk_), allocatable :: dat_(:,:)
|
|
|
|
|
integer(psb_mpk_) :: iam, np, info, icomm
|
|
|
|
|
integer(psb_mpk_) :: iam, np, info
|
|
|
|
|
integer(psb_mpk_) :: icomm
|
|
|
|
|
integer(psb_mpk_) :: status(mpi_status_size)
|
|
|
|
|
integer(psb_ipk_) :: iinfo
|
|
|
|
|
logical :: collective_start, collective_end, collective_sync
|
|
|
|
|
|
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
|
|
|
|
|
|
|
@ -455,21 +523,50 @@ contains
|
|
|
|
|
root_ = -1
|
|
|
|
|
endif
|
|
|
|
|
icomm = psb_get_mpi_comm(ctxt)
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
call psb_realloc(size(dat,1),size(dat,2),dat_,iinfo)
|
|
|
|
|
dat_ = dat
|
|
|
|
|
if (iinfo == psb_success_)&
|
|
|
|
|
& call mpi_allreduce(dat_,dat,size(dat),psb_mpi_i2pk_,mpi_sum,icomm,info)
|
|
|
|
|
if (present(mode)) then
|
|
|
|
|
collective_sync = .false.
|
|
|
|
|
collective_start = iand(mode,psb_collective_start_) /= 0
|
|
|
|
|
collective_end = iand(mode,psb_collective_end_) /= 0
|
|
|
|
|
if (.not.present(request)) then
|
|
|
|
|
collective_sync = .true.
|
|
|
|
|
collective_start = .false.
|
|
|
|
|
collective_end = .false.
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
if (iam == root_) then
|
|
|
|
|
call psb_realloc(size(dat,1),size(dat,2),dat_,iinfo)
|
|
|
|
|
dat_ = dat
|
|
|
|
|
call mpi_reduce(dat_,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
collective_sync = .true.
|
|
|
|
|
collective_start = .false.
|
|
|
|
|
collective_end = .false.
|
|
|
|
|
end if
|
|
|
|
|
if (collective_sync) then
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
if (iinfo == psb_success_) &
|
|
|
|
|
& call mpi_allreduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,icomm,info)
|
|
|
|
|
else
|
|
|
|
|
call psb_realloc(1,1,dat_,iinfo)
|
|
|
|
|
call mpi_reduce(dat,dat_,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
if (iam == root_) then
|
|
|
|
|
call mpi_reduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
else
|
|
|
|
|
call mpi_reduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,icomm,info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
if (collective_start) then
|
|
|
|
|
if (root_ == -1) then
|
|
|
|
|
if (iinfo == psb_success_) &
|
|
|
|
|
& call mpi_iallreduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,&
|
|
|
|
|
& icomm,request,info)
|
|
|
|
|
else
|
|
|
|
|
if (iam == root_) then
|
|
|
|
|
call mpi_ireduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,&
|
|
|
|
|
& icomm,request,info)
|
|
|
|
|
else
|
|
|
|
|
call mpi_ireduce(MPI_IN_PLACE,dat,size(dat),psb_mpi_i2pk_,mpi_sum,root_,&
|
|
|
|
|
& icomm,request,info)
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
else if (collective_end) then
|
|
|
|
|
call mpi_wait(request,status,info)
|
|
|
|
|
endif
|
|
|
|
|
end if
|
|
|
|
|
#endif
|
|
|
|
|
end subroutine psb_i2summ
|
|
|
|
|
|
|
|
|
|