Skip to content

SyclEvent deleter no longer waits #751

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

Merged
merged 5 commits into from
Feb 1, 2022

Conversation

oleksandr-pavlyk
Copy link
Contributor

Added dpctl/_host_task_utils.hpp file that provides function to
submit host_task to decrement reference counts for each
Python object passed to one, gated by passed event references.

Host task is submitted to sycl::queue behind the QRef argument.

dpctl.SyclQueue.submit changes the mechanism by which it ensures that
Python objects (and memory they hold) that the kernel works on
are not GC collected before the kernel completes its execution.

We used to store reference to arguments in the dpctl.SyclEvent object
returned by SyclQueue.submit. To avoid GC-ing kernel arguments
before kernel completes execution, deleter of SyclEvent has to
call SyclEvent.wait.

With this PR SyclQueue.submit increments reference counts of
arguments after submission, then schedules a host task on the same
queue, dependent on the kernel event, which acquires GIL and
decrements reference counts.

After this change the SyclEven.__dealloc__ no longer has to wait.
It also no longer needs to store args attribute. This is now
deprecated and will be removed.

@github-actions
Copy link

@coveralls
Copy link
Collaborator

coveralls commented Jan 27, 2022

Coverage Status

Coverage increased (+0.4%) to 81.631% when pulling 8effe77 on feature/waitless-SyclEvent_deleter into 05a5abd on master.

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the feature/waitless-SyclEvent_deleter branch 2 times, most recently from cc0aee9 to 83dd0f4 Compare January 31, 2022 23:08
Added _host_task_utils.hpp file that provides function to
submit host task to decrement reference count for each
Python object passed to one gated by passed event references.

Host task is submitted to sycl::queue behind the given QRef.

SyclQueue.submit changes the mechanism by which it ensures that
Python objects (and memory they hold) that the kernel works on
are not GC collected before the kernel completes its execution.

We used to store reference to arguments in the SyclEvent object
returned by SyclQueue.submit. To avoid GC-ing kernel arguments
before kernel completes execution, deleter of SyclEvent has to
call `SyclEvent.wait`.

With this PR `SyclQueue.submit` increments reference counts of
arguments after submission, then schedules a host task on the same
queue, dependent on the kernel event, which aquires GIL and
decrements reference counts.

After this change the SyclEven.__dealloc__ no longer has to wait.
It also no longer needs to store args attribute. This is now
deperecated and will be removed.
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the feature/waitless-SyclEvent_deleter branch from 83dd0f4 to 8effe77 Compare February 1, 2022 01:02
@oleksandr-pavlyk oleksandr-pavlyk merged commit 66c885c into master Feb 1, 2022
@oleksandr-pavlyk oleksandr-pavlyk deleted the feature/waitless-SyclEvent_deleter branch February 1, 2022 11:25
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants