threadpool: do not wakeup threads in already paused threadpool

This commit is contained in:
Max Krasnyansky 2024-08-07 23:08:31 -07:00 committed by fmz
parent 3b62f7c145
commit dfa63778bd

View file

@ -18891,8 +18891,10 @@ void ggml_pause_threadpool(struct ggml_compute_threadpool * threadpool) {
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); ggml_mutex_lock(&threadpool->mutex);
threadpool->pause = true; if (!threadpool->pause) {
ggml_cond_broadcast(&threadpool->cond); threadpool->pause = true;
ggml_cond_broadcast(&threadpool->cond);
}
ggml_mutex_unlock(&threadpool->mutex); ggml_mutex_unlock(&threadpool->mutex);
#else #else
UNUSED(threadpool); UNUSED(threadpool);
@ -18905,8 +18907,10 @@ void ggml_resume_threadpool(struct ggml_compute_threadpool * threadpool) {
GGML_PRINT_DEBUG("Resuming threadpool\n"); GGML_PRINT_DEBUG("Resuming threadpool\n");
ggml_mutex_lock(&threadpool->mutex); ggml_mutex_lock(&threadpool->mutex);
threadpool->pause = false; if (threadpool->pause) {
ggml_cond_broadcast(&threadpool->cond); threadpool->pause = false;
ggml_cond_broadcast(&threadpool->cond);
}
ggml_mutex_unlock(&threadpool->mutex); ggml_mutex_unlock(&threadpool->mutex);
#else #else
UNUSED(threadpool); UNUSED(threadpool);