Skip to content

Commit 1904115

Browse files
committed
fixed a harmless race condition
1 parent 67b04b7 commit 1904115

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ggml/src/ggml.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19355,18 +19355,16 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
1935519355
};
1935619356

1935719357
threadpool = ggml_create_threadpool_impl(&ttp, true, cgraph, cplan);
19358-
} else if (n_threads > threadpool->n_threads_max) {
19359-
GGML_PRINT("WARNING: cplan is requesting more threads than the threadpool contains. Expect a bad time!\n");
19360-
}
19361-
19362-
// Set up work
19363-
threadpool->cgraph = cgraph;
19364-
threadpool->cplan = cplan;
19365-
threadpool->n_threads_cur = n_threads;
19366-
19367-
if (!disposable_threadpool) {
19358+
} else {
19359+
if (n_threads > threadpool->n_threads_max) {
19360+
GGML_PRINT("WARNING: cplan is requesting more threads than the threadpool contains. Expect a bad time!\n");
19361+
}
19362+
// Not a disposable threadpool:
1936819363
// Reset some of the paramters that need resetting
1936919364
// No worker threads should be accessing the parameters below at this stage
19365+
threadpool->cgraph = cgraph;
19366+
threadpool->cplan = cplan;
19367+
threadpool->n_threads_cur = n_threads;
1937019368
threadpool->n_barrier = 0;
1937119369
threadpool->n_barrier_passed = 0;
1937219370
threadpool->current_chunk = 0;

0 commit comments

Comments
 (0)