diff --git a/base/modules/penv/psi_c_collective_mod.F90 b/base/modules/penv/psi_c_collective_mod.F90 index 56a70850..e6cbd83d 100644 --- a/base/modules/penv/psi_c_collective_mod.F90 +++ b/base/modules/penv/psi_c_collective_mod.F90 @@ -31,6 +31,7 @@ ! module psi_c_collective_mod use psi_penv_mod + use psi_comm_buffers_mod interface psb_sum @@ -66,6 +67,10 @@ module psi_c_collective_mod module procedure psb_c_simple_a2av end interface psb_simple_a2av + interface psb_triad_a2av + module procedure psb_c_e_triad_a2av, psb_c_m_triad_a2av + end interface psb_triad_a2av + contains @@ -896,5 +901,171 @@ contains end subroutine psb_c_simple_a2av + subroutine psb_c_m_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + complex(psb_spk_), intent(in) :: valsnd(:) + integer(psb_mpk_), intent(in) :: iasnd(:), jasnd(:) + complex(psb_spk_), intent(out) :: valrcv(:) + integer(psb_mpk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_complex_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_c_spk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_complex_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_c_spk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_c_m_triad_a2av + + subroutine psb_c_e_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + complex(psb_spk_), intent(in) :: valsnd(:) + integer(psb_epk_), intent(in) :: iasnd(:), jasnd(:) + complex(psb_spk_), intent(out) :: valrcv(:) + integer(psb_epk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_complex_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_c_spk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_complex_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_c_e_triad_a2av + 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 eaac1ac1..a87bd12c 100644 --- a/base/modules/penv/psi_d_collective_mod.F90 +++ b/base/modules/penv/psi_d_collective_mod.F90 @@ -31,6 +31,7 @@ ! module psi_d_collective_mod use psi_penv_mod + use psi_comm_buffers_mod interface psb_max module procedure psb_dmaxs, psb_dmaxv, psb_dmaxm, & @@ -80,6 +81,10 @@ module psi_d_collective_mod module procedure psb_d_simple_a2av end interface psb_simple_a2av + interface psb_triad_a2av + module procedure psb_d_e_triad_a2av, psb_d_m_triad_a2av + end interface psb_triad_a2av + contains @@ -1387,5 +1392,171 @@ contains end subroutine psb_d_simple_a2av + subroutine psb_d_m_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + real(psb_dpk_), intent(in) :: valsnd(:) + integer(psb_mpk_), intent(in) :: iasnd(:), jasnd(:) + real(psb_dpk_), intent(out) :: valrcv(:) + integer(psb_mpk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_double_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_double_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_d_m_triad_a2av + + subroutine psb_d_e_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + real(psb_dpk_), intent(in) :: valsnd(:) + integer(psb_epk_), intent(in) :: iasnd(:), jasnd(:) + real(psb_dpk_), intent(out) :: valrcv(:) + integer(psb_epk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_double_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_double_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_d_e_triad_a2av + 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 2cdb9637..192f7d7f 100644 --- a/base/modules/penv/psi_e_collective_mod.F90 +++ b/base/modules/penv/psi_e_collective_mod.F90 @@ -31,6 +31,7 @@ ! module psi_e_collective_mod use psi_penv_mod + use psi_comm_buffers_mod interface psb_max module procedure psb_emaxs, psb_emaxv, psb_emaxm, & @@ -76,6 +77,10 @@ module psi_e_collective_mod module procedure psb_e_simple_a2av end interface psb_simple_a2av + interface psb_triad_a2av + module procedure psb_e_e_triad_a2av, psb_e_m_triad_a2av + end interface psb_triad_a2av + contains @@ -1264,5 +1269,171 @@ contains end subroutine psb_e_simple_a2av + subroutine psb_e_m_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_epk_), intent(in) :: valsnd(:) + integer(psb_mpk_), intent(in) :: iasnd(:), jasnd(:) + integer(psb_epk_), intent(out) :: valrcv(:) + integer(psb_mpk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_int8_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_int8_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_e_m_triad_a2av + + subroutine psb_e_e_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_epk_), intent(in) :: valsnd(:) + integer(psb_epk_), intent(in) :: iasnd(:), jasnd(:) + integer(psb_epk_), intent(out) :: valrcv(:) + integer(psb_epk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_int8_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_int8_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_e_e_triad_a2av + 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 3d6ca380..35f56f87 100644 --- a/base/modules/penv/psi_m_collective_mod.F90 +++ b/base/modules/penv/psi_m_collective_mod.F90 @@ -31,6 +31,7 @@ ! module psi_m_collective_mod use psi_penv_mod + use psi_comm_buffers_mod interface psb_max module procedure psb_mmaxs, psb_mmaxv, psb_mmaxm, & @@ -76,6 +77,10 @@ module psi_m_collective_mod module procedure psb_m_simple_a2av end interface psb_simple_a2av + interface psb_triad_a2av + module procedure psb_m_e_triad_a2av, psb_m_m_triad_a2av + end interface psb_triad_a2av + contains @@ -1264,5 +1269,171 @@ contains end subroutine psb_m_simple_a2av + subroutine psb_m_m_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: valsnd(:) + integer(psb_mpk_), intent(in) :: iasnd(:), jasnd(:) + integer(psb_mpk_), intent(out) :: valrcv(:) + integer(psb_mpk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_int4_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_int4_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_m_m_triad_a2av + + subroutine psb_m_e_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + integer(psb_mpk_), intent(in) :: valsnd(:) + integer(psb_epk_), intent(in) :: iasnd(:), jasnd(:) + integer(psb_mpk_), intent(out) :: valrcv(:) + integer(psb_epk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_int4_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_int4_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_m_e_triad_a2av + 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 c0e5a778..7e76d60a 100644 --- a/base/modules/penv/psi_s_collective_mod.F90 +++ b/base/modules/penv/psi_s_collective_mod.F90 @@ -31,6 +31,7 @@ ! module psi_s_collective_mod use psi_penv_mod + use psi_comm_buffers_mod interface psb_max module procedure psb_smaxs, psb_smaxv, psb_smaxm, & @@ -80,6 +81,10 @@ module psi_s_collective_mod module procedure psb_s_simple_a2av end interface psb_simple_a2av + interface psb_triad_a2av + module procedure psb_s_e_triad_a2av, psb_s_m_triad_a2av + end interface psb_triad_a2av + contains @@ -1387,5 +1392,171 @@ contains end subroutine psb_s_simple_a2av + subroutine psb_s_m_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + real(psb_spk_), intent(in) :: valsnd(:) + integer(psb_mpk_), intent(in) :: iasnd(:), jasnd(:) + real(psb_spk_), intent(out) :: valrcv(:) + integer(psb_mpk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_real_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_r_spk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_real_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_spk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_s_m_triad_a2av + + subroutine psb_s_e_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + real(psb_spk_), intent(in) :: valsnd(:) + integer(psb_epk_), intent(in) :: iasnd(:), jasnd(:) + real(psb_spk_), intent(out) :: valrcv(:) + integer(psb_epk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_real_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_r_spk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_real_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_s_e_triad_a2av + 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 b062a03e..71693ac0 100644 --- a/base/modules/penv/psi_z_collective_mod.F90 +++ b/base/modules/penv/psi_z_collective_mod.F90 @@ -31,6 +31,7 @@ ! module psi_z_collective_mod use psi_penv_mod + use psi_comm_buffers_mod interface psb_sum @@ -66,6 +67,10 @@ module psi_z_collective_mod module procedure psb_z_simple_a2av end interface psb_simple_a2av + interface psb_triad_a2av + module procedure psb_z_e_triad_a2av, psb_z_m_triad_a2av + end interface psb_triad_a2av + contains @@ -896,5 +901,171 @@ contains end subroutine psb_z_simple_a2av + subroutine psb_z_m_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + complex(psb_dpk_), intent(in) :: valsnd(:) + integer(psb_mpk_), intent(in) :: iasnd(:), jasnd(:) + complex(psb_dpk_), intent(out) :: valrcv(:) + integer(psb_mpk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_dcomplex_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_c_dpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_dcomplex_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_c_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_mpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_z_m_triad_a2av + + subroutine psb_z_e_triad_a2av(valsnd,iasnd,jasnd,sdsz,bsdindx,& + & valrcv,iarcv,jarcv,rvsz,brvindx,ictxt,info) +#ifdef MPI_MOD + use mpi +#endif + implicit none +#ifdef MPI_H + include 'mpif.h' +#endif + complex(psb_dpk_), intent(in) :: valsnd(:) + integer(psb_epk_), intent(in) :: iasnd(:), jasnd(:) + complex(psb_dpk_), intent(out) :: valrcv(:) + integer(psb_epk_), intent(out) :: iarcv(:), jarcv(:) + integer(psb_mpk_), intent(in) :: bsdindx(:), brvindx(:), sdsz(:), rvsz(:) + integer(psb_ipk_), intent(in) :: ictxt + integer(psb_ipk_), intent(out) :: info + + !Local variables + integer(psb_ipk_) :: iam, np, i,j,k, ip, ipx, idx, sz, counter + integer(psb_mpk_) :: proc_to_comm, p2ptag, p2pstat(mpi_status_size), iret, icomm + integer(psb_mpk_), allocatable :: prcid(:), rvhd(:,:) + + call psb_info(ictxt,iam,np) + + icomm = psb_get_mpi_comm(ictxt) + + if (min(size(bsdindx),size(brvindx),size(sdsz),size(rvsz)) 0) then + prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = brvindx(ip+1) + p2ptag = psb_dcomplex_tag + call mpi_irecv(valrcv(idx+1:idx+sz),sz,& + & psb_mpi_c_dpk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,1),iret) + p2ptag = psb_int_swap_tag + call mpi_irecv(iarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,2),iret) + call mpi_irecv(jarcv(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,rvhd(ip+1,3),iret) + end if + Enddo + + + do ip = 0, np-1 + sz = sdsz(ip+1) + if (sz > 0) then + if (prcid(ip+1)<0) prcid(ip+1) = psb_get_mpi_rank(ictxt,ip) + idx = bsdindx(ip+1) + p2ptag = psb_dcomplex_tag + call mpi_send(valsnd(idx+1:idx+sz),sz,& + & psb_mpi_r_dpk_,prcid(ip+1),& + & p2ptag, icomm,iret) + p2ptag = psb_int_swap_tag + call mpi_send(iasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + call mpi_send(jasnd(idx+1:idx+sz),sz,& + & psb_mpi_epk_,prcid(ip+1),& + & p2ptag, icomm,iret) + end if + Enddo + + do ip = 0, np-1 + sz = rvsz(ip+1) + if (sz > 0) then + call mpi_wait(rvhd(ip+1,1),p2pstat,iret) + call mpi_wait(rvhd(ip+1,2),p2pstat,iret) + call mpi_wait(rvhd(ip+1,3),p2pstat,iret) + end if + Enddo + + end subroutine psb_z_e_triad_a2av + end module psi_z_collective_mod