Added average coarsening ratio

stopcriterion
Salvatore Filippone 6 years ago
parent 7afcdb7ec2
commit 4ffbd65166

@ -444,6 +444,7 @@ subroutine mld_c_hierarchy_bld(a,desc_a,prec,info)
iszv = size(prec%precv) iszv = size(prec%precv)
call prec%cmp_complexity() call prec%cmp_complexity()
call prec%cmp_avg_cr()
if (debug_level >= psb_debug_outer_) & if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),& & write(debug_unit,*) me,' ',trim(name),&

@ -172,6 +172,7 @@ subroutine mld_cfile_prec_descr(prec,iout,root)
write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) 'Multilevel hierarchy: '
write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Number of levels : ',nlev
write(iout_,*) ' Operator complexity: ',prec%get_complexity() write(iout_,*) ' Operator complexity: ',prec%get_complexity()
write(iout_,*) ' Average coarsening : ',prec%get_avg_cr()
ilmin = 2 ilmin = 2
if (nlev == 2) ilmin=1 if (nlev == 2) ilmin=1
do ilev=ilmin,nlev do ilev=ilmin,nlev

@ -444,6 +444,7 @@ subroutine mld_d_hierarchy_bld(a,desc_a,prec,info)
iszv = size(prec%precv) iszv = size(prec%precv)
call prec%cmp_complexity() call prec%cmp_complexity()
call prec%cmp_avg_cr()
if (debug_level >= psb_debug_outer_) & if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),& & write(debug_unit,*) me,' ',trim(name),&

@ -172,6 +172,7 @@ subroutine mld_dfile_prec_descr(prec,iout,root)
write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) 'Multilevel hierarchy: '
write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Number of levels : ',nlev
write(iout_,*) ' Operator complexity: ',prec%get_complexity() write(iout_,*) ' Operator complexity: ',prec%get_complexity()
write(iout_,*) ' Average coarsening : ',prec%get_avg_cr()
ilmin = 2 ilmin = 2
if (nlev == 2) ilmin=1 if (nlev == 2) ilmin=1
do ilev=ilmin,nlev do ilev=ilmin,nlev

@ -444,6 +444,7 @@ subroutine mld_s_hierarchy_bld(a,desc_a,prec,info)
iszv = size(prec%precv) iszv = size(prec%precv)
call prec%cmp_complexity() call prec%cmp_complexity()
call prec%cmp_avg_cr()
if (debug_level >= psb_debug_outer_) & if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),& & write(debug_unit,*) me,' ',trim(name),&

@ -172,6 +172,7 @@ subroutine mld_sfile_prec_descr(prec,iout,root)
write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) 'Multilevel hierarchy: '
write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Number of levels : ',nlev
write(iout_,*) ' Operator complexity: ',prec%get_complexity() write(iout_,*) ' Operator complexity: ',prec%get_complexity()
write(iout_,*) ' Average coarsening : ',prec%get_avg_cr()
ilmin = 2 ilmin = 2
if (nlev == 2) ilmin=1 if (nlev == 2) ilmin=1
do ilev=ilmin,nlev do ilev=ilmin,nlev

@ -444,6 +444,7 @@ subroutine mld_z_hierarchy_bld(a,desc_a,prec,info)
iszv = size(prec%precv) iszv = size(prec%precv)
call prec%cmp_complexity() call prec%cmp_complexity()
call prec%cmp_avg_cr()
if (debug_level >= psb_debug_outer_) & if (debug_level >= psb_debug_outer_) &
& write(debug_unit,*) me,' ',trim(name),& & write(debug_unit,*) me,' ',trim(name),&

@ -172,6 +172,7 @@ subroutine mld_zfile_prec_descr(prec,iout,root)
write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) 'Multilevel hierarchy: '
write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Number of levels : ',nlev
write(iout_,*) ' Operator complexity: ',prec%get_complexity() write(iout_,*) ' Operator complexity: ',prec%get_complexity()
write(iout_,*) ' Average coarsening : ',prec%get_avg_cr()
ilmin = 2 ilmin = 2
if (nlev == 2) ilmin=1 if (nlev == 2) ilmin=1
do ilev=ilmin,nlev do ilev=ilmin,nlev

