Skip to content

Commit

Permalink
ggml : use sched_yield when using BLAS + add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Sep 12, 2023
1 parent 39c4fc5 commit 09a6325
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -17283,10 +17283,18 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
} else {
// wait for other threads to finish
const int last = node_n;
do {
//sched_yield();
while (true) {
// TODO: this sched_yield can have significant impact on the performance - either positive or negative
// depending on the workload and the operating system.
// since it is not clear what is the best approach, it should potentially become user-configurable
// ref: https://github.com/ggerganov/ggml/issues/291
#if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_OPENBLAS)
sched_yield();
#endif

node_n = atomic_load(&state->shared->node_n);
} while (node_n == last);
if (node_n != last) break;
};
}

// check if we should stop
Expand Down

0 comments on commit 09a6325

Please sign in to comment.