From 67d1894759f7590b3d71ae06cb185c5440779f23 Mon Sep 17 00:00:00 2001 From: Awni Hannun Date: Fri, 26 Apr 2024 13:46:41 -0700 Subject: [PATCH] fix order device -> scheduler (#1039) --- mlx/scheduler.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mlx/scheduler.h b/mlx/scheduler.h index 40e33f2be..d14dd4fd5 100644 --- a/mlx/scheduler.h +++ b/mlx/scheduler.h @@ -24,7 +24,9 @@ struct StreamThread { std::thread thread; StreamThread(Stream stream) - : stop(false), stream(stream), thread(&StreamThread::thread_fn, this) {} + : stop(false), stream(stream), thread(&StreamThread::thread_fn, this) { + metal::new_stream(stream); + } ~StreamThread() { synchronize(stream); @@ -37,7 +39,6 @@ struct StreamThread { } void thread_fn() { - bool initialized = false; while (true) { std::function task; { @@ -50,15 +51,6 @@ struct StreamThread { q.pop(); } - // thread_fn may be called from a static initializer and we cannot - // call metal-cpp until all static initializers have completed. waiting - // for a task to arrive means that user code is running so metal-cpp - // can safely be called. - if (!initialized) { - initialized = true; - metal::new_stream(stream); - } - task(); } }