psblas:
base/internals/Makefile base/internals/psi_dswapdata.F90 base/internals/psi_dswaptran.F90 base/internals/psi_iswapdata.F90 base/internals/psi_iswaptran.F90 base/internals/psi_zswapdata.F90 base/internals/psi_zswaptran.F90 base/modules/Makefile base/modules/psb_base_mod.f90 base/modules/psb_desc_type.f90 base/modules/psb_inter_desc_type.f90 base/modules/psb_realloc_mod.F90 base/modules/psb_serial_mod.f90 base/modules/psb_spmat_type.f90 base/modules/psb_tools_mod.f90 base/modules/psi_mod.f90 base/modules/psi_serial_mod.f90 base/tools/psb_cdcpy.f90 base/tools/psb_dcdovr.F90 base/tools/psb_glob_to_loc.f90 base/tools/psb_loc_to_glob.f90 base/tools/psb_zcdovr.F90 Merged changes from psblas-intermesh branch up to rev. 2809.psblas3-type-indexed
parent
348a88de3b
commit
9dc5a8bc11
@ -0,0 +1,655 @@
|
||||
module psb_inter_descriptor_type
|
||||
use psb_spmat_type
|
||||
use psb_descriptor_type
|
||||
|
||||
|
||||
|
||||
! Inter-descriptor mapping data structures.
|
||||
integer, parameter :: psb_map_kind_ = 1
|
||||
integer, parameter :: psb_map_data_ = 2
|
||||
integer, parameter :: psb_map_integer_ = 1
|
||||
integer, parameter :: psb_map_double_ = 2
|
||||
integer, parameter :: psb_map_complex_ = 3
|
||||
|
||||
integer, parameter :: psb_fw_tmp_kind_ = 5
|
||||
integer, parameter :: psb_fw_tmp_sz_ = 6
|
||||
integer, parameter :: psb_bk_tmp_kind_ = 7
|
||||
integer, parameter :: psb_bk_tmp_sz_ = 8
|
||||
integer, parameter :: psb_itd_data_size_=20
|
||||
|
||||
|
||||
type psb_d_map_type
|
||||
type(psb_dspmat_type) :: map_fw, map_bk
|
||||
end type psb_d_map_type
|
||||
type psb_z_map_type
|
||||
type(psb_zspmat_type) :: map_fw, map_bk
|
||||
end type psb_z_map_type
|
||||
|
||||
type psb_inter_desc_type
|
||||
integer, allocatable :: itd_data(:)
|
||||
type(psb_desc_type), pointer :: desc_1=>null(), desc_2=>null()
|
||||
integer, allocatable :: exch_fw_idx(:), exch_bk_idx(:)
|
||||
type(psb_d_map_type) :: dmap
|
||||
type(psb_z_map_type) :: zmap
|
||||
end type psb_inter_desc_type
|
||||
|
||||
interface psb_forward_map
|
||||
module procedure psb_d_forward_map, psb_z_forward_map
|
||||
end interface
|
||||
|
||||
interface psb_backward_map
|
||||
module procedure psb_d_backward_map, psb_z_backward_map
|
||||
end interface
|
||||
|
||||
interface psb_is_ok_desc
|
||||
module procedure psb_is_ok_inter_desc
|
||||
end interface
|
||||
|
||||
interface psb_is_asb_desc
|
||||
module procedure psb_is_asb_inter_desc
|
||||
end interface
|
||||
|
||||
interface psb_inter_desc
|
||||
module procedure psb_d_inter_desc, psb_d_inter_desc_noidx,&
|
||||
& psb_z_inter_desc, psb_z_inter_desc_noidx
|
||||
end interface
|
||||
|
||||
interface psb_sizeof
|
||||
module procedure psb_itd_sizeof,&
|
||||
& psb_d_map_sizeof, psb_z_map_sizeof
|
||||
end interface
|
||||
|
||||
|
||||
contains
|
||||
|
||||
function psb_cd_get_map_kind(desc)
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
Integer :: psb_cd_get_map_kind
|
||||
if (psb_is_ok_desc(desc)) then
|
||||
psb_cd_get_map_kind = desc%itd_data(psb_map_kind_)
|
||||
else
|
||||
psb_cd_get_map_kind = -1
|
||||
end if
|
||||
end function psb_cd_get_map_kind
|
||||
|
||||
subroutine psb_cd_set_map_kind(map_kind,desc)
|
||||
implicit none
|
||||
integer, intent(in) :: map_kind
|
||||
type(psb_inter_desc_type), intent(inout) :: desc
|
||||
|
||||
desc%itd_data(psb_map_kind_) = map_kind
|
||||
|
||||
end subroutine psb_cd_set_map_kind
|
||||
|
||||
function psb_cd_get_map_data(desc)
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
Integer :: psb_cd_get_map_data
|
||||
if (psb_is_ok_desc(desc)) then
|
||||
psb_cd_get_map_data = desc%itd_data(psb_map_data_)
|
||||
else
|
||||
psb_cd_get_map_data = -1
|
||||
end if
|
||||
end function psb_cd_get_map_data
|
||||
|
||||
subroutine psb_cd_set_map_data(map_data,desc)
|
||||
implicit none
|
||||
integer, intent(in) :: map_data
|
||||
type(psb_inter_desc_type), intent(inout) :: desc
|
||||
|
||||
|
||||
desc%itd_data(psb_map_data_) = map_data
|
||||
|
||||
end subroutine psb_cd_set_map_data
|
||||
|
||||
|
||||
function psb_cd_get_fw_tmp_sz(desc)
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
Integer :: psb_cd_get_fw_tmp_sz
|
||||
|
||||
psb_cd_get_fw_tmp_sz = desc%itd_data(psb_fw_tmp_sz_)
|
||||
end function psb_cd_get_fw_tmp_sz
|
||||
|
||||
function psb_cd_get_bk_tmp_sz(desc)
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
Integer :: psb_cd_get_bk_tmp_sz
|
||||
|
||||
psb_cd_get_bk_tmp_sz = desc%itd_data(psb_bk_tmp_sz_)
|
||||
end function psb_cd_get_bk_tmp_sz
|
||||
|
||||
subroutine psb_cd_set_fw_tmp_sz(isz,desc)
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(inout) :: desc
|
||||
integer, intent(in) :: isz
|
||||
|
||||
desc%itd_data(psb_fw_tmp_sz_) =isz
|
||||
end subroutine psb_cd_set_fw_tmp_sz
|
||||
|
||||
subroutine psb_cd_set_bk_tmp_sz(isz,desc)
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(inout) :: desc
|
||||
integer, intent(in) :: isz
|
||||
|
||||
desc%itd_data(psb_bk_tmp_sz_) =isz
|
||||
|
||||
end subroutine psb_cd_set_bk_tmp_sz
|
||||
|
||||
|
||||
logical function psb_is_asb_inter_desc(desc)
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
|
||||
psb_is_asb_inter_desc = .false.
|
||||
if (.not.allocated(desc%itd_data)) return
|
||||
if (.not.associated(desc%desc_1)) return
|
||||
if (.not.associated(desc%desc_2)) return
|
||||
psb_is_asb_inter_desc = &
|
||||
& psb_is_asb_desc(desc%desc_1).and.psb_is_asb_desc(desc%desc_2)
|
||||
|
||||
end function psb_is_asb_inter_desc
|
||||
|
||||
logical function psb_is_ok_inter_desc(desc)
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
|
||||
psb_is_ok_inter_desc = .false.
|
||||
if (.not.allocated(desc%itd_data)) return
|
||||
select case(desc%itd_data(psb_map_data_))
|
||||
case(psb_map_integer_, psb_map_double_, psb_map_complex_)
|
||||
! Ok go ahead
|
||||
case default
|
||||
! Since it's false so far, simply return
|
||||
return
|
||||
end select
|
||||
if (.not.associated(desc%desc_1)) return
|
||||
if (.not.associated(desc%desc_2)) return
|
||||
psb_is_ok_inter_desc = &
|
||||
& psb_is_ok_desc(desc%desc_1).and.psb_is_ok_desc(desc%desc_2)
|
||||
|
||||
end function psb_is_ok_inter_desc
|
||||
|
||||
|
||||
function psb_d_map_sizeof(map)
|
||||
implicit none
|
||||
type(psb_d_map_type), intent(in) :: map
|
||||
Integer :: psb_d_map_sizeof
|
||||
integer :: val
|
||||
|
||||
val = 0
|
||||
|
||||
val = val + psb_sizeof(map%map_fw)
|
||||
val = val + psb_sizeof(map%map_bk)
|
||||
psb_d_map_sizeof = val
|
||||
end function psb_d_map_sizeof
|
||||
|
||||
function psb_z_map_sizeof(map)
|
||||
implicit none
|
||||
type(psb_z_map_type), intent(in) :: map
|
||||
Integer :: psb_z_map_sizeof
|
||||
integer :: val
|
||||
|
||||
val = 0
|
||||
|
||||
val = val + psb_sizeof(map%map_fw)
|
||||
val = val + psb_sizeof(map%map_bk)
|
||||
psb_z_map_sizeof = val
|
||||
end function psb_z_map_sizeof
|
||||
|
||||
function psb_itd_sizeof(desc)
|
||||
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
Integer :: psb_itd_sizeof
|
||||
integer :: val
|
||||
|
||||
val = 0
|
||||
|
||||
if (allocated(desc%itd_data)) val = val + 4*size(desc%itd_data)
|
||||
if (allocated(desc%exch_fw_idx)) val = val + 4*size(desc%exch_fw_idx)
|
||||
if (allocated(desc%exch_bk_idx)) val = val + 4*size(desc%exch_bk_idx)
|
||||
val = val + psb_sizeof(desc%dmap)
|
||||
val = val + psb_sizeof(desc%zmap)
|
||||
psb_itd_sizeof = val
|
||||
end function psb_itd_sizeof
|
||||
|
||||
function psb_d_inter_desc(map_kind,desc1, desc2, map_fw, map_bk, idx_fw, idx_bk)
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type) :: psb_d_inter_desc
|
||||
type(psb_desc_type), target :: desc1, desc2
|
||||
type(psb_dspmat_type), intent(in) :: map_fw, map_bk
|
||||
integer, intent(in) :: map_kind,idx_fw(:), idx_bk(:)
|
||||
!
|
||||
type(psb_inter_desc_type) :: this
|
||||
integer :: info
|
||||
character(len=20), parameter :: name='psb_inter_desc'
|
||||
|
||||
info = 0
|
||||
if (psb_is_ok_desc(desc1)) then
|
||||
this%desc_1=>desc1
|
||||
else
|
||||
info = 2
|
||||
endif
|
||||
if (psb_is_ok_desc(desc2)) then
|
||||
this%desc_2=>desc2
|
||||
else
|
||||
info = 3
|
||||
endif
|
||||
|
||||
if (info == 0) call psb_sp_clone(map_fw,this%dmap%map_fw,info)
|
||||
if (info == 0) call psb_sp_clone(map_bk,this%dmap%map_bk,info)
|
||||
if (info == 0) call psb_safe_cpy(idx_fw,this%exch_fw_idx,info)
|
||||
if (info == 0) call psb_safe_cpy(idx_bk,this%exch_bk_idx,info)
|
||||
if (info == 0) call psb_realloc(psb_itd_data_size_,this%itd_data,info)
|
||||
if (info == 0) then
|
||||
call psb_cd_set_map_kind(map_kind, this)
|
||||
call psb_cd_set_map_data(psb_map_double_, this)
|
||||
!!$ call psb_cd_set_fw_tmp_sz(map_fw%k, this)
|
||||
!!$ call psb_cd_set_bk_tmp_sz(map_bk%k, this)
|
||||
end if
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Invalid descriptor input'
|
||||
return
|
||||
end if
|
||||
|
||||
psb_d_inter_desc = this
|
||||
|
||||
end function psb_d_inter_desc
|
||||
|
||||
function psb_d_inter_desc_noidx(map_kind,desc1, desc2, map_fw, map_bk)
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type) :: psb_d_inter_desc_noidx
|
||||
type(psb_desc_type), target :: desc1, desc2
|
||||
type(psb_dspmat_type), intent(in) :: map_fw, map_bk
|
||||
integer, intent(in) :: map_kind
|
||||
!
|
||||
type(psb_inter_desc_type) :: this
|
||||
integer :: info
|
||||
character(len=20), parameter :: name='psb_inter_desc'
|
||||
|
||||
info = 0
|
||||
select case(map_kind)
|
||||
case (psb_map_aggr_)
|
||||
! OK
|
||||
case default
|
||||
write(0,*) 'Bad mapp kind into psb_inter_desc ',map_kind
|
||||
info = 1
|
||||
end select
|
||||
|
||||
if (psb_is_ok_desc(desc1)) then
|
||||
this%desc_1=>desc1
|
||||
else
|
||||
info = 2
|
||||
endif
|
||||
if (psb_is_ok_desc(desc2)) then
|
||||
this%desc_2=>desc2
|
||||
else
|
||||
info = 3
|
||||
endif
|
||||
|
||||
if (info == 0) call psb_sp_clone(map_fw,this%dmap%map_fw,info)
|
||||
if (info == 0) call psb_sp_clone(map_bk,this%dmap%map_bk,info)
|
||||
if (info == 0) call psb_realloc(psb_itd_data_size_,this%itd_data,info)
|
||||
if (info == 0) then
|
||||
call psb_cd_set_map_kind(map_kind, this)
|
||||
call psb_cd_set_map_data(psb_map_double_, this)
|
||||
!!$ call psb_cd_set_fw_tmp_sz(map_fw%k, this)
|
||||
!!$ call psb_cd_set_bk_tmp_sz(map_bk%k, this)
|
||||
end if
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Invalid descriptor input'
|
||||
return
|
||||
end if
|
||||
|
||||
psb_d_inter_desc_noidx = this
|
||||
|
||||
end function psb_d_inter_desc_noidx
|
||||
|
||||
function psb_z_inter_desc(map_kind,desc1, desc2, map_fw, map_bk, idx_fw, idx_bk)
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type) :: psb_z_inter_desc
|
||||
type(psb_desc_type), target :: desc1, desc2
|
||||
type(psb_zspmat_type), intent(in) :: map_fw, map_bk
|
||||
integer, intent(in) :: map_kind,idx_fw(:), idx_bk(:)
|
||||
!
|
||||
type(psb_inter_desc_type) :: this
|
||||
integer :: info
|
||||
character(len=20), parameter :: name='psb_inter_desc'
|
||||
|
||||
info = 0
|
||||
if (psb_is_ok_desc(desc1)) then
|
||||
this%desc_1=>desc1
|
||||
else
|
||||
info = 2
|
||||
endif
|
||||
if (psb_is_ok_desc(desc2)) then
|
||||
this%desc_2=>desc2
|
||||
else
|
||||
info = 3
|
||||
endif
|
||||
|
||||
if (info == 0) call psb_sp_clone(map_fw,this%zmap%map_fw,info)
|
||||
if (info == 0) call psb_sp_clone(map_bk,this%zmap%map_bk,info)
|
||||
if (info == 0) call psb_safe_cpy(idx_fw,this%exch_fw_idx,info)
|
||||
if (info == 0) call psb_safe_cpy(idx_bk,this%exch_bk_idx,info)
|
||||
if (info == 0) call psb_realloc(psb_itd_data_size_,this%itd_data,info)
|
||||
if (info == 0) then
|
||||
call psb_cd_set_map_kind(map_kind, this)
|
||||
call psb_cd_set_map_data(psb_map_complex_, this)
|
||||
!!$ call psb_cd_set_fw_tmp_sz(map_fw%k, this)
|
||||
!!$ call psb_cd_set_bk_tmp_sz(map_bk%k, this)
|
||||
end if
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Invalid descriptor input'
|
||||
return
|
||||
end if
|
||||
|
||||
psb_z_inter_desc = this
|
||||
|
||||
end function psb_z_inter_desc
|
||||
|
||||
function psb_z_inter_desc_noidx(map_kind,desc1, desc2, map_fw, map_bk)
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type) :: psb_z_inter_desc_noidx
|
||||
type(psb_desc_type), target :: desc1, desc2
|
||||
type(psb_zspmat_type), intent(in) :: map_fw, map_bk
|
||||
integer, intent(in) :: map_kind
|
||||
!
|
||||
type(psb_inter_desc_type) :: this
|
||||
integer :: info
|
||||
character(len=20), parameter :: name='psb_inter_desc'
|
||||
|
||||
info = 0
|
||||
select case(map_kind)
|
||||
case (psb_map_aggr_)
|
||||
! OK
|
||||
case default
|
||||
write(0,*) 'Bad mapp kind into psb_inter_desc ',map_kind
|
||||
info = 1
|
||||
end select
|
||||
|
||||
if (psb_is_ok_desc(desc1)) then
|
||||
this%desc_1=>desc1
|
||||
else
|
||||
info = 2
|
||||
endif
|
||||
if (psb_is_ok_desc(desc2)) then
|
||||
this%desc_2=>desc2
|
||||
else
|
||||
info = 3
|
||||
endif
|
||||
|
||||
if (info == 0) call psb_sp_clone(map_fw,this%zmap%map_fw,info)
|
||||
if (info == 0) call psb_sp_clone(map_bk,this%zmap%map_bk,info)
|
||||
if (info == 0) call psb_realloc(psb_itd_data_size_,this%itd_data,info)
|
||||
if (info == 0) then
|
||||
call psb_cd_set_map_kind(map_kind, this)
|
||||
call psb_cd_set_map_data(psb_map_complex_, this)
|
||||
!!$ call psb_cd_set_fw_tmp_sz(map_fw%k, this)
|
||||
!!$ call psb_cd_set_bk_tmp_sz(map_bk%k, this)
|
||||
end if
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Invalid descriptor input'
|
||||
return
|
||||
end if
|
||||
|
||||
psb_z_inter_desc_noidx = this
|
||||
|
||||
end function psb_z_inter_desc_noidx
|
||||
|
||||
|
||||
|
||||
|
||||
!
|
||||
! Takes a vector X from space desc%desc_1 and maps it onto
|
||||
! desc%desc_2 under desc%map_fw possibly with communication
|
||||
! due to exch_fw_idx
|
||||
!
|
||||
subroutine psb_d_forward_map(alpha,x,beta,y,desc,info,work)
|
||||
use psb_comm_mod
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
real(kind(1.d0)), intent(in) :: alpha,beta
|
||||
real(kind(1.d0)), intent(inout) :: x(:)
|
||||
real(kind(1.d0)), intent(out) :: y(:)
|
||||
integer, intent(out) :: info
|
||||
real(kind(1.d0)), optional :: work(:)
|
||||
|
||||
!
|
||||
real(kind(1.d0)), allocatable :: xt(:)
|
||||
integer :: itsz, i, j,totxch,totsnd,totrcv,&
|
||||
& map_kind, map_data
|
||||
character(len=20), parameter :: name='psb_forward_map'
|
||||
|
||||
info = 0
|
||||
if (.not.psb_is_asb_desc(desc)) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end if
|
||||
|
||||
itsz = psb_cd_get_fw_tmp_sz(desc)
|
||||
map_kind = psb_cd_get_map_kind(desc)
|
||||
map_data = psb_cd_get_map_data(desc)
|
||||
if (map_data /= psb_map_double_) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt: map_data', &
|
||||
& map_data,psb_map_double_
|
||||
info = 1
|
||||
return
|
||||
endif
|
||||
|
||||
select case(map_kind)
|
||||
case(psb_map_aggr_)
|
||||
! Ok, we just need to call a halo update and a matrix-vector product.
|
||||
call psb_halo(x,desc%desc_1,info,work=work)
|
||||
if (info == 0) call psb_csmm(alpha,desc%dmap%map_fw,x,beta,y,info)
|
||||
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Error from inner routines',info
|
||||
info = -1
|
||||
end if
|
||||
|
||||
|
||||
case default
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end select
|
||||
|
||||
end subroutine psb_d_forward_map
|
||||
|
||||
|
||||
!
|
||||
! Takes a vector X from space desc%desc_2 and maps it onto
|
||||
! desc%desc_1 under desc%map_bk possibly with communication
|
||||
! due to exch_bk_idx
|
||||
!
|
||||
subroutine psb_d_backward_map(alpha,x,beta,y,desc,info,work)
|
||||
use psb_comm_mod
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
real(kind(1.d0)), intent(in) :: alpha,beta
|
||||
real(kind(1.d0)), intent(inout) :: x(:)
|
||||
real(kind(1.d0)), intent(out) :: y(:)
|
||||
integer, intent(out) :: info
|
||||
real(kind(1.d0)), optional :: work(:)
|
||||
|
||||
!
|
||||
real(kind(1.d0)), allocatable :: xt(:)
|
||||
integer :: itsz, i, j,totxch,totsnd,totrcv,&
|
||||
& map_kind, map_data
|
||||
character(len=20), parameter :: name='psb_backward_map'
|
||||
|
||||
info = 0
|
||||
if (.not.psb_is_asb_desc(desc)) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end if
|
||||
|
||||
itsz = psb_cd_get_bk_tmp_sz(desc)
|
||||
map_kind = psb_cd_get_map_kind(desc)
|
||||
map_data = psb_cd_get_map_data(desc)
|
||||
if (map_data /= psb_map_double_) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt: map_data',&
|
||||
& map_data,psb_map_double_
|
||||
info = 1
|
||||
return
|
||||
endif
|
||||
|
||||
select case(map_kind)
|
||||
case(psb_map_aggr_)
|
||||
! Ok, we just need to call a halo update and a matrix-vector product.
|
||||
call psb_halo(x,desc%desc_2,info,work=work)
|
||||
if (info == 0) call psb_csmm(alpha,desc%dmap%map_bk,x,beta,y,info)
|
||||
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Error from inner routines',info
|
||||
info = -1
|
||||
end if
|
||||
|
||||
|
||||
case default
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end select
|
||||
|
||||
end subroutine psb_d_backward_map
|
||||
|
||||
|
||||
!
|
||||
! Takes a vector X from space desc%desc_1 and maps it onto
|
||||
! desc%desc_2 under desc%map_fw possibly with communication
|
||||
! due to exch_fw_idx
|
||||
!
|
||||
subroutine psb_z_forward_map(alpha,x,beta,y,desc,info,work)
|
||||
use psb_comm_mod
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
complex(kind(1.d0)), intent(in) :: alpha,beta
|
||||
complex(kind(1.d0)), intent(inout) :: x(:)
|
||||
complex(kind(1.d0)), intent(out) :: y(:)
|
||||
integer, intent(out) :: info
|
||||
complex(kind(1.d0)), optional :: work(:)
|
||||
|
||||
!
|
||||
complex(kind(1.d0)), allocatable :: xt(:)
|
||||
integer :: itsz, i, j,totxch,totsnd,totrcv,&
|
||||
& map_kind, map_data
|
||||
character(len=20), parameter :: name='psb_forward_map'
|
||||
|
||||
info = 0
|
||||
if (.not.psb_is_asb_desc(desc)) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end if
|
||||
|
||||
itsz = psb_cd_get_fw_tmp_sz(desc)
|
||||
map_kind = psb_cd_get_map_kind(desc)
|
||||
map_data = psb_cd_get_map_data(desc)
|
||||
if (map_data /= psb_map_complex_) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt: map_data',&
|
||||
& map_data,psb_map_complex_
|
||||
info = 1
|
||||
return
|
||||
endif
|
||||
|
||||
select case(map_kind)
|
||||
case(psb_map_aggr_)
|
||||
! Ok, we just need to call a halo update and a matrix-vector product.
|
||||
call psb_halo(x,desc%desc_1,info,work=work)
|
||||
if (info == 0) call psb_csmm(alpha,desc%zmap%map_fw,x,beta,y,info)
|
||||
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Error from inner routines',info
|
||||
info = -1
|
||||
end if
|
||||
|
||||
|
||||
case default
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end select
|
||||
|
||||
end subroutine psb_z_forward_map
|
||||
|
||||
|
||||
!
|
||||
! Takes a vector X from space desc%desc_2 and maps it onto
|
||||
! desc%desc_1 under desc%map_bk possibly with communication
|
||||
! due to exch_bk_idx
|
||||
!
|
||||
subroutine psb_z_backward_map(alpha,x,beta,y,desc,info,work)
|
||||
use psb_comm_mod
|
||||
use psb_serial_mod
|
||||
use psi_mod
|
||||
implicit none
|
||||
type(psb_inter_desc_type), intent(in) :: desc
|
||||
complex(kind(1.d0)), intent(in) :: alpha,beta
|
||||
complex(kind(1.d0)), intent(inout) :: x(:)
|
||||
complex(kind(1.d0)), intent(out) :: y(:)
|
||||
integer, intent(out) :: info
|
||||
complex(kind(1.d0)), optional :: work(:)
|
||||
|
||||
!
|
||||
complex(kind(1.d0)), allocatable :: xt(:)
|
||||
integer :: itsz, i, j,totxch,totsnd,totrcv,&
|
||||
& map_kind, map_data
|
||||
character(len=20), parameter :: name='psb_backward_map'
|
||||
|
||||
info = 0
|
||||
if (.not.psb_is_asb_desc(desc)) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end if
|
||||
|
||||
itsz = psb_cd_get_bk_tmp_sz(desc)
|
||||
map_kind = psb_cd_get_map_kind(desc)
|
||||
map_data = psb_cd_get_map_data(desc)
|
||||
if (map_data /= psb_map_complex_) then
|
||||
write(0,*) trim(name),' Invalid descriptor inupt: map_data',&
|
||||
& map_data,psb_map_complex_
|
||||
info = 1
|
||||
return
|
||||
endif
|
||||
|
||||
select case(map_kind)
|
||||
case(psb_map_aggr_)
|
||||
! Ok, we just need to call a halo update and a matrix-vector product.
|
||||
call psb_halo(x,desc%desc_2,info,work=work)
|
||||
if (info == 0) call psb_csmm(alpha,desc%zmap%map_bk,x,beta,y,info)
|
||||
|
||||
if (info /= 0) then
|
||||
write(0,*) trim(name),' Error from inner routines',info
|
||||
info = -1
|
||||
end if
|
||||
|
||||
|
||||
case default
|
||||
write(0,*) trim(name),' Invalid descriptor inupt'
|
||||
info = 1
|
||||
return
|
||||
end select
|
||||
|
||||
end subroutine psb_z_backward_map
|
||||
|
||||
|
||||
end module psb_inter_descriptor_type
|
@ -0,0 +1,518 @@
|
||||
!!$
|
||||
!!$ Parallel Sparse BLAS v2.0
|
||||
!!$ (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata
|
||||
!!$ Alfredo Buttari University of Rome Tor Vergata
|
||||
!!$
|
||||
!!$ Redistribution and use in source and binary forms, with or without
|
||||
!!$ modification, are permitted provided that the following conditions
|
||||
!!$ are met:
|
||||
!!$ 1. Redistributions of source code must retain the above copyright
|
||||
!!$ notice, this list of conditions and the following disclaimer.
|
||||
!!$ 2. Redistributions in binary form must reproduce the above copyright
|
||||
!!$ notice, this list of conditions, and the following disclaimer in the
|
||||
!!$ documentation and/or other materials provided with the distribution.
|
||||
!!$ 3. The name of the PSBLAS group or the names of its contributors may
|
||||
!!$ not be used to endorse or promote products derived from this
|
||||
!!$ software without specific written permission.
|
||||
!!$
|
||||
!!$ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
!!$ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
!!$ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
!!$ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
||||
!!$ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
!!$ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
!!$ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
!!$ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
!!$ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
!!$ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
!!$ POSSIBILITY OF SUCH DAMAGE.
|
||||
!!$
|
||||
!!$
|
||||
module psi_serial_mod
|
||||
|
||||
|
||||
interface psi_gth
|
||||
module procedure &
|
||||
& psi_igthv, psi_dgthv, psi_zgthv,&
|
||||
& psi_igthzv, psi_dgthzv, psi_zgthzv,&
|
||||
& psi_igthzmv, psi_dgthzmv, psi_zgthzmv
|
||||
end interface
|
||||
|
||||
interface psi_sct
|
||||
module procedure psi_isctmv, psi_isctv,&
|
||||
& psi_dsctmv, psi_dsctv,&
|
||||
& psi_zsctmv, psi_zsctv
|
||||
end interface
|
||||
|
||||
|
||||
contains
|
||||
|
||||
|
||||
subroutine psi_igthv(n,idx,alpha,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
integer :: x(:), y(:), alpha, beta
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
if (beta == izero) then
|
||||
if (alpha == ione) then
|
||||
do i=1,n
|
||||
y(i) = x(idx(i))
|
||||
end do
|
||||
else if (alpha == -ione) then
|
||||
do i=1,n
|
||||
y(i) = -x(idx(i))
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(i) = alpha*x(idx(i))
|
||||
end do
|
||||
end if
|
||||
else
|
||||
if (beta == ione) then
|
||||
! Do nothing
|
||||
else if (beta == -ione) then
|
||||
y(1:n) = -y(1:n)
|
||||
else
|
||||
y(1:n) = beta*y(1:n)
|
||||
end if
|
||||
|
||||
if (alpha == ione) then
|
||||
do i=1,n
|
||||
y(i) = y(i) + x(idx(i))
|
||||
end do
|
||||
else if (alpha == -ione) then
|
||||
do i=1,n
|
||||
y(i) = y(i) - x(idx(i))
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(i) = y(i) + alpha*x(idx(i))
|
||||
end do
|
||||
end if
|
||||
end if
|
||||
|
||||
end subroutine psi_igthv
|
||||
|
||||
subroutine psi_dgthv(n,idx,alpha,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
real(kind(1.d0)) :: x(:), y(:), alpha, beta
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
if (beta == dzero) then
|
||||
if (alpha == done) then
|
||||
do i=1,n
|
||||
y(i) = x(idx(i))
|
||||
end do
|
||||
else if (alpha == -done) then
|
||||
do i=1,n
|
||||
y(i) = -x(idx(i))
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(i) = alpha*x(idx(i))
|
||||
end do
|
||||
end if
|
||||
else
|
||||
if (beta == done) then
|
||||
! Do nothing
|
||||
else if (beta == -done) then
|
||||
y(1:n) = -y(1:n)
|
||||
else
|
||||
y(1:n) = beta*y(1:n)
|
||||
end if
|
||||
|
||||
if (alpha == done) then
|
||||
do i=1,n
|
||||
y(i) = y(i) + x(idx(i))
|
||||
end do
|
||||
else if (alpha == -done) then
|
||||
do i=1,n
|
||||
y(i) = y(i) - x(idx(i))
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(i) = y(i) + alpha*x(idx(i))
|
||||
end do
|
||||
end if
|
||||
end if
|
||||
|
||||
end subroutine psi_dgthv
|
||||
|
||||
subroutine psi_zgthv(n,idx,alpha,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
complex(kind(1.d0)) :: x(:), y(:),alpha,beta
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
if (beta == zzero) then
|
||||
if (alpha == zone) then
|
||||
do i=1,n
|
||||
y(i) = x(idx(i))
|
||||
end do
|
||||
else if (alpha == -zone) then
|
||||
do i=1,n
|
||||
y(i) = -x(idx(i))
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(i) = alpha*x(idx(i))
|
||||
end do
|
||||
end if
|
||||
else
|
||||
if (beta == zone) then
|
||||
! Do nothing
|
||||
else if (beta == -zone) then
|
||||
y(1:n) = -y(1:n)
|
||||
else
|
||||
y(1:n) = beta*y(1:n)
|
||||
end if
|
||||
|
||||
if (alpha == zone) then
|
||||
do i=1,n
|
||||
y(i) = y(i) + x(idx(i))
|
||||
end do
|
||||
else if (alpha == -zone) then
|
||||
do i=1,n
|
||||
y(i) = y(i) - x(idx(i))
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(i) = y(i) + alpha*x(idx(i))
|
||||
end do
|
||||
end if
|
||||
end if
|
||||
|
||||
end subroutine psi_zgthv
|
||||
|
||||
|
||||
|
||||
|
||||
subroutine psi_dgthzmv(n,k,idx,x,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, k, idx(:)
|
||||
real(kind(1.d0)) :: x(:,:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i, j, pt
|
||||
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(pt)=x(idx(i),j)
|
||||
end do
|
||||
end do
|
||||
|
||||
end subroutine psi_dgthzmv
|
||||
|
||||
|
||||
subroutine psi_igthzmv(n,k,idx,x,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, k, idx(:)
|
||||
integer :: x(:,:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i, j, pt
|
||||
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(pt)=x(idx(i),j)
|
||||
end do
|
||||
end do
|
||||
|
||||
end subroutine psi_igthzmv
|
||||
|
||||
|
||||
subroutine psi_zgthzmv(n,k,idx,x,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, k, idx(:)
|
||||
complex(kind(1.d0)) :: x(:,:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i, j, pt
|
||||
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(pt)=x(idx(i),j)
|
||||
end do
|
||||
end do
|
||||
|
||||
end subroutine psi_zgthzmv
|
||||
|
||||
subroutine psi_dgthzv(n,idx,x,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
real(kind(1.d0)) :: x(:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
|
||||
do i=1,n
|
||||
y(i)=x(idx(i))
|
||||
end do
|
||||
|
||||
end subroutine psi_dgthzv
|
||||
|
||||
subroutine psi_igthzv(n,idx,x,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
integer :: x(:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
|
||||
do i=1,n
|
||||
y(i)=x(idx(i))
|
||||
end do
|
||||
|
||||
end subroutine psi_igthzv
|
||||
|
||||
subroutine psi_zgthzv(n,idx,x,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
complex(kind(1.d0)) :: x(:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
|
||||
do i=1,n
|
||||
y(i)=x(idx(i))
|
||||
end do
|
||||
|
||||
end subroutine psi_zgthzv
|
||||
|
||||
|
||||
subroutine psi_dsctmv(n,k,idx,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, k, idx(:)
|
||||
real(kind(1.d0)) :: beta, x(:), y(:,:)
|
||||
|
||||
! Locals
|
||||
integer :: i, j, pt
|
||||
|
||||
if (beta == dzero) then
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = x(pt)
|
||||
end do
|
||||
end do
|
||||
else if (beta == done) then
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = y(idx(i),j)+x(pt)
|
||||
end do
|
||||
end do
|
||||
else
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = beta*y(idx(i),j)+x(pt)
|
||||
end do
|
||||
end do
|
||||
end if
|
||||
end subroutine psi_dsctmv
|
||||
|
||||
subroutine psi_dsctv(n,idx,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
real(kind(1.d0)) :: beta, x(:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
|
||||
if (beta == dzero) then
|
||||
do i=1,n
|
||||
y(idx(i)) = x(i)
|
||||
end do
|
||||
else if (beta == done) then
|
||||
do i=1,n
|
||||
y(idx(i)) = y(idx(i))+x(i)
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(idx(i)) = beta*y(idx(i))
|
||||
end do
|
||||
do i=1,n
|
||||
y(idx(i)) = y(idx(i))+x(i)
|
||||
end do
|
||||
end if
|
||||
end subroutine psi_dsctv
|
||||
|
||||
subroutine psi_isctmv(n,k,idx,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, k, idx(:)
|
||||
integer :: beta, x(:), y(:,:)
|
||||
|
||||
! Locals
|
||||
integer :: i, j, pt
|
||||
|
||||
if (beta == izero) then
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = x(pt)
|
||||
end do
|
||||
end do
|
||||
else if (beta == ione) then
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = y(idx(i),j)+x(pt)
|
||||
end do
|
||||
end do
|
||||
else
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = beta*y(idx(i),j)+x(pt)
|
||||
end do
|
||||
end do
|
||||
end if
|
||||
end subroutine psi_isctmv
|
||||
|
||||
subroutine psi_isctv(n,idx,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
integer :: beta, x(:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
|
||||
if (beta == izero) then
|
||||
do i=1,n
|
||||
y(idx(i)) = x(i)
|
||||
end do
|
||||
else if (beta == ione) then
|
||||
do i=1,n
|
||||
y(idx(i)) = y(idx(i))+x(i)
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(idx(i)) = beta*y(idx(i))+x(i)
|
||||
end do
|
||||
end if
|
||||
end subroutine psi_isctv
|
||||
|
||||
subroutine psi_zsctmv(n,k,idx,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, k, idx(:)
|
||||
complex(kind(1.d0)) :: beta, x(:), y(:,:)
|
||||
|
||||
! Locals
|
||||
integer :: i, j, pt
|
||||
|
||||
if (beta == zzero) then
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = x(pt)
|
||||
end do
|
||||
end do
|
||||
else if (beta == zone) then
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = y(idx(i),j)+x(pt)
|
||||
end do
|
||||
end do
|
||||
else
|
||||
pt=0
|
||||
do j=1,k
|
||||
do i=1,n
|
||||
pt=pt+1
|
||||
y(idx(i),j) = beta*y(idx(i),j)+x(pt)
|
||||
end do
|
||||
end do
|
||||
end if
|
||||
end subroutine psi_zsctmv
|
||||
|
||||
|
||||
subroutine psi_zsctv(n,idx,x,beta,y)
|
||||
|
||||
use psb_const_mod
|
||||
implicit none
|
||||
|
||||
integer :: n, idx(:)
|
||||
complex(kind(1.d0)) :: beta, x(:), y(:)
|
||||
|
||||
! Locals
|
||||
integer :: i
|
||||
|
||||
if (beta == zzero) then
|
||||
do i=1,n
|
||||
y(idx(i)) = x(i)
|
||||
end do
|
||||
else if (beta == zone) then
|
||||
do i=1,n
|
||||
y(idx(i)) = y(idx(i))+x(i)
|
||||
end do
|
||||
else
|
||||
do i=1,n
|
||||
y(idx(i)) = beta*y(idx(i))+x(i)
|
||||
end do
|
||||
end if
|
||||
end subroutine psi_zsctv
|
||||
|
||||
|
||||
end module psi_serial_mod
|
Loading…
Reference in New Issue