Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix progress #56

Merged
merged 6 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ gpu =
profile =
click
line-profiler
pyuvsim
pyuvsim>=1.2.5
test =
ipython
matplotlib
pyradiosky
pytest
pytest-cov
pyuvsim[sim]@git+https://github.com/RadioAstronomySoftwareGroup/pyuvsim
pyuvsim[sim]>=1.2.5

[test]
extras = True
Expand Down
17 changes: 9 additions & 8 deletions src/vis_cpu/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eq2top": ("np.dot(eq2top",),
"beam_interp": ("_evaluate_beam_cpu(",),
"get_tau": ("np.dot(antpos",),
"get_antenna_vis": ("v = get_antenna_vis(",),
"get_antenna_vis": ("v = _get_antenna_vis(",),
"get_baseline_vis": ("vis[t] =",),
}

Expand All @@ -44,7 +44,7 @@
"beam_interp": ("do_beam_interpolation(",),
"get_tau": ("# compute tau",),
"get_antenna_vis": ("meas_eq(",),
"get_baseline_vis": ("vis_inner_product(",),
"get_baseline_vis": ("cublas_complex_mm(",),
}

profiler = LineProfiler()
Expand Down Expand Up @@ -191,7 +191,7 @@ def profile(
print("------------- Summary of timings -------------")
for thing, (hits, time, time_per_hit, percent, nlines) in thing_stats.items():
print(
f"{thing:>19}: {hits:>4} hits, {time:.2f} seconds, {time_per_hit:.2f} sec/hit, {percent:3.2f}%, {nlines} lines"
f"{thing:>19}: {hits:>4} hits, {time:.3e} seconds, {time_per_hit:.3e} sec/hit, {percent:3.2f}%, {nlines} lines"
)
print("----------------------------------------------")

Expand All @@ -201,8 +201,9 @@ def profile(

def get_line_based_stats(lstats) -> tuple[dict, float]:
"""Convert the line-number based stats into line-based stats."""
time_unit = lstats.unit
(fn, lineno, name), timings = sorted(lstats.timings.items())[0]
d, total_time = get_stats_and_lines(fn, lineno, timings)
d, total_time = get_stats_and_lines(fn, lineno, timings, time_unit)
return d, total_time


Expand Down Expand Up @@ -244,7 +245,7 @@ def get_summary_stats(line_data, total_time, ids):
return thing_stats


def get_stats_and_lines(filename, start_lineno, timings):
def get_stats_and_lines(filename, start_lineno, timings, time_unit):
"""Match up timing stats with line content of the code."""
d = {}
total_time = 0.0
Expand All @@ -267,13 +268,13 @@ def get_stats_and_lines(filename, start_lineno, timings):

d[sublines[idx].rstrip("\n").rstrip("\r")] = (
nhits,
time / 1e6,
float(time) / nhits / 1e6,
time * time_unit,
float(time) / nhits * time_unit,
percent,
lineno,
)

return d, total_time / 1e6
return d, total_time * time_unit


def get_standard_sim_params(
Expand Down
6 changes: 3 additions & 3 deletions src/vis_cpu/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ def _log_progress(start_time, prev_time, iters, niters, pr, last_mem):
return prev_time, last_mem

t = time.time()
lapsed = datetime.timedelta(t - prev_time)
total = datetime.timedelta(t - start_time)
lapsed = datetime.timedelta(seconds=(t - prev_time))
total = datetime.timedelta(seconds=(t - start_time))
per_iter = total / iters
expected = per_iter * niters

Expand All @@ -418,7 +418,7 @@ def _log_progress(start_time, prev_time, iters, niters, pr, last_mem):
Progress Info [{iters}/{niters} times ({100 * iters / niters:.1f}%)]
-> Update Time: {lapsed}
-> Total Time: {total} [{per_iter} per integration]
-> Expected Time: {expected:.2f} [{expected - total} remaining]
-> Expected Time: {expected} [{expected - total} remaining]
-> Memory Usage: {mem} [{memdiff}]
"""
)
Expand Down