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

debug memory leak in wave #845

Closed
wants to merge 1 commit into from
Closed
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
30 changes: 17 additions & 13 deletions examples/wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from pytools.obj_array import flat_obj_array

from grudge.shortcuts import make_visualizer
# from grudge.shortcuts import make_visualizer
import grudge.op as op

from mirgecom.discretization import create_discretization_collection
Expand Down Expand Up @@ -124,10 +124,11 @@ def main(actx_class, use_profiling=False, use_logmgr=False, lazy: bool = False):
logmgr_add_device_memory_usage(logmgr, queue)
logmgr_add_mempool_usage(logmgr, alloc)

logmgr.add_watches(["step.max", "t_step.max", "t_log.max"])
logmgr.add_watches(["step.max"])

try:
logmgr.add_watches(["memory_usage_python.max", "memory_usage_gpu.max"])
logmgr.add_watches(["memory_usage_mempool_managed.max",
"memory_usage_mempool_active.max"])
except KeyError:
pass

Expand All @@ -137,33 +138,36 @@ def main(actx_class, use_profiling=False, use_logmgr=False, lazy: bool = False):
vis_timer = IntervalTimer("t_vis", "Time spent visualizing")
logmgr.add_quantity(vis_timer)

vis = make_visualizer(dcoll)
# vis = make_visualizer(dcoll)

def rhs(t, w):
return wave_operator(dcoll, c=wave_speed, w=w)

compiled_rhs = actx.compile(rhs)
fields = force_evaluation(actx, fields)

import gc

t = 0
t_final = 1
istep = 0
while t < t_final:
if logmgr:
logmgr.tick_before()

gc.collect()

fields = rk4_step(fields, t, dt, compiled_rhs)
fields = force_evaluation(actx, fields)

if istep % 10 == 0:
if use_profiling:
print(actx.tabulate_profiling_data())
print(istep, t, actx.to_numpy(op.norm(dcoll, fields[0], 2)))
vis.write_vtk_file("fld-wave-%04d.vtu" % istep,
[
("u", fields[0]),
("v", fields[1:]),
], overwrite=True)
if istep == 10:
gc.set_debug(gc.DEBUG_SAVEALL)
gc.collect()
gc.set_debug(0)
obj_list = gc.garbage

for obj in obj_list:
print(type(obj))

t += dt
istep += 1
Expand Down