@ -95,6 +95,7 @@ module mld_c_prec_type
! 3. min_cr_ratio = 1.5 ! 3. min_cr_ratio = 1.5
real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_ real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_
real(psb_spk_) :: op_complexity = szero real(psb_spk_) :: op_complexity = szero
real(psb_spk_) :: avg_cr = szero
! !
! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle.
! !
@ -122,6 +123,8 @@ module mld_c_prec_type
procedure, pass(prec) :: free_wrk => mld_c_free_wrk procedure, pass(prec) :: free_wrk => mld_c_free_wrk
procedure, pass(prec) :: get_complexity => mld_c_get_compl procedure, pass(prec) :: get_complexity => mld_c_get_compl
procedure, pass(prec) :: cmp_complexity => mld_c_cmp_compl procedure, pass(prec) :: cmp_complexity => mld_c_cmp_compl
procedure, pass(prec) :: get_avg_cr => mld_c_get_avg_cr
procedure, pass(prec) :: cmp_avg_cr => mld_c_cmp_avg_cr
procedure, pass(prec) :: get_nlevs => mld_c_get_nlevs procedure, pass(prec) :: get_nlevs => mld_c_get_nlevs
procedure, pass(prec) :: get_nzeros => mld_c_get_nzeros procedure, pass(prec) :: get_nzeros => mld_c_get_nzeros
procedure, pass(prec) :: sizeof => mld_cprec_sizeof procedure, pass(prec) :: sizeof => mld_cprec_sizeof
@ -143,7 +146,8 @@ module mld_c_prec_type
end type mld_cprec_type end type mld_cprec_type
private :: mld_c_dump, mld_c_get_compl, mld_c_cmp_compl,& private :: mld_c_dump, mld_c_get_compl, mld_c_cmp_compl,&
& mld_c_get_nzeros, mld_c_get_nlevs, c_prec_move_alloc & mld_c_get_avg_cr, mld_c_cmp_avg_cr,&
& mld_c_get_nzeros, mld_c_get_nlevs, c_prec_move_alloc
! !
@ -476,6 +480,43 @@ contains
prec%op_complexity = num/den prec%op_complexity = num/den
end subroutine mld_c_cmp_compl end subroutine mld_c_cmp_compl
!
! Average coarsening ratio
!
function mld_c_get_avg_cr(prec) result(val)
implicit none
class(mld_cprec_type), intent(in) :: prec
complex(psb_spk_) :: val
val = prec%avg_cr
end function mld_c_get_avg_cr
subroutine mld_c_cmp_avg_cr(prec)
implicit none
class(mld_cprec_type), intent(inout) :: prec
real(psb_spk_) :: avgcr
integer(psb_ipk_) :: ictxt
integer(psb_ipk_) :: il, nl, iam, np
avgcr = szero
ictxt = prec%ictxt
call psb_info(ictxt,iam,np)
if (allocated(prec%precv)) then
nl = size(prec%precv)
do il=2,nl
avgcr = avgcr + max(szero,prec%precv(il)%szratio)
end do
avgcr = avgcr / (nl-1)
end if
call psb_sum(ictxt,avgcr)
prec%avg_cr = avgcr/np
end subroutine mld_c_cmp_avg_cr
! !
! Subroutines: mld_Tprec_free ! Subroutines: mld_Tprec_free
! Version: complex ! Version: complex
@ -740,6 +781,7 @@ contains
pout%min_cr_ratio = prec%min_cr_ratio pout%min_cr_ratio = prec%min_cr_ratio
pout%outer_sweeps = prec%outer_sweeps pout%outer_sweeps = prec%outer_sweeps
pout%op_complexity = prec%op_complexity pout%op_complexity = prec%op_complexity
pout%avg_cr = prec%avg_cr
if (allocated(prec%precv)) then if (allocated(prec%precv)) then
ln = size(prec%precv) ln = size(prec%precv)
allocate(pout%precv(ln),stat=info) allocate(pout%precv(ln),stat=info)

