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

Remove completed task references #104

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions src/python/parla/cython/scheduler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ class WorkerThread(ControllableThread, SchedulerContext):
if isinstance(final_state, tasks.TaskRunahead):
final_state = tasks.TaskCompleted(final_state.return_value)
core.binlog_2("Worker", "Completed task: ", active_task.inner_task, " on worker: ", self.inner_worker)
active_task.cleanup()

# print("Finished Task", active_task, flush=True)
active_task.state = final_state
Expand Down
19 changes: 13 additions & 6 deletions src/python/parla/cython/tasks.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ from parla.common.globals import AccessMode, Storage
from parla.common.parray.core import PArray
from parla.common.globals import SynchronizationType as SyncType

import gc

PyDevice = device.PyDevice
PyCUDADevice = device.PyCUDADevice
PyCPUDevice = device.PyCPUDevice
Expand Down Expand Up @@ -556,6 +558,10 @@ class ComputeTask(Task):
return self.func(self, *self.args)

def cleanup(self):
print("Task cleanup is called.")
print("\tfunc refs:", gc.get_referrers(self.func))
print("\targs refs:", gc.get_referrers(self.args))
print("\tdata flow refs:", gc.get_referrers(self.dataflow))
self.func = None
self.args = None
self.dataflow = None
Expand Down Expand Up @@ -604,6 +610,13 @@ class DataMovementTask(Task):
#print(self, "STATUS: ", self.parray.print_overview())
return TaskRunahead(0)

def cleanup(self):
print("Datamove Task cleanup is called.")
print("\t Parray reference count:", gc.get_referrers(self.parray))
# Release the reference
self.parray = None


######
# Task Environment
######
Expand Down Expand Up @@ -1635,9 +1648,3 @@ class BackendTaskSpace(TaskSpace):

def wait(self):
self.inner_space.wait()