File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -19190,7 +19190,14 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
19190
19190
}
19191
19191
}
19192
19192
19193
+ if (cgraph->n_nodes == 1) {
19194
+ // We need a barrier before disabling new_work in case we have a trivial graph
19195
+ ggml_barrier(state->threadpool);
19196
+ }
19197
+
19193
19198
if (!state->threadpool->disposable && state->ith == 0) {
19199
+ // Don't need a lock, because there is a barrier after this, and only after that
19200
+ // do the secondary threads go into standby
19194
19201
state->threadpool->new_work = false;
19195
19202
}
19196
19203
@@ -19432,6 +19439,8 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19432
19439
threadpool->new_work = true;
19433
19440
ggml_cond_broadcast(&threadpool->cond);
19434
19441
ggml_mutex_unlock(&threadpool->mutex);
19442
+ } else {
19443
+ threadpool->new_work = true;
19435
19444
}
19436
19445
}
19437
19446
// this is a work thread too
You can’t perform that action at this time.
0 commit comments