Skip to content

Commit 718df0d

Browse files
threadpool: do not wakeup threads in already paused threadpool
1 parent a99c104 commit 718df0d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ggml/src/ggml.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18967,8 +18967,10 @@ void ggml_pause_threadpool(struct ggml_compute_threadpool * threadpool) {
1896718967
GGML_ASSERT(!threadpool->disposable);
1896818968
GGML_PRINT_DEBUG("Pausing threadpool\n");
1896918969
ggml_mutex_lock(&threadpool->mutex);
18970-
threadpool->pause = true;
18971-
ggml_cond_broadcast(&threadpool->cond);
18970+
if (!threadpool->pause) {
18971+
threadpool->pause = true;
18972+
ggml_cond_broadcast(&threadpool->cond);
18973+
}
1897218974
ggml_mutex_unlock(&threadpool->mutex);
1897318975
#else
1897418976
UNUSED(threadpool);
@@ -18981,8 +18983,10 @@ void ggml_resume_threadpool(struct ggml_compute_threadpool * threadpool) {
1898118983
GGML_PRINT_DEBUG("Resuming threadpool\n");
1898218984

1898318985
ggml_mutex_lock(&threadpool->mutex);
18984-
threadpool->pause = false;
18985-
ggml_cond_broadcast(&threadpool->cond);
18986+
if (threadpool->pause) {
18987+
threadpool->pause = false;
18988+
ggml_cond_broadcast(&threadpool->cond);
18989+
}
1898618990
ggml_mutex_unlock(&threadpool->mutex);
1898718991
#else
1898818992
UNUSED(threadpool);

0 commit comments

Comments
 (0)