From 2f07fc52200b575b367948b619cadb08e55fc9b4 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Thu, 1 Aug 2019 14:55:30 +0100 Subject: [PATCH] New scan_sum and exscan_sum collectives. --- base/modules/penv/psi_c_collective_mod.F90 | 66 +++++++++++++++++++++- base/modules/penv/psi_d_collective_mod.F90 | 66 +++++++++++++++++++++- base/modules/penv/psi_e_collective_mod.F90 | 66 +++++++++++++++++++++- base/modules/penv/psi_m_collective_mod.F90 | 66 +++++++++++++++++++++- base/modules/penv/psi_s_collective_mod.F90 | 66 +++++++++++++++++++++- base/modules/penv/psi_z_collective_mod.F90 | 66 +++++++++++++++++++++- 6 files changed, 390 insertions(+), 6 deletions(-) diff --git a/base/modules/penv/psi_c_collective_mod.F90 b/base/modules/penv/psi_c_collective_mod.F90 index 2ae40807..3f95038d 100644 --- a/base/modules/penv/psi_c_collective_mod.F90 +++ b/base/modules/penv/psi_c_collective_mod.F90 @@ -52,7 +52,17 @@ module psi_c_collective_mod interface psb_bcast module procedure psb_cbcasts, psb_cbcastv, psb_cbcastm, & & psb_cbcasts_ec, psb_cbcastv_ec, psb_cbcastm_ec - end interface + end interface psb_bcast + + interface psb_scan_sum + module procedure psb_cscan_sums + end interface psb_scan_sum + + interface psb_exscan_sum + module procedure psb_cexscan_sums + end interface psb_exscan_sum + + contains @@ -740,5 +750,59 @@ contains end subroutine psb_cbcastm_ec + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! + ! SCAN + ! + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine psb_cscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + complex(psb_spk_), intent(inout) :: dat + complex(psb_spk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_c_spk_,mpi_sum,ictxt,info) + dat = dat_ +#endif + end subroutine psb_cscan_sums + + + subroutine psb_cexscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + complex(psb_spk_), intent(inout) :: dat + complex(psb_spk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_c_spk_,mpi_sum,ictxt,info) + dat = dat_ +#else + dat = 0 +#endif + end subroutine psb_cexscan_sums + + end module psi_c_collective_mod diff --git a/base/modules/penv/psi_d_collective_mod.F90 b/base/modules/penv/psi_d_collective_mod.F90 index 537cf3a0..58f919eb 100644 --- a/base/modules/penv/psi_d_collective_mod.F90 +++ b/base/modules/penv/psi_d_collective_mod.F90 @@ -66,7 +66,17 @@ module psi_d_collective_mod interface psb_bcast module procedure psb_dbcasts, psb_dbcastv, psb_dbcastm, & & psb_dbcasts_ec, psb_dbcastv_ec, psb_dbcastm_ec - end interface + end interface psb_bcast + + interface psb_scan_sum + module procedure psb_dscan_sums + end interface psb_scan_sum + + interface psb_exscan_sum + module procedure psb_dexscan_sums + end interface psb_exscan_sum + + contains @@ -1231,5 +1241,59 @@ contains end subroutine psb_dbcastm_ec + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! + ! SCAN + ! + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine psb_dscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + real(psb_dpk_), intent(inout) :: dat + real(psb_dpk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_r_dpk_,mpi_sum,ictxt,info) + dat = dat_ +#endif + end subroutine psb_dscan_sums + + + subroutine psb_dexscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + real(psb_dpk_), intent(inout) :: dat + real(psb_dpk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_r_dpk_,mpi_sum,ictxt,info) + dat = dat_ +#else + dat = 0 +#endif + end subroutine psb_dexscan_sums + + end module psi_d_collective_mod diff --git a/base/modules/penv/psi_e_collective_mod.F90 b/base/modules/penv/psi_e_collective_mod.F90 index e0053915..7d2ff4b0 100644 --- a/base/modules/penv/psi_e_collective_mod.F90 +++ b/base/modules/penv/psi_e_collective_mod.F90 @@ -62,7 +62,17 @@ module psi_e_collective_mod interface psb_bcast module procedure psb_ebcasts, psb_ebcastv, psb_ebcastm, & & psb_ebcasts_ec, psb_ebcastv_ec, psb_ebcastm_ec - end interface + end interface psb_bcast + + interface psb_scan_sum + module procedure psb_escan_sums + end interface psb_scan_sum + + interface psb_exscan_sum + module procedure psb_eexscan_sums + end interface psb_exscan_sum + + contains @@ -1108,5 +1118,59 @@ contains end subroutine psb_ebcastm_ec + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! + ! SCAN + ! + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine psb_escan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + integer(psb_epk_), intent(inout) :: dat + integer(psb_epk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_epk_,mpi_sum,ictxt,info) + dat = dat_ +#endif + end subroutine psb_escan_sums + + + subroutine psb_eexscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + integer(psb_epk_), intent(inout) :: dat + integer(psb_epk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_epk_,mpi_sum,ictxt,info) + dat = dat_ +#else + dat = 0 +#endif + end subroutine psb_eexscan_sums + + end module psi_e_collective_mod diff --git a/base/modules/penv/psi_m_collective_mod.F90 b/base/modules/penv/psi_m_collective_mod.F90 index d0ca82d7..bd1eefd4 100644 --- a/base/modules/penv/psi_m_collective_mod.F90 +++ b/base/modules/penv/psi_m_collective_mod.F90 @@ -62,7 +62,17 @@ module psi_m_collective_mod interface psb_bcast module procedure psb_mbcasts, psb_mbcastv, psb_mbcastm, & & psb_mbcasts_ec, psb_mbcastv_ec, psb_mbcastm_ec - end interface + end interface psb_bcast + + interface psb_scan_sum + module procedure psb_mscan_sums + end interface psb_scan_sum + + interface psb_exscan_sum + module procedure psb_mexscan_sums + end interface psb_exscan_sum + + contains @@ -1108,5 +1118,59 @@ contains end subroutine psb_mbcastm_ec + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! + ! SCAN + ! + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine psb_mscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + integer(psb_mpk_), intent(inout) :: dat + integer(psb_mpk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_mpk_,mpi_sum,ictxt,info) + dat = dat_ +#endif + end subroutine psb_mscan_sums + + + subroutine psb_mexscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + integer(psb_mpk_), intent(inout) :: dat + integer(psb_mpk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_mpk_,mpi_sum,ictxt,info) + dat = dat_ +#else + dat = 0 +#endif + end subroutine psb_mexscan_sums + + end module psi_m_collective_mod diff --git a/base/modules/penv/psi_s_collective_mod.F90 b/base/modules/penv/psi_s_collective_mod.F90 index 0c985f2d..5d86d581 100644 --- a/base/modules/penv/psi_s_collective_mod.F90 +++ b/base/modules/penv/psi_s_collective_mod.F90 @@ -66,7 +66,17 @@ module psi_s_collective_mod interface psb_bcast module procedure psb_sbcasts, psb_sbcastv, psb_sbcastm, & & psb_sbcasts_ec, psb_sbcastv_ec, psb_sbcastm_ec - end interface + end interface psb_bcast + + interface psb_scan_sum + module procedure psb_sscan_sums + end interface psb_scan_sum + + interface psb_exscan_sum + module procedure psb_sexscan_sums + end interface psb_exscan_sum + + contains @@ -1231,5 +1241,59 @@ contains end subroutine psb_sbcastm_ec + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! + ! SCAN + ! + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine psb_sscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + real(psb_spk_), intent(inout) :: dat + real(psb_spk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_r_spk_,mpi_sum,ictxt,info) + dat = dat_ +#endif + end subroutine psb_sscan_sums + + + subroutine psb_sexscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + real(psb_spk_), intent(inout) :: dat + real(psb_spk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_r_spk_,mpi_sum,ictxt,info) + dat = dat_ +#else + dat = 0 +#endif + end subroutine psb_sexscan_sums + + end module psi_s_collective_mod diff --git a/base/modules/penv/psi_z_collective_mod.F90 b/base/modules/penv/psi_z_collective_mod.F90 index 3ed7e4f6..7176e02a 100644 --- a/base/modules/penv/psi_z_collective_mod.F90 +++ b/base/modules/penv/psi_z_collective_mod.F90 @@ -52,7 +52,17 @@ module psi_z_collective_mod interface psb_bcast module procedure psb_zbcasts, psb_zbcastv, psb_zbcastm, & & psb_zbcasts_ec, psb_zbcastv_ec, psb_zbcastm_ec - end interface + end interface psb_bcast + + interface psb_scan_sum + module procedure psb_zscan_sums + end interface psb_scan_sum + + interface psb_exscan_sum + module procedure psb_zexscan_sums + end interface psb_exscan_sum + + contains @@ -740,5 +750,59 @@ contains end subroutine psb_zbcastm_ec + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! + ! SCAN + ! + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine psb_zscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + complex(psb_dpk_), intent(inout) :: dat + complex(psb_dpk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_c_dpk_,mpi_sum,ictxt,info) + dat = dat_ +#endif + end subroutine psb_zscan_sums + + + subroutine psb_zexscan_sums(ictxt,dat) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: ictxt + complex(psb_dpk_), intent(inout) :: dat + complex(psb_dpk_) :: dat_ + integer(psb_mpk_) :: iam, np, info + integer(psb_ipk_) :: iinfo + + +#if !defined(SERIAL_MPI) + call psb_info(ictxt,iam,np) + call mpi_scan(dat,dat_,1,psb_mpi_c_dpk_,mpi_sum,ictxt,info) + dat = dat_ +#else + dat = 0 +#endif + end subroutine psb_zexscan_sums + + end module psi_z_collective_mod