@ -95,6 +95,7 @@ module mld_d_prec_type
! 3. min_cr_ratio = 1.5 ! 3. min_cr_ratio = 1.5
real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_ real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_
real(psb_dpk_) :: op_complexity = dzero real(psb_dpk_) :: op_complexity = dzero
real(psb_dpk_) :: avg_cr = dzero
! !
! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle.
! !
@ -122,6 +123,8 @@ module mld_d_prec_type
procedure, pass(prec) :: free_wrk => mld_d_free_wrk procedure, pass(prec) :: free_wrk => mld_d_free_wrk
procedure, pass(prec) :: get_complexity => mld_d_get_compl procedure, pass(prec) :: get_complexity => mld_d_get_compl
procedure, pass(prec) :: cmp_complexity => mld_d_cmp_compl procedure, pass(prec) :: cmp_complexity => mld_d_cmp_compl
procedure, pass(prec) :: get_avg_cr => mld_d_get_avg_cr
procedure, pass(prec) :: cmp_avg_cr => mld_d_cmp_avg_cr
procedure, pass(prec) :: get_nlevs => mld_d_get_nlevs procedure, pass(prec) :: get_nlevs => mld_d_get_nlevs
procedure, pass(prec) :: get_nzeros => mld_d_get_nzeros procedure, pass(prec) :: get_nzeros => mld_d_get_nzeros
procedure, pass(prec) :: sizeof => mld_dprec_sizeof procedure, pass(prec) :: sizeof => mld_dprec_sizeof
@ -143,7 +146,8 @@ module mld_d_prec_type
end type mld_dprec_type end type mld_dprec_type
private :: mld_d_dump, mld_d_get_compl, mld_d_cmp_compl,& private :: mld_d_dump, mld_d_get_compl, mld_d_cmp_compl,&
& mld_d_get_nzeros, mld_d_get_nlevs, d_prec_move_alloc & mld_d_get_avg_cr, mld_d_cmp_avg_cr,&
& mld_d_get_nzeros, mld_d_get_nlevs, d_prec_move_alloc
! !
@ -476,6 +480,43 @@ contains
prec%op_complexity = num/den prec%op_complexity = num/den
end subroutine mld_d_cmp_compl end subroutine mld_d_cmp_compl
!
! Average coarsening ratio
!
function mld_d_get_avg_cr(prec) result(val)
implicit none
class(mld_dprec_type), intent(in) :: prec
real(psb_dpk_) :: val
val = prec%avg_cr
end function mld_d_get_avg_cr
subroutine mld_d_cmp_avg_cr(prec)
implicit none
class(mld_dprec_type), intent(inout) :: prec
real(psb_dpk_) :: avgcr
integer(psb_ipk_) :: ictxt
integer(psb_ipk_) :: il, nl, iam, np
avgcr = dzero
ictxt = prec%ictxt
call psb_info(ictxt,iam,np)
if (allocated(prec%precv)) then
nl = size(prec%precv)
do il=2,nl
avgcr = avgcr + max(dzero,prec%precv(il)%szratio)
end do
avgcr = avgcr / (nl-1)
end if
call psb_sum(ictxt,avgcr)
prec%avg_cr = avgcr/np
end subroutine mld_d_cmp_avg_cr
! !
! Subroutines: mld_Tprec_free ! Subroutines: mld_Tprec_free
! Version: real ! Version: real
@ -740,6 +781,7 @@ contains
pout%min_cr_ratio = prec%min_cr_ratio pout%min_cr_ratio = prec%min_cr_ratio
pout%outer_sweeps = prec%outer_sweeps pout%outer_sweeps = prec%outer_sweeps
pout%op_complexity = prec%op_complexity pout%op_complexity = prec%op_complexity
pout%avg_cr = prec%avg_cr
if (allocated(prec%precv)) then if (allocated(prec%precv)) then
ln = size(prec%precv) ln = size(prec%precv)
allocate(pout%precv(ln),stat=info) allocate(pout%precv(ln),stat=info)

