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

Avoid synchronizing freed queues. #247

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
7 changes: 6 additions & 1 deletion lib/cl/cmdqueue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ mutable struct CmdQueue <: CLObject
function CmdQueue(q_id::cl_command_queue; retain::Bool=false)
q = new(q_id)
retain && clRetainCommandQueue(q)
finalizer(clReleaseCommandQueue, q)
finalizer(q) do _
# this is to prevent `device_synchronize()` operating on freed queues.
# XXX: why does the WeakKeyDict contain freed objects?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order of finalizers? E.g. the second finalizer that removes q from queues hasn't run yet?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That, or maybe the objects are collected as part of a single collection cycle? In any case, kind-of surprising.

delete!(cl.queues, q)
clReleaseCommandQueue(q)
end
return q
end
end
Expand Down