mirror of
https://github.com/ml-explore/mlx.git
synced 2025-07-16 13:51:13 +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;
|
std::thread thread;
|
||||||
|
|
||||||
StreamThread(Stream stream)
|
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() {
|
~StreamThread() {
|
||||||
synchronize(stream);
|
synchronize(stream);
|
||||||
@ -37,7 +39,6 @@ struct StreamThread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void thread_fn() {
|
void thread_fn() {
|
||||||
bool initialized = false;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
std::function<void()> task;
|
std::function<void()> task;
|
||||||
{
|
{
|
||||||
@ -50,15 +51,6 @@ struct StreamThread {
|
|||||||
q.pop();
|
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();
|
task();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user