Skip to content

Commit

Permalink
only print timings if verbosity larger than 1
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester committed Oct 30, 2024
1 parent c974a0a commit ff2831c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
18 changes: 10 additions & 8 deletions pfb/operators/gridder.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,8 @@ def compute_residual(dsl,
nthreads=1,
epsilon=1e-7,
do_wgridding=True,
double_accum=True):
double_accum=True,
verbosity=1):
'''
Function to compute residual and write it to disk
'''
Expand Down Expand Up @@ -780,13 +781,14 @@ def compute_residual(dsl,

ttot = time() - tii
ttally = tread + tdegrid + tgrid + tdiff + tassign + twrite
print(f'tread = {tread/ttot}')
print(f'tdegrid = {tdegrid/ttot}')
print(f'tgrid = {tgrid/ttot}')
print(f'tdiff = {tdiff/ttot}')
print(f'tassign = {tassign/ttot}')
print(f'twrite = {twrite/ttot}')
print(f'ttally = {ttally/ttot}')
if verbosity > 1:
print(f'tread = {tread/ttot}')
print(f'tdegrid = {tdegrid/ttot}')
print(f'tgrid = {tgrid/ttot}')
print(f'tdiff = {tdiff/ttot}')
print(f'tassign = {tassign/ttot}')
print(f'twrite = {twrite/ttot}')
print(f'ttally = {ttally/ttot}')
return residual, future

def dataset_to_zarr(ds, output_name):
Expand Down
15 changes: 8 additions & 7 deletions pfb/opt/pcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,14 @@ def M(x): return x
# file=log)
ttot = time() - tii
ttally = tcopy + tA + tvdot + tupdate + tp + tnorm
print('tcopy = ', tcopy/ttot)
print('tA = ', tA/ttot)
print('tvdot = ', tvdot/ttot)
print('tupdate = ', tupdate/ttot)
print('tp = ', tp/ttot)
print('tnorm = ', tnorm/ttot)
print('ttally = ', ttally/ttot)
if verbosity > 1:
print('tcopy = ', tcopy/ttot)
print('tA = ', tA/ttot)
print('tvdot = ', tvdot/ttot)
print('tupdate = ', tupdate/ttot)
print('tp = ', tp/ttot)
print('tnorm = ', tnorm/ttot)
print('ttally = ', ttally/ttot)

if k >= maxit:
if verbosity:
Expand Down
21 changes: 11 additions & 10 deletions pfb/opt/primal_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,17 @@ def primal_dual_optimised(

ttot = time() - tii
ttally = tpsi + tpsiH + tgrad + tupdate + teval1 + teval2 + tpos + tnorm
print('Time taken per step', file=log)
print(f'psi = {tpsi/ttot}', file=log)
print(f'psiH = {tpsiH/ttot}', file=log)
print(f'grad = {tgrad/ttot}', file=log)
print(f'update = {tupdate/ttot}', file=log)
print(f'eval1 = {teval1/ttot}', file=log)
print(f'eval2 = {teval2/ttot}', file=log)
print(f'pos = {tpos/ttot}', file=log)
print(f'norm = {tnorm/ttot}', file=log)
print(f'tally = {ttally/ttot}', file=log)
if verbosity > 1:
print('Time taken per step', file=log)
print(f'psi = {tpsi/ttot}', file=log)
print(f'psiH = {tpsiH/ttot}', file=log)
print(f'grad = {tgrad/ttot}', file=log)
print(f'update = {tupdate/ttot}', file=log)
print(f'eval1 = {teval1/ttot}', file=log)
print(f'eval2 = {teval2/ttot}', file=log)
print(f'pos = {tpos/ttot}', file=log)
print(f'norm = {tnorm/ttot}', file=log)
print(f'tally = {ttally/ttot}', file=log)

if k == maxit-1:
if verbosity:
Expand Down
9 changes: 8 additions & 1 deletion pfb/parser/model2comps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ inputs:
- (.)out.yml

outputs:
{}
mds-out:
implicit: =IFSET(current.model-out, current.model-out, '{current.output-filename}_{current.product}_{current.suffix}_{current.model-name}.mds')
dtype: Directory
must_exist: false
# fits-out:
# implicit: =IFSET(current.model-out, STRIPEXT(current.model-out)+.fits, '{current.output-filename}_{current.product}_{current.suffix}_{current.model-name}.mds')
# dtype: Directory
# must_exist: false

policies:
pass_missing_as_none: true
9 changes: 9 additions & 0 deletions pfb/parser/sara.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,21 @@ inputs:
default: 0.5
info:
Reduce the regularisation strength by this fraction at the outset.
verbosity:
dtype: int
default: 1
info:
Set to larger than 1 to report timings during residual computation

outputs:
dds-out:
implicit: '{current.output-filename}_{current.product}_{current.suffix}.dds'
dtype: Directory
must_exist: false
mds-out:
implicit: '{current.output-filename}_{current.product}_{current.suffix}_model.mds'
dtype: Directory
must_exist: false

policies:
pass_missing_as_none: true
3 changes: 2 additions & 1 deletion pfb/workers/sara.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ def _sara(**kw):
nthreads=opts.nthreads,
epsilon=opts.epsilon,
do_wgridding=opts.do_wgridding,
double_accum=opts.double_accum)
double_accum=opts.double_accum,
verbosity=opts.verbosity)
write_futures.append(fut)

residual /= wsum
Expand Down

0 comments on commit ff2831c

Please sign in to comment.