From 82224f84d73e54932bff3b3b606610c04df9e8ca Mon Sep 17 00:00:00 2001 From: Faisal Zaghloul Date: Wed, 31 Jul 2024 12:42:30 -0400 Subject: [PATCH] fixed a harmless race condition --- ggml/src/ggml.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 6df6ffa83..1185e785c 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -19300,18 +19300,16 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl }; threadpool = ggml_create_threadpool_impl(&ttp, true, cgraph, cplan); - } else if (n_threads > threadpool->n_threads_max) { - GGML_PRINT("WARNING: cplan is requesting more threads than the threadpool contains. Expect a bad time!\n"); - } - - // Set up work - threadpool->cgraph = cgraph; - threadpool->cplan = cplan; - threadpool->n_threads_cur = n_threads; - - if (!disposable_threadpool) { + } else { + if (n_threads > threadpool->n_threads_max) { + GGML_PRINT("WARNING: cplan is requesting more threads than the threadpool contains. Expect a bad time!\n"); + } + // Not a disposable threadpool: // Reset some of the paramters that need resetting // No worker threads should be accessing the parameters below at this stage + threadpool->cgraph = cgraph; + threadpool->cplan = cplan; + threadpool->n_threads_cur = n_threads; threadpool->n_barrier = 0; threadpool->n_barrier_passed = 0; threadpool->current_chunk = 0;