diff --git a/mlprec/impl/mld_c_hierarchy_bld.f90 b/mlprec/impl/mld_c_hierarchy_bld.f90 index 5511fcdc..4ebaa374 100644 --- a/mlprec/impl/mld_c_hierarchy_bld.f90 +++ b/mlprec/impl/mld_c_hierarchy_bld.f90 @@ -444,6 +444,7 @@ subroutine mld_c_hierarchy_bld(a,desc_a,prec,info) iszv = size(prec%precv) call prec%cmp_complexity() + call prec%cmp_avg_cr() if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& diff --git a/mlprec/impl/mld_cfile_prec_descr.f90 b/mlprec/impl/mld_cfile_prec_descr.f90 index 1f243756..499421d0 100644 --- a/mlprec/impl/mld_cfile_prec_descr.f90 +++ b/mlprec/impl/mld_cfile_prec_descr.f90 @@ -172,6 +172,7 @@ subroutine mld_cfile_prec_descr(prec,iout,root) write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() ilmin = 2 if (nlev == 2) ilmin=1 do ilev=ilmin,nlev diff --git a/mlprec/impl/mld_d_hierarchy_bld.f90 b/mlprec/impl/mld_d_hierarchy_bld.f90 index b3b68307..0a40dcb8 100644 --- a/mlprec/impl/mld_d_hierarchy_bld.f90 +++ b/mlprec/impl/mld_d_hierarchy_bld.f90 @@ -444,6 +444,7 @@ subroutine mld_d_hierarchy_bld(a,desc_a,prec,info) iszv = size(prec%precv) call prec%cmp_complexity() + call prec%cmp_avg_cr() if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& diff --git a/mlprec/impl/mld_dfile_prec_descr.f90 b/mlprec/impl/mld_dfile_prec_descr.f90 index d129e434..d2c3735b 100644 --- a/mlprec/impl/mld_dfile_prec_descr.f90 +++ b/mlprec/impl/mld_dfile_prec_descr.f90 @@ -172,6 +172,7 @@ subroutine mld_dfile_prec_descr(prec,iout,root) write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() ilmin = 2 if (nlev == 2) ilmin=1 do ilev=ilmin,nlev diff --git a/mlprec/impl/mld_s_hierarchy_bld.f90 b/mlprec/impl/mld_s_hierarchy_bld.f90 index aa23b70c..e4951c7c 100644 --- a/mlprec/impl/mld_s_hierarchy_bld.f90 +++ b/mlprec/impl/mld_s_hierarchy_bld.f90 @@ -444,6 +444,7 @@ subroutine mld_s_hierarchy_bld(a,desc_a,prec,info) iszv = size(prec%precv) call prec%cmp_complexity() + call prec%cmp_avg_cr() if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& diff --git a/mlprec/impl/mld_sfile_prec_descr.f90 b/mlprec/impl/mld_sfile_prec_descr.f90 index c90976e2..7bb0a150 100644 --- a/mlprec/impl/mld_sfile_prec_descr.f90 +++ b/mlprec/impl/mld_sfile_prec_descr.f90 @@ -172,6 +172,7 @@ subroutine mld_sfile_prec_descr(prec,iout,root) write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() ilmin = 2 if (nlev == 2) ilmin=1 do ilev=ilmin,nlev diff --git a/mlprec/impl/mld_z_hierarchy_bld.f90 b/mlprec/impl/mld_z_hierarchy_bld.f90 index 895b9a9c..638021ee 100644 --- a/mlprec/impl/mld_z_hierarchy_bld.f90 +++ b/mlprec/impl/mld_z_hierarchy_bld.f90 @@ -444,6 +444,7 @@ subroutine mld_z_hierarchy_bld(a,desc_a,prec,info) iszv = size(prec%precv) call prec%cmp_complexity() + call prec%cmp_avg_cr() if (debug_level >= psb_debug_outer_) & & write(debug_unit,*) me,' ',trim(name),& diff --git a/mlprec/impl/mld_zfile_prec_descr.f90 b/mlprec/impl/mld_zfile_prec_descr.f90 index e54e3a4f..ab1789f0 100644 --- a/mlprec/impl/mld_zfile_prec_descr.f90 +++ b/mlprec/impl/mld_zfile_prec_descr.f90 @@ -172,6 +172,7 @@ subroutine mld_zfile_prec_descr(prec,iout,root) write(iout_,*) 'Multilevel hierarchy: ' write(iout_,*) ' Number of levels : ',nlev write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() ilmin = 2 if (nlev == 2) ilmin=1 do ilev=ilmin,nlev diff --git a/mlprec/mld_c_prec_type.f90 b/mlprec/mld_c_prec_type.f90 index bafc6a03..59597e89 100644 --- a/mlprec/mld_c_prec_type.f90 +++ b/mlprec/mld_c_prec_type.f90 @@ -95,6 +95,7 @@ module mld_c_prec_type ! 3. min_cr_ratio = 1.5 real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_ 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. ! @@ -122,6 +123,8 @@ module mld_c_prec_type procedure, pass(prec) :: free_wrk => mld_c_free_wrk procedure, pass(prec) :: get_complexity => mld_c_get_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_nzeros => mld_c_get_nzeros procedure, pass(prec) :: sizeof => mld_cprec_sizeof @@ -143,7 +146,8 @@ module mld_c_prec_type end type mld_cprec_type 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 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 ! Version: complex @@ -740,6 +781,7 @@ contains pout%min_cr_ratio = prec%min_cr_ratio pout%outer_sweeps = prec%outer_sweeps pout%op_complexity = prec%op_complexity + pout%avg_cr = prec%avg_cr if (allocated(prec%precv)) then ln = size(prec%precv) allocate(pout%precv(ln),stat=info) diff --git a/mlprec/mld_d_prec_type.f90 b/mlprec/mld_d_prec_type.f90 index c1cbe45d..c8b5d623 100644 --- a/mlprec/mld_d_prec_type.f90 +++ b/mlprec/mld_d_prec_type.f90 @@ -95,6 +95,7 @@ module mld_d_prec_type ! 3. min_cr_ratio = 1.5 real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_ 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. ! @@ -122,6 +123,8 @@ module mld_d_prec_type procedure, pass(prec) :: free_wrk => mld_d_free_wrk procedure, pass(prec) :: get_complexity => mld_d_get_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_nzeros => mld_d_get_nzeros procedure, pass(prec) :: sizeof => mld_dprec_sizeof @@ -143,7 +146,8 @@ module mld_d_prec_type end type mld_dprec_type 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 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 ! Version: real @@ -740,6 +781,7 @@ contains pout%min_cr_ratio = prec%min_cr_ratio pout%outer_sweeps = prec%outer_sweeps pout%op_complexity = prec%op_complexity + pout%avg_cr = prec%avg_cr if (allocated(prec%precv)) then ln = size(prec%precv) allocate(pout%precv(ln),stat=info) diff --git a/mlprec/mld_s_prec_type.f90 b/mlprec/mld_s_prec_type.f90 index 21dbfb27..9d2f0eb0 100644 --- a/mlprec/mld_s_prec_type.f90 +++ b/mlprec/mld_s_prec_type.f90 @@ -95,6 +95,7 @@ module mld_s_prec_type ! 3. min_cr_ratio = 1.5 real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_ 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. ! @@ -122,6 +123,8 @@ module mld_s_prec_type procedure, pass(prec) :: free_wrk => mld_s_free_wrk procedure, pass(prec) :: get_complexity => mld_s_get_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_nzeros => mld_s_get_nzeros procedure, pass(prec) :: sizeof => mld_sprec_sizeof @@ -143,7 +146,8 @@ module mld_s_prec_type end type mld_sprec_type 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 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 ! Version: real @@ -740,6 +781,7 @@ contains pout%min_cr_ratio = prec%min_cr_ratio pout%outer_sweeps = prec%outer_sweeps pout%op_complexity = prec%op_complexity + pout%avg_cr = prec%avg_cr if (allocated(prec%precv)) then ln = size(prec%precv) allocate(pout%precv(ln),stat=info) diff --git a/mlprec/mld_z_prec_type.f90 b/mlprec/mld_z_prec_type.f90 index db29b60b..d4226422 100644 --- a/mlprec/mld_z_prec_type.f90 +++ b/mlprec/mld_z_prec_type.f90 @@ -95,6 +95,7 @@ module mld_z_prec_type ! 3. min_cr_ratio = 1.5 real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_ 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. ! @@ -122,6 +123,8 @@ module mld_z_prec_type procedure, pass(prec) :: free_wrk => mld_z_free_wrk procedure, pass(prec) :: get_complexity => mld_z_get_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_nzeros => mld_z_get_nzeros procedure, pass(prec) :: sizeof => mld_zprec_sizeof @@ -143,7 +146,8 @@ module mld_z_prec_type end type mld_zprec_type 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 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 ! Version: complex @@ -740,6 +781,7 @@ contains pout%min_cr_ratio = prec%min_cr_ratio pout%outer_sweeps = prec%outer_sweeps pout%op_complexity = prec%op_complexity + pout%avg_cr = prec%avg_cr if (allocated(prec%precv)) then ln = size(prec%precv) allocate(pout%precv(ln),stat=info)