fix more race conditions

This commit is contained in:
Faisal Zaghloul 2024-07-31 12:42:31 -04:00 committed by fmz
parent 817eaf0c00
commit 57637326c4

View file

@ -18877,7 +18877,10 @@ void ggml_pause_threadpool(struct ggml_compute_threadpool * threadpool) {
#ifndef GGML_USE_OPENMP #ifndef GGML_USE_OPENMP
GGML_ASSERT(!threadpool->disposable); GGML_ASSERT(!threadpool->disposable);
GGML_PRINT_DEBUG("Pausing threadpool\n"); GGML_PRINT_DEBUG("Pausing threadpool\n");
ggml_mutex_lock(&threadpool->mutex);
threadpool->pause = true; threadpool->pause = true;
ggml_cond_broadcast(&threadpool->cond);
ggml_mutex_unlock(&threadpool->mutex);
#else #else
UNUSED(threadpool); UNUSED(threadpool);
#endif #endif
@ -19348,9 +19351,9 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
__thread_affinity(threadpool->workers[0].cpumask); __thread_affinity(threadpool->workers[0].cpumask);
} }
threadpool->new_work = true;
if (!threadpool->poll) { if (!threadpool->poll) {
ggml_mutex_lock(&threadpool->mutex); ggml_mutex_lock(&threadpool->mutex);
threadpool->new_work = true;
ggml_cond_broadcast(&threadpool->cond); ggml_cond_broadcast(&threadpool->cond);
ggml_mutex_unlock(&threadpool->mutex); ggml_mutex_unlock(&threadpool->mutex);
} }