Skip to content
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
9 changes: 8 additions & 1 deletion emlx/c_src/emlx_runtime_call_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@ struct PendingRuntimeCall {
// A worker thread uses only these two streams. Its own stream is the default
// stream for its device. The ops of the other device use the default stream of
// that device.
//
// The GPU stream is only peeked. An op on the default GPU stream of the thread
// creates that stream first, so a thread without one has no GPU work to wait for.
// default_stream() would create the stream on a :cpu worker only to commit an
// empty command buffer and wait for it.
inline void synchronize_thread_streams() {
if (mlx::core::is_available(mlx::core::Device::gpu)) {
mlx::core::synchronize(mlx::core::default_stream(mlx::core::Device::gpu));
if (auto gpu = mlx::core::peek_default_stream(mlx::core::Device::gpu)) {
mlx::core::synchronize(*gpu);
}
}
mlx::core::synchronize(mlx::core::default_stream(mlx::core::Device::cpu));
}
Expand Down
Loading