@ -95,6 +95,7 @@ module mld_s_prec_type
! 3. min_cr_ratio = 1.5 ! 3. min_cr_ratio = 1.5
real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_ real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_
real(psb_spk_) :: op_complexity = szero real(psb_spk_) :: op_complexity = szero
real(psb_spk_) :: avg_cr = szero
! !
! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle.
! !
@ -122,6 +123,8 @@ module mld_s_prec_type
procedure, pass(prec) :: free_wrk => mld_s_free_wrk procedure, pass(prec) :: free_wrk => mld_s_free_wrk
procedure, pass(prec) :: get_complexity => mld_s_get_compl procedure, pass(prec) :: get_complexity => mld_s_get_compl
procedure, pass(prec) :: cmp_complexity => mld_s_cmp_compl procedure, pass(prec) :: cmp_complexity => mld_s_cmp_compl
procedure, pass(prec) :: get_avg_cr => mld_s_get_avg_cr
procedure, pass(prec) :: cmp_avg_cr => mld_s_cmp_avg_cr
procedure, pass(prec) :: get_nlevs => mld_s_get_nlevs procedure, pass(prec) :: get_nlevs => mld_s_get_nlevs
procedure, pass(prec) :: get_nzeros => mld_s_get_nzeros procedure, pass(prec) :: get_nzeros => mld_s_get_nzeros
procedure, pass(prec) :: sizeof => mld_sprec_sizeof procedure, pass(prec) :: sizeof => mld_sprec_sizeof
@ -143,7 +146,8 @@ module mld_s_prec_type
end type mld_sprec_type end type mld_sprec_type
private :: mld_s_dump, mld_s_get_compl, mld_s_cmp_compl,& private :: mld_s_dump, mld_s_get_compl, mld_s_cmp_compl,&
& mld_s_get_nzeros, mld_s_get_nlevs, s_prec_move_alloc & mld_s_get_avg_cr, mld_s_cmp_avg_cr,&
& mld_s_get_nzeros, mld_s_get_nlevs, s_prec_move_alloc
! !
@ -476,6 +480,43 @@ contains
prec%op_complexity = num/den prec%op_complexity = num/den
end subroutine mld_s_cmp_compl end subroutine mld_s_cmp_compl
!
! Average coarsening ratio
!
function mld_s_get_avg_cr(prec) result(val)
implicit none
class(mld_sprec_type), intent(in) :: prec
real(psb_spk_) :: val
val = prec%avg_cr
end function mld_s_get_avg_cr
subroutine mld_s_cmp_avg_cr(prec)
implicit none
class(mld_sprec_type), intent(inout) :: prec
real(psb_spk_) :: avgcr
integer(psb_ipk_) :: ictxt
integer(psb_ipk_) :: il, nl, iam, np
avgcr = szero
ictxt = prec%ictxt
call psb_info(ictxt,iam,np)
if (allocated(prec%precv)) then
nl = size(prec%precv)
do il=2,nl
avgcr = avgcr + max(szero,prec%precv(il)%szratio)
end do
avgcr = avgcr / (nl-1)
end if
call psb_sum(ictxt,avgcr)
prec%avg_cr = avgcr/np
end subroutine mld_s_cmp_avg_cr
! !
! Subroutines: mld_Tprec_free ! Subroutines: mld_Tprec_free
! Version: real ! Version: real
@ -740,6 +781,7 @@ contains
pout%min_cr_ratio = prec%min_cr_ratio pout%min_cr_ratio = prec%min_cr_ratio
pout%outer_sweeps = prec%outer_sweeps pout%outer_sweeps = prec%outer_sweeps
pout%op_complexity = prec%op_complexity pout%op_complexity = prec%op_complexity
pout%avg_cr = prec%avg_cr
if (allocated(prec%precv)) then if (allocated(prec%precv)) then
ln = size(prec%precv) ln = size(prec%precv)
allocate(pout%precv(ln),stat=info) allocate(pout%precv(ln),stat=info)

