You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #521, code was added to the MTLCommandBuffer on_completed callback calling @error. That is not supported, in fact, any task switch from such a callback context results in a deadlock. Simply adding a print to the on_completed callback results in the following hang:
The issue is that the callback wants to switch tasks while the main thread is blocked within a system library. To demonstrate, @gbaraldi suggested launching the kernel from a separate thread (Threads.@spawn @metal ...) resulting in the main thread not being stuck so that the callback can still switch tasks.
In fact, this may suggest that the real fix here is to ensure we don't do blocking synchronization on thread 0 (the I/O thread), instead of changing how the callback work. Because of that, I'm filing the issue here rather than on ObjectiveC.jl. Such nonblocking synchronization could be ported over from CUDA.jl, where we already support doing this without blocking in libcuda.so, instead relying on a pool of worker threads.
The text was updated successfully, but these errors were encountered:
In #521, code was added to the MTLCommandBuffer on_completed callback calling
@error
. That is not supported, in fact, any task switch from such a callback context results in a deadlock. Simply adding aprint
to theon_completed
callback results in the following hang:Main thread:
Callback:
The issue is that the callback wants to switch tasks while the main thread is blocked within a system library. To demonstrate, @gbaraldi suggested launching the kernel from a separate thread (
Threads.@spawn @metal ...
) resulting in the main thread not being stuck so that the callback can still switch tasks.In fact, this may suggest that the real fix here is to ensure we don't do blocking synchronization on thread 0 (the I/O thread), instead of changing how the callback work. Because of that, I'm filing the issue here rather than on ObjectiveC.jl. Such nonblocking synchronization could be ported over from CUDA.jl, where we already support doing this without blocking in
libcuda.so
, instead relying on a pool of worker threads.The text was updated successfully, but these errors were encountered: