From a612cea167c0d74ffd14cf00eaea91ae61e96cc2 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Fri, 10 Feb 2023 07:53:04 -0500 Subject: [PATCH] Debug for matchboxp --- amgprec/amg_d_matchboxp_mod.f90 | 39 ++++++++++++++++++++++++++++----- amgprec/amg_s_matchboxp_mod.f90 | 39 ++++++++++++++++++++++++++++----- 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/amgprec/amg_d_matchboxp_mod.f90 b/amgprec/amg_d_matchboxp_mod.f90 index 2df58797..e19ce617 100644 --- a/amgprec/amg_d_matchboxp_mod.f90 +++ b/amgprec/amg_d_matchboxp_mod.f90 @@ -143,7 +143,7 @@ contains type(psb_ld_coo_sparse_mat) :: tmpcoo logical :: display_out_, print_out_, reproducible_ logical, parameter :: dump=.false., debug=.false., dump_mate=.false., & - & debug_ilaggr=.false., debug_sync=.false. + & debug_ilaggr=.false., debug_sync=.false., debug_mate=.false. integer(psb_ipk_), save :: idx_bldmtc=-1, idx_phase1=-1, idx_phase2=-1, idx_phase3=-1 logical, parameter :: do_timings=.true. integer, parameter :: ilaggr_neginit=-1, ilaggr_nonlocal=-2 @@ -214,7 +214,20 @@ contains call psb_barrier(ictxt) if (iam == 0) write(0,*)' out from buildmatching:', info end if - + if (debug_mate) then + block + integer(psb_lpk_), allocatable :: ckmate(:) + allocate(ckmate(nr)) + ckmate(1:nr) = mate(1:nr) + call psb_msort(ckmate(1:nr)) + do i=1,nr-1 + if ((ckmate(i)>0) .and. (ckmate(i) == ckmate(i+1))) then + write(0,*) iam,' Duplicate mate entry at',i,' :',ckmate(i) + end if + end do + end block + end if + if (info == 0) then if (do_timings) call psb_tic(idx_phase2) if (debug_sync) then @@ -276,6 +289,9 @@ contains ilaggr(idx) = nlaggr(iam) wtemp(k) = w(k)/nrmagg wtemp(idx) = w(idx)/nrmagg + else + write(0,*) iam,' Inconsistent mate? ',k,mate(k),idx,& + &mate(idx),ilaggr(idx) end if nlpairs = nlpairs+1 else if (idx <= nc) then @@ -326,6 +342,12 @@ contains nlsingl = nlsingl + 1 end if end if + if (ilaggr(k) == ilaggr_neginit) then + write(0,*) iam,' Error: no update to ',k,mate(k),& + & abs(w(k)),nrmagg,epsilon(nrmagg),wtemp(k) + end if + else + if (ilaggr(k)<0) write(0,*) 'Strange? ',k,ilaggr(k) end if end if end do @@ -360,9 +382,14 @@ contains else write(0,*) 'Error : unresolved (paired) index ',k,idx,i,nr,nc, ilv(k),ilv(idx) end if - end if - if (ilaggr(k) <0) then - write(0,*) 'Matchboxp: Funny number: ',k,ilv(k),ilaggr(k),wtemp(k) + else if (ilaggr(k) <0) then + write(0,*) iam,'Matchboxp: Funny number: ',k,ilv(k),ilaggr(k),wtemp(k) + write(0,*) iam,' : : ',nr,nc,mate(k) + if (mate(k) <= nr) then + write(0,*) iam,' : : ',ilaggr(mate(k)),mate(mate(k)),& + & ilv(k),ilv(mate(k)), ilv(mate(mate(k))),ilaggr(mate(mate(k))) + end if + flush(0) end if end do if (debug_sync) then @@ -415,7 +442,7 @@ contains end block if (iam == 0) then - write(0,*) 'Matching statistics: Unmatched nodes ',& + write(0,*) iam,'Matching statistics: Unmatched nodes ',& & nunmatched,' Singletons:',nlsingl,' Pairs:',nlpairs end if diff --git a/amgprec/amg_s_matchboxp_mod.f90 b/amgprec/amg_s_matchboxp_mod.f90 index 9144d70e..a7f41c24 100644 --- a/amgprec/amg_s_matchboxp_mod.f90 +++ b/amgprec/amg_s_matchboxp_mod.f90 @@ -143,7 +143,7 @@ contains type(psb_ls_coo_sparse_mat) :: tmpcoo logical :: display_out_, print_out_, reproducible_ logical, parameter :: dump=.false., debug=.false., dump_mate=.false., & - & debug_ilaggr=.false., debug_sync=.false. + & debug_ilaggr=.false., debug_sync=.false., debug_mate=.false. integer(psb_ipk_), save :: idx_bldmtc=-1, idx_phase1=-1, idx_phase2=-1, idx_phase3=-1 logical, parameter :: do_timings=.true. integer, parameter :: ilaggr_neginit=-1, ilaggr_nonlocal=-2 @@ -214,7 +214,20 @@ contains call psb_barrier(ictxt) if (iam == 0) write(0,*)' out from buildmatching:', info end if - + if (debug_mate) then + block + integer(psb_lpk_), allocatable :: ckmate(:) + allocate(ckmate(nr)) + ckmate(1:nr) = mate(1:nr) + call psb_msort(ckmate(1:nr)) + do i=1,nr-1 + if ((ckmate(i)>0) .and. (ckmate(i) == ckmate(i+1))) then + write(0,*) iam,' Duplicate mate entry at',i,' :',ckmate(i) + end if + end do + end block + end if + if (info == 0) then if (do_timings) call psb_tic(idx_phase2) if (debug_sync) then @@ -276,6 +289,9 @@ contains ilaggr(idx) = nlaggr(iam) wtemp(k) = w(k)/nrmagg wtemp(idx) = w(idx)/nrmagg + else + write(0,*) iam,' Inconsistent mate? ',k,mate(k),idx,& + &mate(idx),ilaggr(idx) end if nlpairs = nlpairs+1 else if (idx <= nc) then @@ -326,6 +342,12 @@ contains nlsingl = nlsingl + 1 end if end if + if (ilaggr(k) == ilaggr_neginit) then + write(0,*) iam,' Error: no update to ',k,mate(k),& + & abs(w(k)),nrmagg,epsilon(nrmagg),wtemp(k) + end if + else + if (ilaggr(k)<0) write(0,*) 'Strange? ',k,ilaggr(k) end if end if end do @@ -360,9 +382,14 @@ contains else write(0,*) 'Error : unresolved (paired) index ',k,idx,i,nr,nc, ilv(k),ilv(idx) end if - end if - if (ilaggr(k) <0) then - write(0,*) 'Matchboxp: Funny number: ',k,ilv(k),ilaggr(k),wtemp(k) + else if (ilaggr(k) <0) then + write(0,*) iam,'Matchboxp: Funny number: ',k,ilv(k),ilaggr(k),wtemp(k) + write(0,*) iam,' : : ',nr,nc,mate(k) + if (mate(k) <= nr) then + write(0,*) iam,' : : ',ilaggr(mate(k)),mate(mate(k)),& + & ilv(k),ilv(mate(k)), ilv(mate(mate(k))),ilaggr(mate(mate(k))) + end if + flush(0) end if end do if (debug_sync) then @@ -415,7 +442,7 @@ contains end block if (iam == 0) then - write(0,*) 'Matching statistics: Unmatched nodes ',& + write(0,*) iam,'Matching statistics: Unmatched nodes ',& & nunmatched,' Singletons:',nlsingl,' Pairs:',nlpairs end if