File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -17283,10 +17283,18 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
17283
17283
} else {
17284
17284
// wait for other threads to finish
17285
17285
const int last = node_n;
17286
- do {
17287
- //sched_yield();
17286
+ while (true) {
17287
+ // TODO: this sched_yield can have significant impact on the performance - either positive or negative
17288
+ // depending on the workload and the operating system.
17289
+ // since it is not clear what is the best approach, it should potentially become user-configurable
17290
+ // ref: https://github.com/ggerganov/ggml/issues/291
17291
+ #if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_OPENBLAS)
17292
+ sched_yield();
17293
+ #endif
17294
+
17288
17295
node_n = atomic_load(&state->shared->node_n);
17289
- } while (node_n == last);
17296
+ if (node_n != last) break;
17297
+ };
17290
17298
}
17291
17299
17292
17300
// check if we should stop
You can’t perform that action at this time.
0 commit comments