From aca1848401829ccfc8de8c8834341649589d6b17 Mon Sep 17 00:00:00 2001 From: sfilippone Date: Wed, 17 Apr 2024 13:53:23 +0200 Subject: [PATCH] New timings in CG --- base/internals/psi_desc_index.F90 | 2 +- base/tools/psb_icdasb.F90 | 2 +- krylov/psb_dcg.F90 | 31 +++++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/base/internals/psi_desc_index.F90 b/base/internals/psi_desc_index.F90 index 35c8d921..6423c116 100644 --- a/base/internals/psi_desc_index.F90 +++ b/base/internals/psi_desc_index.F90 @@ -137,7 +137,7 @@ subroutine psi_i_desc_index(desc,index_in,dep_list,& & idxr, idxs, iszs, iszr, nesd, nerv, ixp, idx integer(psb_mpk_) :: icomm, minfo - logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. integer(psb_ipk_), save :: idx_phase1=-1, idx_phase2=-1, idx_phase3=-1, idx_phase4=-1 logical, parameter :: usempi=.false. integer(psb_ipk_) :: debug_level, debug_unit diff --git a/base/tools/psb_icdasb.F90 b/base/tools/psb_icdasb.F90 index 31d92133..04f95738 100644 --- a/base/tools/psb_icdasb.F90 +++ b/base/tools/psb_icdasb.F90 @@ -67,7 +67,7 @@ subroutine psb_icdasb(desc,info,ext_hv,mold) integer(psb_mpk_) :: icomm integer(psb_ipk_) :: np,me logical :: ext_hv_ - logical, parameter :: do_timings=.true. + logical, parameter :: do_timings=.false. integer(psb_ipk_), save :: idx_phase1=-1, idx_phase2=-1, idx_phase3=-1 integer(psb_ipk_), save :: idx_phase11=-1, idx_phase12=-1, idx_phase13=-1 integer(psb_ipk_), save :: idx_total=-1 diff --git a/krylov/psb_dcg.F90 b/krylov/psb_dcg.F90 index 669573be..caebb712 100644 --- a/krylov/psb_dcg.F90 +++ b/krylov/psb_dcg.F90 @@ -129,6 +129,8 @@ subroutine psb_dcg_vect(a,prec,b,x,eps,desc_a,info,& logical :: do_cond character(len=20) :: name character(len=*), parameter :: methdname='CG' + logical, parameter :: do_timings=.true. + integer(psb_ipk_), save :: cg_vect=-1, cg_mv=-1, cg_prec=-1 info = psb_success_ name = 'psb_dcg' @@ -149,6 +151,12 @@ subroutine psb_dcg_vect(a,prec,b,x,eps,desc_a,info,& call psb_errpush(info,name) goto 9999 endif + if ((do_timings).and.(cg_vect==-1)) & + & cg_vect = psb_get_timer_idx("CG: vector ops ") + if ((do_timings).and.(cg_mv==-1)) & + & cg_mv = psb_get_timer_idx("CG: MV product") + if ((do_timings).and.(cg_prec==-1)) & + & cg_prec = psb_get_timer_idx("CG: preconditioner") mglob = desc_a%get_global_rows() @@ -219,17 +227,21 @@ subroutine psb_dcg_vect(a,prec,b,x,eps,desc_a,info,& ! = ! = r0 = b-Ax0 ! = + if (do_timings) call psb_tic(cg_vect) if (itx>= itmax_) exit restart - it = 0 call psb_geaxpby(done,b,dzero,r,desc_a,info) + if (do_timings) call psb_toc(cg_vect) + if (do_timings) call psb_tic(cg_mv) if (info == psb_success_) call psb_spmm(-done,a,x,done,r,desc_a,info,work=aux) if (info /= psb_success_) then info=psb_err_from_subroutine_non_ call psb_errpush(info,name) goto 9999 end if - + if (do_timings) call psb_toc(cg_mv) + + if (do_timings) call psb_tic(cg_vect) rho = dzero call psb_init_conv(methdname,istop_,itrace_,itmax_,a,x,b,eps,desc_a,stopdat,info) @@ -237,13 +249,18 @@ subroutine psb_dcg_vect(a,prec,b,x,eps,desc_a,info,& call psb_errpush(psb_err_from_subroutine_non_,name) goto 9999 End If - + if (do_timings) call psb_toc(cg_vect) + iteration: do it = it + 1 itx = itx + 1 - + if (do_timings) call psb_tic(cg_prec) + call prec%apply(r,z,desc_a,info,work=aux) + if (do_timings) call psb_toc(cg_prec) + if (do_timings) call psb_tic(cg_vect) + rho_old = rho rho = psb_gedot(r,z,desc_a,info) @@ -254,13 +271,18 @@ subroutine psb_dcg_vect(a,prec,b,x,eps,desc_a,info,& if (debug_level >= psb_debug_ext_)& & write(debug_unit,*) me,' ',trim(name),& & ': CG Iteration breakdown rho' + if (do_timings) call psb_toc(cg_vect) exit iteration endif beta = rho/rho_old call psb_geaxpby(done,z,beta,p,desc_a,info) end if + if (do_timings) call psb_toc(cg_vect) + if (do_timings) call psb_tic(cg_mv) call psb_spmm(done,a,p,dzero,q,desc_a,info,work=aux) + if (do_timings) call psb_toc(cg_mv) + if (do_timings) call psb_tic(cg_vect) sigma = psb_gedot(p,q,desc_a,info) if (sigma == dzero) then if (debug_level >= psb_debug_ext_)& @@ -293,6 +315,7 @@ subroutine psb_dcg_vect(a,prec,b,x,eps,desc_a,info,& end do iteration end do restart + if (do_timings) call psb_toc(cg_vect) if (do_cond) then if (me == psb_root_) then #if defined(HAVE_LAPACK)