Skip to content

Commit 09a6325

Browse files
committed
ggml : use sched_yield when using BLAS + add comment
1 parent 39c4fc5 commit 09a6325

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ggml.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17283,10 +17283,18 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
1728317283
} else {
1728417284
// wait for other threads to finish
1728517285
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+
1728817295
node_n = atomic_load(&state->shared->node_n);
17289-
} while (node_n == last);
17296+
if (node_n != last) break;
17297+
};
1729017298
}
1729117299

1729217300
// check if we should stop

0 commit comments

Comments
 (0)