@ -95,6 +95,7 @@ module mld_z_prec_type
! 3. min_cr_ratio = 1.5 ! 3. min_cr_ratio = 1.5
real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_ real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_
real(psb_dpk_) :: op_complexity = dzero real(psb_dpk_) :: op_complexity = dzero
real(psb_dpk_) :: avg_cr = dzero
! !
! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle.
! !
@ -122,6 +123,8 @@ module mld_z_prec_type
procedure, pass(prec) :: free_wrk => mld_z_free_wrk procedure, pass(prec) :: free_wrk => mld_z_free_wrk
procedure, pass(prec) :: get_complexity => mld_z_get_compl procedure, pass(prec) :: get_complexity => mld_z_get_compl
procedure, pass(prec) :: cmp_complexity => mld_z_cmp_compl procedure, pass(prec) :: cmp_complexity => mld_z_cmp_compl
procedure, pass(prec) :: get_avg_cr => mld_z_get_avg_cr
procedure, pass(prec) :: cmp_avg_cr => mld_z_cmp_avg_cr
procedure, pass(prec) :: get_nlevs => mld_z_get_nlevs procedure, pass(prec) :: get_nlevs => mld_z_get_nlevs
procedure, pass(prec) :: get_nzeros => mld_z_get_nzeros procedure, pass(prec) :: get_nzeros => mld_z_get_nzeros
procedure, pass(prec) :: sizeof => mld_zprec_sizeof procedure, pass(prec) :: sizeof => mld_zprec_sizeof
@ -143,7 +146,8 @@ module mld_z_prec_type
end type mld_zprec_type end type mld_zprec_type
private :: mld_z_dump, mld_z_get_compl, mld_z_cmp_compl,& private :: mld_z_dump, mld_z_get_compl, mld_z_cmp_compl,&
& mld_z_get_nzeros, mld_z_get_nlevs, z_prec_move_alloc & mld_z_get_avg_cr, mld_z_cmp_avg_cr,&
& mld_z_get_nzeros, mld_z_get_nlevs, z_prec_move_alloc
! !
@ -476,6 +480,43 @@ contains
prec%op_complexity = num/den prec%op_complexity = num/den
end subroutine mld_z_cmp_compl end subroutine mld_z_cmp_compl
!
! Average coarsening ratio
!
function mld_z_get_avg_cr(prec) result(val)
implicit none
class(mld_zprec_type), intent(in) :: prec
complex(psb_dpk_) :: val
val = prec%avg_cr
end function mld_z_get_avg_cr
subroutine mld_z_cmp_avg_cr(prec)
implicit none
class(mld_zprec_type), intent(inout) :: prec
real(psb_dpk_) :: avgcr
integer(psb_ipk_) :: ictxt
integer(psb_ipk_) :: il, nl, iam, np
avgcr = dzero
ictxt = prec%ictxt
call psb_info(ictxt,iam,np)
if (allocated(prec%precv)) then
nl = size(prec%precv)
do il=2,nl
avgcr = avgcr + max(dzero,prec%precv(il)%szratio)
end do
avgcr = avgcr / (nl-1)
end if
call psb_sum(ictxt,avgcr)
prec%avg_cr = avgcr/np
end subroutine mld_z_cmp_avg_cr
! !
! Subroutines: mld_Tprec_free ! Subroutines: mld_Tprec_free
! Version: complex ! Version: complex
@ -740,6 +781,7 @@ contains
pout%min_cr_ratio = prec%min_cr_ratio pout%min_cr_ratio = prec%min_cr_ratio
pout%outer_sweeps = prec%outer_sweeps pout%outer_sweeps = prec%outer_sweeps
pout%op_complexity = prec%op_complexity pout%op_complexity = prec%op_complexity
pout%avg_cr = prec%avg_cr
if (allocated(prec%precv)) then if (allocated(prec%precv)) then
ln = size(prec%precv) ln = size(prec%precv)
allocate(pout%precv(ln),stat=info) allocate(pout%precv(ln),stat=info)

Loading…
Cancel
Save