mirror of
https://github.com/ml-explore/mlx.git
synced 2025-07-15 21:21:16 +08:00
fix order device -> scheduler (#1039)
This commit is contained in:
parent
5bfe89bdb1
commit
67d1894759
@ -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<void()> 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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user