File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -19169,7 +19169,14 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
19169
19169
}
19170
19170
}
19171
19171
19172
+ if (cgraph->n_nodes == 1) {
19173
+ // We need a barrier before disabling new_work in case we have a trivial graph
19174
+ ggml_barrier(state->threadpool);
19175
+ }
19176
+
19172
19177
if (!state->threadpool->disposable && state->ith == 0) {
19178
+ // Don't need a lock, because there is a barrier after this, and only after that
19179
+ // do the secondary threads go into standby
19173
19180
state->threadpool->new_work = false;
19174
19181
}
19175
19182
@@ -19411,6 +19418,8 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19411
19418
threadpool->new_work = true;
19412
19419
ggml_cond_broadcast(&threadpool->cond);
19413
19420
ggml_mutex_unlock(&threadpool->mutex);
19421
+ } else {
19422
+ threadpool->new_work = true;
19414
19423
}
19415
19424
}
19416
19425
// this is a work thread too
You can’t perform that action at this time.
0 commit comments