From a64d182b8bac1ac09bbda2b61ce83d38ea87cd3f Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 23 Sep 2023 10:44:41 +0800 Subject: [PATCH] sched yield fix again --- ggml.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ggml.c b/ggml.c index 29902e1c0..81c40041e 100644 --- a/ggml.c +++ b/ggml.c @@ -17290,18 +17290,14 @@ static thread_ret_t ggml_graph_compute_thread(void * data) { } else { // wait for other threads to finish const int last = node_n; - 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) + do { + #if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_METAL) + //apple does nothing + #else sched_yield(); -#endif - + #endif node_n = atomic_load(&state->shared->node_n); - if (node_n != last) break; - }; + } while (node_n == last); } // check if we should stop