@@ -19237,6 +19237,12 @@ static void ggml_graph_compute_kickoff(struct ggml_compute_threadpool * threadpo
19237
19237
atomic_fetch_add_explicit(&threadpool->n_graph, 1, memory_order_relaxed);
19238
19238
19239
19239
if (threadpool->pause) {
19240
+ // Update main thread prio and affinity to match the threadpool settings
19241
+ ggml_thread_apply_thread_priority(threadpool->prio);
19242
+ if (ggml_thread_cpumask_is_valid(threadpool->workers[0].cpumask)) {
19243
+ ggml_thread_apply_affinity(threadpool->workers[0].cpumask);
19244
+ }
19245
+
19240
19246
// resume does cond broadcast
19241
19247
ggml_resume_threadpool_locked(threadpool);
19242
19248
} else {
@@ -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