@@ -18898,6 +18898,12 @@ static void ggml_resume_threadpool_locked(struct ggml_compute_threadpool * threa
18898
18898
GGML_PRINT_DEBUG("Resuming threadpool\n");
18899
18899
threadpool->pause = false;
18900
18900
ggml_cond_broadcast(&threadpool->cond);
18901
+
18902
+ // Update main thread prio and affinity to match the threadpool settings
18903
+ ggml_thread_apply_thread_priority(threadpool->prio);
18904
+ if (ggml_thread_cpumask_is_valid(threadpool->workers[0].cpumask)) {
18905
+ ggml_thread_apply_affinity(threadpool->workers[0].cpumask);
18906
+ }
18901
18907
}
18902
18908
#endif
18903
18909
@@ -19324,6 +19330,14 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
19324
19330
}
19325
19331
19326
19332
ggml_thread_cpumask_next(tpp->cpumask, workers[0].cpumask, tpp->strict_cpu, &cpumask_iter);
19333
+
19334
+ if (!threadpool->pause) {
19335
+ // Update main thread prio and affinity at the start, otherwise we'll do it in resume
19336
+ ggml_thread_apply_thread_priority(threadpool->prio);
19337
+ if (ggml_thread_cpumask_is_valid(threadpool->workers[0].cpumask)) {
19338
+ ggml_thread_apply_affinity(threadpool->workers[0].cpumask);
19339
+ }
19340
+ }
19327
19341
#endif // GGML_USE_OPENMP
19328
19342
19329
19343
return threadpool;
@@ -19380,12 +19394,6 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19380
19394
ggml_graph_compute_thread(&threadpool->workers[0]);
19381
19395
}
19382
19396
#else
19383
- // Update main thread prio and affinity to match the current threadpool
19384
- ggml_thread_apply_thread_priority(threadpool->prio);
19385
- if (ggml_thread_cpumask_is_valid(threadpool->workers[0].cpumask)) {
19386
- ggml_thread_apply_affinity(threadpool->workers[0].cpumask);
19387
- }
19388
-
19389
19397
// Kick all threads to start the new graph
19390
19398
ggml_graph_compute_kickoff(threadpool);
19391
19399
0 commit comments